Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTPtrSlist<T>

Alternative interface: no Standard C++ Library

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

Synopsis

#include <rw/tpslist.h>
RWTPtrSlist<T> list;

Please Note!


If you do not have the Standard C++ Library, use the interface described here. Otherwise, use the interface to RWTPtrSlist described in the Class Reference.


Description

This class maintains a collection of pointers to type T, implemented as a singly-linked list. This is a pointer based list: pointers to objects are copied in and out of the links that make up the list.

Parameter T represents the type of object to be inserted into the list, either a class or fundamental type. The class T must have:

Persistence

Isomorphic

Example

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

#include <rw/tpslist.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>

main()  {
  RWTPtrSlist<RWDate> dates;
  dates.insert(new RWDate(2, "June", 52));        // 6/2/52
  dates.insert(new RWDate(30, "March", 46));      // 3/30/46
  dates.insert(new RWDate(1, "April", 90));       // 4/1/90

  // Now look for one of the dates:
  RWDate key(2, "June", 52);
  RWDate* d = dates.find(&key);
  if (d){
    cout << "Found date " << *d << endl;
  }

  // Remove in reverse order:
  while (!dates.isEmpty()){
    d = dates.removeLast();
    cout << *d << endl;
    delete d;
  }

  return 0;
}

Program output:

Found date June 2, 1952
April 1, 1990
March 30, 1946
June 2, 1952

Public Constructors

RWTPtrSlist<T>();
RWTPtrSlist<T>(const RWTPtrSlist<T>& c);

Public Operators

RWTPtrSlist&
operator=(const RWTPtrSlist<T>& c);
T*&
operator[](size_t i);
T* const&
operator[](size_t i) const;

Public Member Functions

void
append(T* a);
void
apply(void (*applyFun)(T*, void*), void* d);
T*&
at(size_t i);
T* const;
at(size_t i) const;
void
clear();
void
clearAndDestroy();
RWBoolean
contains(const T* a) const;
RWBoolean
contains(RWBoolean (*testFun)(T*, void*),void* d) const;
size_t
entries() const;
T*
find(const T* target) const;
T*
find(RWBoolean (*testFun)(T*, void*),void* d,) const;
T*&
first();
T* const&
first() const;
T*
get();
size_t
index(const T* a);
size_t
index(RWBoolean (*testFun)(T*, void*),void* d) const;
void 
insert(T* a);
void
insertAt(size_t i, T* a);
RWBoolean
isEmpty() const;
T*&
last();
T* const&
last() const;
size_t
occurrencesOf(const T* a) const;
size_t
occurrencesOf(RWBoolean (*testFun)(T*, void*),void* d) 
              const;
void
prepend(T* a);
T*
remove(const T* a);
T*
remove(RWBoolean (*testFun)(T*, void*),void* d);
size_t
removeAll(const T* a);
size_t
removeAll(RWBoolean (*testFun)(T*, void*),void* d);
T*
removeAt(size_t i);
T*
removeFirst();
T*
removeLast();

Related Global Operators

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


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