Rogue Wave Software logo banner

Click on the banner to return to the Class Reference home page.

©Copyright 1996 Rogue Wave Software

RWGDlist(type)

Synopsis

#include <rw/gdlist.h>
declare(RWGDlist, type)

RWGDlist(type) a;

Description

Class RWGDlist(type) represents a group of ordered elements of type type, not accessible by an external key. Duplicates are allowed. This class is implemented as a doubly-linked list. Objects of type RWGDlist(type) are declared with macros defined in the standard C++ header file <generic.h>.

In order to find a particular item within the collection, a user-provided global "tester" function is required to test for a "match," definable in any consistent way. This function should have prototype:

RWBoolean yourTesterFunction(const type* c, const void* d);

The argument c is a candidate within the collection to be tested for a match. The argument d is for your convenience and will be passed to yourTesterFunction(). The function should return TRUE if a "match" is found between c and d.

In order to simplify the documentation below, an imaginary typedef

typedef RWBoolean (*yourTester)(const type*, const void*);

has been used for this tester function.

Persistence

None

Example

#include <rw/gdlist.h>
#include <rw/rstream.h>

declare(RWGDlist,int)    /* Declare a list of ints */

main()  {
  RWGDlist(int) list;    // Define a list of ints
  int *ip;

  list.insert(new int(5));   // Insert some ints
  list.insert(new int(7));
  list.insert(new int(1));
  list.prepend(new int(11));

  RWGDlistIterator(int) next(list);

  while(ip = next() )
    cout << *ip << endl;   // Print out the members

  while(!list.isEmpty())
    delete list.get();     // Remove & delete list items

  return 0;
}

Program output:

     11
     5
     7
     1

Public Constructors

RWGDlist(type)();
RWGDlist(type)(type* a);
RWGDlist(type)(const RWGDlist(type)& a);

Assignment Operator

void
operator=(const RWGDlist(type)& a);

Public Member Functions

type*
append(type* a);
void
apply(void (*ap)(type*, void*), void* );
type*&
at(size_t i);
const type*
at(size_t i) const;
void
clear();
RWBoolean
contains(yourTester t, const void* d) const;
RWBoolean
containsReference(const type* e) const;
size_t
entries() const;
type*
find(yourTester t, const void* d) const;
type*
findReference(const type* e) const;
type*
first() const;
type*
get();
type*
insert(type* e);
void
insertAt(size_t indx, type* e);
RWBoolean
isEmpty() const;
type*
last() const;
size_t
occurrencesOf(yourTester t, const void* d) const;
size_t
occurrencesOfReference(const type* e) const;
type*
prepend(type* a);
type*
remove(yourTester t, const void* d);
type*
removeReference(const type* e);