Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTValSortedDlist<T,C>

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

Synopsis

#include <rw/tvsrtdli.h> 
RWTValSortedDlist<T,C> srtdlist;

Standard C++ Library Dependent!


RWTValSortedDlist requires the Standard C++ Library.


Description

This class maintains an always-sorted collection of values, implemented as a doubly-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 sorted doubly-linked list of RWDates is exercised.

//
// tvsdldat.cpp
//
#include <rw/tvsrtdli.h>
#include <rw/rwdate.h>
#include <iostream.h>
#include <function.h>

main(){
  RWTValSortedDList<RWDate, less<RWDate> > lst;

  lst.insert(RWDate(10, "Aug", 1991));
  lst.insert(RWDate(9, "Aug", 1991));
  lst.insert(RWDate(1, "Sep", 1991));
  lst.insert(RWDate(14, "May", 1990));
  lst.insert(RWDate(1, "Sep", 1991));   // Add a duplicate
  lst.insert(RWDate(2, "June", 1991));

  for (int i=0; i<lst.entries(); i++)
    cout << lst[i] << endl;
  return 0;
}

Program Output:
05/14/90
06/02/91
08/09/91
08/10/91
09/01/91
09/01/91

Related Classes

RWTValSortedVector<T> is an alternative always-sorted collections. RWTValDlist<T> is an unsorted doubly-linked list of values.

Class list<T,allocator> is the C++-standard collection that serves as the underlying implementation for this class.

Public Typedefs

typedef list<T,allocator>                      container_type; 
typedef container_type::const_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

RWTValSortedDlist<T,C>();
RWTValSortedDlist<T,C>(const list<T,allocator>& lst);
RWTValSortedDlist<T,C>(const RWTValSortedDlist<T,C>& rwlst);
RWTValSortedDlist<T,C>(size_type n, const T& val = T());
RWTValSortedDlist<T,C>(const T* first, const T* last);

Public Member Operators

RWTValSortedDlist<T,C>&
operator=(const RWTValSortedDlist<T,C>& lst); 
RWTValSortedDlist<T,C>&
operator=(const list<T,allocator>& lst);
bool
operator<(const RWTValSortedDlist<T,C>& lst) const; 
bool
operator<(const list<T,allocator>& lst) const;
bool
operator==(const RWTValSortedDlist<T,C>& lst) const; 
bool
operator==(const list<T>& lst) const;
const_reference
operator()(size_type i) const; 
const_reference
operator[](size_type i) const; 

Public Member Functions

void
apply(void (*fn)(const_reference,void*), void* d) const; 
const_reference
at(size_type i) const; 
iterator
begin();
const_iterator
begin() const;
void
clear();
bool
contains(const_reference a) const; 
bool
contains(bool (*fn)(const_reference,void*), void* d) const;
iterator
end();
const_iterator
end() const;
size_type
entries() const; 
bool
find(const_reference a, value_type& k) const; 
bool
find(bool (*fn)(const_reference,void*), void* d, 
value_type& k) const;
reference
first();
const_reference
first() const;
size_type
index(const_reference a) const; 
size_type
index(bool (*fn)(const_reference,void*), void* d) const;
size_type
insert(const list<T,allocator>& a); 
bool
insert(const_reference a); 
bool
isEmpty() const; 
bool
isSorted() const; 
const_reference
last() const; 
size_type
merge(const RWTValSortedDlist&<T,C> dl); 
size_type
occurrencesOf(const_reference) const; 
size_type
occurrencesOf(bool (*fn)(const_reference,void*),
              void* d) const;
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();
list<T,allocator>&
std();
const list<T,allocator>&
std() const;

Static Public Data Member

const size_type  npos;

Related Global Operators

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


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