Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTValSlist<T>

Alternative interface: no Standard C++ Library

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

Synopsis

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

Please Note!


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


Description

This class maintains a collection of values, implemented as a singly-linked list. This is a value based list: objects are copied in and out of the links that make up the list. Unlike intrusive lists (see class RWTIsvSlist<T>) the objects need not inherit from a link class. However, this makes the class slightly less efficient than the intrusive lists because of the need to allocate a new link off the heap with every insertion and to make a copy of the object in the newly allocated link.

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/tvslist.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>

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

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

  // Remove in reverse order:
  while (!dates.isEmpty())
    cout << dates.removeLast() << endl;

  return 0;
}

Program output:

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

Public Constructors

RWTValSlist<T>();
RWTValSlist<T>(const RWTValSlist<T>& list);

Public Operators

RWTValSlist&
operator=(const RWTValSlist<T>& list);
T&
operator[](size_t i);
const T&
operator[](size_t i) const;

Public Member Functions

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

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
Return to the main class reference
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.