Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTValSlist<T>

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/tvslist.h> 
RWTValSlist<T> lst;

Please Note!


If you have the Standard C++ Library, use the interface described here. Otherwise, use the restricted interface to RWTValSlist described in Appendix A.


Description

This class maintains a collection of values, implemented as a singly-linked list.

The value type must have operator== and operator< defined. This requirement is imposed by the Standard C++ Library.

Persistence

Isomorphic

Example

In this example, a singly-linked list of RWDates is exercised.

//
// tvslint.cpp
//
#include<rw/tvslist.h>
#include<iostream.h>

void div5(int& x, void *y){x = x/5;}

int main()
{
  const int vec[10] = {45,10,5,15,25,30,35,20,40,50};

  RWTValSlist<int> lst(vec, vec+10);
  RWTValSlistIterator<int> itr(lst);

  lst.apply(div5, 0);
  lst.sort();

  for(;itr();)
     cout << itr.key() << "  ";
  cout << endl;

  return 0;
}
Program Output:
1 2 3 4 5 6 7 8 9 10

Related Classes

Classes RWTValDeque<T>, RWTValDlist<T>, and RWTValOrderedVector<T> also provide a Rogue Wave interface to C++-standard sequence collections.

The Rogue Wave supplied, standard-compliant class rw_slist<T> is the collection that serves as the underlying implementation for this class.

Public Typedefs

typedef rw_slist<T>                            container_type; 
typedef container_type::iterator               iterator;
typedef container_type::const_iterator         const_iterator;
typedef container_type::size_type              size_type;
typedef T                                      value_type; 
typedef T&                                     reference; 
typedef const T&                               const_reference; 

Public Constructors

RWTValSlist<T>();
RWTValSlist<T>(const rw_slist<T>& lst);
RWTValSlist<T>(const RWTValSlist<T>& rwlst);
RWTValSlist<T>(size_type n, const T& val = T());
RWTValSlist<T>(const T* first, const T* last);

Public Member Operators

RWTValSlist<T>&
operator=(const RWTValSlist<T>& lst); 
RWTValSlist<T>&
operator=(const rw_slist<T>& lst);
bool
operator<(const RWTValSlist<T>& lst) const; 
bool
operator<(const rw_slist<T>& lst) const;
bool
operator==(const RWTValSlist<T>& lst) const; 
bool
operator==(const rw_slist<T>& lst) const;
reference
operator()(size_type i); 
const_reference
operator()(size_type i) const;
reference
operator[](size_type i); 
const_reference
operator[](size_type i) const;

Public Member Functions

void
append(const_reference a); 
void
apply(void (*fn)(reference,void*), void* d); 
void
apply(void (*fn)(const_reference,void*), void* d) const;
reference
at(size_type i); 
const_reference
at(size_type i) const;
iterator
begin();
const_iterator
begin() const;
void
clear();
bool
contains(const T& a) const; 
bool
contains(bool (*fn)(const T&,void*), void* d) const;
iterator
end();
const_iterator
end() const;
size_type
entries() const; 
bool
find(const_reference a,reference k) const; 
bool
find
(bool (*fn)(const_reference,void*),void* d,reference k) const;
reference
first();
const_reference
first() const;
T*
get();
size_type
index(const_reference a) const; 
size_type
index(bool (*fn)(const_reference,void*), void* d) const;
bool
insert(const_reference a); 
void
insertAt(size_type i, const T& a); 
bool
isEmpty() const; 
T
last() const; 
reference
maxElement();
const_reference
maxElement() const;
reference
minElement();
const_reference
minElement() const;
size_type 
occurrencesOf(const_reference a) const; 
size_type
occurrencesOf(bool (*fn)(const_reference,void*),void* d) const;
void
prepend(const_reference a); 
bool
remove(const_reference a); 
bool
remove(bool (*fn)(const_reference,void*), void* d);
size_type
removeAll(const_reference a); 
size_type
removeAll(bool (*fn)(const_reference,void*), void* d); 
T
removeAt(size_type i); 
T
removeFirst();
T
removeLast();
size_type
replaceAll(const_reference oldVal,const_reference newVal);
size_type
replaceAll(bool (*fn)(const_reference,void*), 
           void* d,const_reference nv);
void
sort();
rw_slist<T>&
std();
const rw_slist<T>&
std() const;

Static Public Data Member

const size_type  npos;

Related Global Operators

RWvostream&
operator<<(RWvostream& strm, const RWTValSlist<T>& coll); 
RWFile&
operator<<(RWFile& strm, const RWTValSlist<T>& coll);
RWvistream&
operator>>(RWvistream& strm, RWTValSlist<T>& coll); 
RWFile&
operator>>(RWFile& strm, RWTValSlist<T>& coll);
RWvistream&
operator>>(RWvistream& strm, RWTValSlist<T>*& p);
RWFile&
operator>>(RWFile& strm, RWTValSlist<T>*& p);


Previous fileTop of documentContentsIndexNext file
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.