©Copyright 1996 Rogue Wave Software If you are accessing this for the first time, please read the licensing statement. Tools.h++ also has a User Guide. Tools.h++ 7.0 Class Reference Introduction Class Hierarchy Contents Appendix A: Alternate Template Class Interfaces Introduction The Tools.h++ Class Reference describes all the classes and functions in Tools.h++. It does not provide a tutorial on how to program with the Tools.h++ class library. For information on how to write programs using Tools.
Conventions All Rogue Wave class names start with the letters RW, as in RWCollectable, with the bold font emphasizing the class name rather than the prefix. In some cases, we may refer to an instance of a class by an English name; for example, "the string" instead of "the RWCString instance." We do this to make it easier to read when the meaning should be clear from context, but we use the longer form if there is a possible ambiguity.
RWBinaryTree. 2. Functions that are inherited from a base class without being redefined. The complete documentation for these functions is presented in the defining base class. An example is clearAndDestroy(), for class RWBinaryTree, which is inherited from class RWCollection. When a member function is inherited without being redefined, the member function appears in both places, and this guide refers you to the original definition. 3. Functions that are redefined in a derived class.
RWOrdered RWSortedVector RWSlistCollectables RWSlistCollectablesQueue RWSlistCollectablesStack RWCollectableAssociation RWCollectableDate (&RWDate) RWCollectableInt (&RWInteger) RWCollectableString (&RWCString) RWCollectableTime (&RWTime) RWModelClient RWCRegexp RWCRExp RWCString RWCollectableString (&RWCollectable) RWCSubString RWCTokenizer RWDate RWCollectableDate (&RWCollectable) RWErrObject RWFactory RWFile RWFileManager RWGBitVec(size) RWGDlist(type) RWGDlistIterator(type) RWGOrderedVector(val) RWGQueu
RWHashDictionaryIterator RWHashTableIterator RWSetIterator RWOrderedIterator RWSlistCollectablesIterator RWLocale RWLocaleSnapshot RWMessage RWModel RWReference RWCStringRef RWVirtualRef RWWStringRef RWTime RWCollectableTime (&RWCollectable) RWTimer RWTBitVec RWTIsvDlist RWTIsvDlistIterator RWTIsvSlist RWTIsvSlistIterator RWTPtrDeque RWTPtrDlist RWTPtrDlistIterator RWTPtrHashMap RWTPtrHashMapIterator RWTPtrHashMultiMap RWTPtr
RWTPtrSetIterator RWTPtrSlist RWTPtrSlistIterator RWTPtrSlistDictionary RWTPtrSlistDictionaryIterator RWTPtrSortedDlist RWTPtrSortedDlistIterator RWTPtrSortedVector RWTPtrVector RWTQueue RWTRegularExpression RWTStack RWTValDeque RWTValDlist RWTValDlistIterator RWTValHashMap RWTValHashMapIterator RWTValHashMultiMap RWTValHashMultiMapIterato
RWTValVirtualArray RWvios ios (virtual) RWvistream RWbistream (&ios: virtual) RWeistream RWpistream RWXDRistream (&RWios) RWvostream RWbostream (&ios: virtual) RWeostream RWpostream RWXDRostream (&RWios) RWVirtualPageHeap RWBufferedPageHeap RWDiskPageHeap RWWString RWWSubString RWWTokenizer RWZone RWZoneSimple streambuf RWAuditStreamBuffer RWCLIPstreambuf RWDDEstreambuf xmsg RWxmsg RWExternalErr RWFileErr RWStreamErr RWInternalErr RWBoundsErr RWxalloc Contents ● RWAuditStreamBuffer ● RWBag ● RWBagI
● RWBinaryTree ● RWBinaryTreeIterator ● RWbistream ● RWBitVec ● RWbostream ● RWBTree ● RWBTreeDictionary ● RWBTreeOnDisk ● RWBufferedPageHeap ● RWCacheManager ● RWCLIPstreambuf ● RWCollectable ● RWCollectableAssociation ● RWCollectableDate ● RWCollectableInt ● RWCollectableString ● RWCollectableTime ● RWCollection ● RWCRegexp ● RWCRExpr ● RWCString ● RWCSubString ● RWCTokenizer ● RWDate ● RWDDEstreambuf ● RWDiskPageHeap ● RWDlistCollectables ● RWDlistCo
● RWGBitVec(size) ● RWGDlist(type) ● RWGDlistIterator(type) ● RWGOrderedVector(val) ● RWGQueue(type) ● RWGSlist(type) ● RWGSlistIterator(type) ● RWGSortedVector(val) ● RWGStack(type) ● RWGVector(val) ● RWHashDictionary ● RWHashDictionaryIterator ● rw_hashmap ● rw_hashmultimap ● rw_hashmultiset ● rw_hashset ● RWHashTable ● RWHashTableIterator ● RWIdentityDictionary ● RWIdentitySet ● RWInteger ● RWIterator ● RWLocale ● RWLocaleSnapshot ● RWModel ● RWModelClie
● rw_slist ● RWSlistCollectables ● RWSlistCollectablesIterator ● RWSlistCollectablesQueue ● RWSlistCollectablesStack ● RWSortedVector ● RWTBitVec ● RWTime ● RWTimer ● RWTIsvDlist ● RWTIsvDlistIterator ● RWTIsvSlist ● RWTIsvSlistIterator ● RWTPtrDeque ● RWTPtrDlist ● RWTPtrDlistIterator ● RWTPtrHashDictionary ● RWTPtrHashDictionaryIterator ● RWTPtrHashMap ● RWTPtrHashMapIterator ● RWTPtrHashMultiMap ● RWTPt
● RWTPtrMultiSetIterator ● RWTPtrOrderedVector ● RWTPtrSet ● RWTPtrSetIterator ● RWTPtrSlist ● RWTPtrSlistIterator ● RWTPtrSortedDlist ● RWTPtrSortedDlistIterator ● RWTPtrSortedVector ● RWTPtrVector ● RWTQueue ● RWTStack ● RWTValDeque ● RWTValDlist ● RWTValDlistIterator ● RWTValHashDictionary ● RWTValHashDictionaryIterator ● RWTValHashMap ● RWTValHashMapIterator ● RWTValHashMultiMap
● RWTValOrderedVector ● RWTValSet ● RWTValSetIterator ● RWTValSlist ● RWTValSlistIterator ● RWTValSortedDlist ● RWTValSortedDlistIterator ● RWTValSortedVector ● RWTValVector ● RWTValVirtualArray ● RWVirtualPageHeap ● RWvios ● RWvistream ● RWvostream ● RWWString ● RWWSubString ● RWWTokenizer ● RWXDRistream (Unix only) ● RWXDRostream (Unix only) ● RWZone ● RWZoneSimple
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWAuditStreamBuffer RWAuditStreamBuffer ● Synopsis ● Description ● Persistence ● Short Example ● Related Classes ● Global Typedef ● Public Constructors ● Public Destructor ● Public Member Operator ● Public Member Function ● Extended Example streambuf Synopsis #include #include
Persistence None Short Example #include #include #include #include int main() { RWCollectable ct; fillCollectable(); // make a collection, somehow RWAuditStreamBuffer bcounter, pcounter; RWbostream bcount(&bcounter); //ctor takes streambuf pointer RWpostream pcount(&pcounter); //_ bcount << ct; pcount << ct; cout << "We just counted " << bcounter << " bytes from an RWbostream.
Public Constructors RWAuditStreamBuffer(RWauditFunction=0, void*=0); Constructs a new RWAuditStreamBuffer that may be used only to examine and count every byte that passes into an ostream that has the RWAuditStreamBuffer instance as its streambuf. It will not forward the bytes to any stream, nor accept bytes from a stream. The second argument to the constructor allows you to supply storage for the byte count. It is optional.
Public Member Operator operator unsigned long(); Provides the count of bytes seen so far. Public Member Function unsigned long reset(unsigned long value = 0); Resets the count of bytes seen so far. Returns the current count. Extended Example #include #include #include #include #include
// just cout << << cout << } // end of for fun, print out some statistics: "We just saved " << crcb " bytes of data to the file." << endl; "The checksum for those bytes was " <
cout << " and the saved checksum was " << savedCRC << endl; return 0; }
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBag RWBag RWCollection ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWCollectable Synopsis typedef RWBag Bag; #include RWBag h; // Smalltalk typedef . Description Class RWBag corresponds to the Smalltalk class Bag. It represents a group of unordered elements, not accessible by an external key.
Member function apply() and the iterator are called repeatedly according to the count for an item. See class RWHashTable if you want duplicates to be stored, rather than merely counted. Persistence Polymorphic Public Constructors RWBag(size_t n = RWDEFAULT_CAPACITY); Construct an empty bag with n buckets. RWBag(const RWBag& b); Copy constructor. A shallow copy of b will be made. Public Member Operators void operator=(const RWBag& b); Assignment operator. A shallow copy of b will be made.
virtual void clear(); Redefined from class RWCollection. virtual void clearAndDestroy(); Inherited from class RWCollection. virtual int compareTo(const RWCollectable* a) const; Inherited from class RWCollectable. virtual RWBoolean contains(const RWCollectable* target) const; Inherited from class RWCollection. virtual size_t entries() const; Redefined from class RWCollection. virtual RWCollectable* find(const RWCollectable* target) const; Redefined from class RWCollection.
virtual RWBoolean isEmpty() const; Redefined from class RWCollection. virtual RWBoolean isEqual(const RWCollectable* a) const; Inherited from class RWCollectable. virtual size_t occurrencesOf(const RWCollectable* target) const; Redefined from class RWCollection. Returns the number of items that are equal to the item pointed to by target. virtual RWCollectable* remove(const RWCollectable* target); Redefined from class RWCollection. Removes and returns the item that isEqual to the item pointed to by target.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBagIterator RWBagIterator RWIterator ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Operator ● Public Member Functions Synopsis #include RWBag b; RWBagIterator it(b); Description Iterator for class RWBag, which allows sequential access to all the elements of RWBag.
Public Constructor RWBagIterator(const RWBag&); Construct an iterator for an RWBag. After construction, the position of the iterator is undefined. Public Member Operator virtual RWCollectable* operator()(); Redefined from class RWIterator. Advances the iterator to the next item and returns it. Returns nil when the end of the collection has been reached. Public Member Functions virtual RWCollectable* findNext(const RWCollectable* target); Redefined from class RWIterator.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBench ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Member Functions Synopsis #include (Abstract base class) Description This is an abstract class that can automate the process of benchmarking a piece of code. To use it, derive a class from RWBench, including a definition for the virtual function doLoop(unsigned long N).
TestBrute() { } virtual void doLoop(unsigned long n); virtual void idleLoop(unsigned long n); virtual void what(ostream& s) const { s << "Brute force string search: \n"; } }; class TestRW : public RWBench { public: TestRW() { } virtual void doLoop(unsigned long n); virtual void idleLoop(unsigned long n); virtual void what(ostream& s) const { s << "Rogue Wave search: \n"; } }; main(int argc, char* argv[]){ cout << "Testing string \n\"" << cs << "\"\n"; // Test brute force string search algorithm: TestBrute
j++; } } delete tokener; } void TestRW::doLoop(unsigned long n){ RWCString string(cs); RWCTokenizer *tokener; RWCString token, result; RWCRegexp re(""); tokener = new RWCTokenizer(string); while(n--){ if((token = (*tokener)()).
if((token = (*tokener)()).isNull()) { delete tokener; tokener = new RWCTokenizer(string); token = (*tokener)(); } re = RWCRegexp(token); } delete tokener; } Program output: Testing string "A multi-character string with lots of words in it to be parsed out and searched for." Borland C++ V4.0 Brute force string search: Iterations: Inner loop operations: Total operations: Elapsed (user) time: Kilo-operations per second: 35 1000 35000 4.596 7.61532 Borland C++ V4.
Return the current setting for the benchmark test duration. This should not be confused with function time() which returns the actual test time. virtual void go(); Call this function to run the benchmark. virtual void idleLoop(unsigned long N); This function can help to correct the benchmark for overhead. The default definition merely executes a "for()" loop N times. See the example.
Returns the current setting for the number of inner loop operations that will be passed into function doLoop(unsigned long N) as parameter N. double time() const; Returns the amount of time the benchmark took, corrected for overhead. unsigned long outerLoops() const; Returns the number of times the function doLoop() was called.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBinaryTree RWBinaryTree RWCollection ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWCollectable Synopsis typedef RWBinaryTree SortedCollection; #include RWBinaryTree bt; // Smalltalk typedef. Description Class RWBinaryTree represents a group of ordered elements, internally sorted by the compareTo() function.
Copy constructor. Constructs a shallow copy from t. Member function balance() (see below) is called before returning. virtual ~RWBinaryTree(); Redefined from RWCollection. Calls clear(). Public Member Operators void operator=(const RWBinaryTree& bt); Sets self to a shallow copy of bt. void operator+=(const RWCollection ct); Inserts each element of .ct into self.
virtual RWspace binaryStoreSize() const; Inherited from class RWCollection. virtual void clear(); Redefined from class RWCollection. virtual void clearAndDestroy(); Inherited from class RWCollection. virtual int compareTo(const RWCollectable* a) const; Inherited from class RWCollectable. virtual RWBoolean contains(const RWCollectable* target) const; Inherited from class RWCollection. virtual size_t entries() const; Redefined from class RWCollection.
careful not to insert() a long sequence of sorted items without calling balance() since the result will be very unbalanced (and therefore inefficient). virtual RWClassID isA() const; Redefined from class RWCollectable to return __RWBINARYTREE. virtual RWBoolean isEmpty() const; Redefined from class RWCollection. virtual RWBoolean isEqual(const RWCollectable* a) const; Inherited from class RWCollectable. virtual size_t occurrencesOf(const RWCollectable* target) const; Redefined from class RWCollection.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBinaryTreeIterator RWBinaryTreeIterator ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Operator ● Public Member Functions RWIterator Synopsis // Smalltalk typedef: typedef RWBinaryTreeIterator SortedCollectionIterator; #include RWBinaryTree bt; RWBinaryTreeIterator iterate(bt); Description Iterator for class RWBinaryTree.
Persistence None Public Constructor RWBinaryTreeIterator(const RWBinaryTree&); Constructs an iterator for an RWBinaryTree. Immediately after construction, the position of the iterator is undefined until positioned. Public Member Operator virtual RWCollectable* operator()(); Redefined from class RWIterator. Advances iterator to the next "largest" element and returns a pointer to it. Returns nil when the end of the collection is reached.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWbistream RWvistream RWios RWvios RWbistream ios ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions Synopsis #include
Persistence None Example See RWbostream for an example of how the file "data.dat" might be created. #include #include main(){ ifstream fstr("data.dat"); // Open an input file RWbistream bstr(fstr); // Construct RWbistream from it int i; float f; double d; bstr >> i; bstr >> f >> d; // Restore an int that was stored in binary // Restore a float & double } Public Constructors RWbistream(streambuf* s); Construct an RWbistream from the streambuf s.
operator>>(wchar_t& wc); Redefined from class RWvistream. Get the next wide char from the input stream and store it in wc. virtual RWvistream& operator>>(double& d); Redefined from class RWvistream. Get the next double from the input stream and store it in d. virtual RWvistream& operator>>(float& f); Redefined from class RWvistream. Get the next float from the input stream and store it in f. virtual RWvistream& operator>>(int& i); Redefined from class RWvistream.
Redefined from class RWvistream. Get the next unsigned long from the input stream and store it in l. operator void*(); Inherited via RWvistream from RWvios. Public Member Functions virtual int get(); Redefined from class RWvistream. Get and return the next char from the input stream. Returns EOF if end of file is encountered. virtual RWvistream& get(char& c); Redefined from class RWvistream. Get the next char and store it in c. virtual RWvistream& get(wchar_t& wc); Redefined from class RWvistream.
stores what has already been retrieved from the stream into v, and sets the failbit. virtual RWvistream& get(float* v, size_t N); Redefined from class RWvistream. Get a vector of floats and store them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason; get stores what has already been retrieved from the stream into v, and sets the failbit.
get(unsigned int* v, size_t N); Redefined from class RWvistream. Get a vector of unsigned ints and store them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason; get stores what has already been retrieved from the stream into v, and sets the failbit. virtual RWvistream& get(unsigned long* v, size_t N); Redefined from class RWvistream.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBitVec ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Assignment Operators ● Indexing Operators ● Logical Operators ● Public Member Functions ● Related Global Functions Synopsis #include RWBitVec v; Description Class RWBitVec is a bitvector whose length can be changed at run time.
main(){ // Allocate a vector with 20 bits, set to TRUE: RWBitVec av(20, TRUE); av(2) = FALSE; av.clearBit(7); av.setBit(2); // Turn bit 2 off // Turn bit 7 off // Turn bit 2 back on for(int i=11; i<=14; i++) av(i) = FALSE; cout << av << endl; // Print the vector out } Program output: [ 1 1 1 1 1 1 1 0 1 1 1 0 0 0 0 1 1 1 1 1 ] Public Constructors RWBitVec(); Construct a zero lengthed (null) vector. RWBitVec(size_t N); Construct a vector with N bits. The initial value of the bits is undefined.
Assignment Operators RWBitVec& operator=(const RWBitVec& v); Assignment operator. Value semantics are used -- self will be a copy of v. RWBitVec& operator=(RWBoolean b); Assignment operator. Sets every bit in self to the boolean value b. RWBitVec& operator&=(const RWBitVec& v); RWBitVec& operator^=(const RWBitVec& v); RWBitVec& operator|=(const RWBitVec& v); Logical assignments. Set each element of self to the logical AND, XOR, or OR, respectively, of self and the corresponding bit in v.
operator()(size_t i) const; Returns the boolean value of bit i. The result cannot be used as an lvalue. The index i must be between 0 and the length of the vector less one. Bounds checking is performed only if the preprocessor macro RWBOUNDS_CHECK has been defined before including the header file . If so, and if the index is out of range, then an exception of type RWBoundsErr will occur.
Returns the index of the first FALSE bit in self. Returns RW_NPOS if there is no FALSE bit. size_t firstTrue() const; Returns the index of the first TRUE bit in self. Returns RW_NPOS if there is no TRUE bit. unsigned hash() const; Returns a value suitable for hashing. RWBoolean isEqual(const RWBitVec& v) const; Returns TRUE if self and v have the same length and if each bit of self is set to the same value as the corresponding bit in v. Otherwise, returns FALSE.
testBit(size_t i) const; Tests the bit with index i. The index i must be between 0 and size-1. No bounds checking is performed. The following are equivalent, although testBit(size_t) is slightly smaller and faster than using operator()(size_t): if( a(i) ) doSomething(); if( a.testBit(i) ) doSomething(); Related Global Functions RWBitVec operator!(const RWBitVec& v); Unary operator that returns the logical negation of vector v.
sum(const RWBitVec& v); Returns the total number of bits set in the vector v.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWbostream RWvostream RWio RWvios RWbostream ios ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Destructor ● Public Operators ● Public Member Functions Synopsis #include
RWbostream can be interrogated as to the stream state using member functions good(), bad(), eof(), etc. Persistence None Example See RWbistream for an example of how the file "data.dat" might be read back in. #include #include main(){ ofstream fstr("data.dat"); RWbostream bstr(fstr); // Open an output file // Construct an RWbostream from it int i = 5; float f = 22.1; double d = -0.
Public Operators virtual RWvostream& operator<<(const char* s); Redefined from class RWvostream. Store the character string starting at s to the output stream in binary. The character string is expected to be null terminated. virtual RWvostream& operator<<(const wchar_t* ws); Redefined from class RWvostream. Store the wide character string starting at ws to the output stream in binary. The wide character string is expected to be null terminated.
Redefined from class RWvostream. Store the long l to the output stream in binary. virtual RWvostream& operator<<(unsigned long l); Redefined from class RWvostream. Store the unsigned long l to the output stream in binary. virtual RWvostream& operator<<(short s); Redefined from class RWvostream. Store the short s to the output stream in binary. virtual RWvostream& operator<<(unsigned short s); Redefined from class RWvostream. Store the unsigned short s to the output stream in binary.
Redefined from class RWvostream. Store the vector of wide chars starting at p to the output stream in binary. virtual RWvostream& put(const unsigned char* p, size_t N); Redefined from class RWvostream. Store the vector of unsigned chars starting at p to the output stream in binary. virtual RWvostream& put(const short* p, size_t N); Redefined from class RWvostream. Store the vector of shorts starting at p to the output stream in binary.
Redefined from class RWvostream. Store the vector of doubles starting at p to the output stream in binary. virtual RWvostream& putString(const char* p, size_t N); Redefined from class RWvostream. Data is formatted as a string containing N characters. virtual RWvostream& putString(const char*s, size_t N); Store the character string, including embedded nulls, starting at s to the output string.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBTree RWBTree RWCollection ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWCollectable Synopsis #include RWBTree a; Description Class RWBTree represents a group of ordered elements, not accessible by an external key. Duplicates are not allowed.
Persistence Polymorphic Public Constructors RWBTree(); Construct an empty B-tree. RWBTree(const RWBTree& btr); Construct self as a shallow copy of btr. Public Destructor virtual ~RWBTree(); Redefined from RWCollection. Calls clear(). Public Member Operators void operator=(const RWBTree& btr); Set self to a shallow copy of btr. RWBoolean operator<=(const RWBTree& btr) const; Returns TRUE if self is a subset of btr. That is, for every item in self, there must be an item in btr that compares equal.
function should not do anything to the items that could change the ordering of the collection. virtual RWspace binaryStoreSize() const; Inherited from class RWCollection. virtual void clear(); Redefined from class RWCollection. virtual void clearAndDestroy(); Inherited from class RWCollection. virtual int compareTo(const RWCollectable* a) const; Inherited from class RWCollectable. virtual RWBoolean contains(const RWCollectable* target) const; Inherited from class RWCollection.
The item c is inserted according to the value returned by compareTo(). If an item is already in the collection which isEqual to c, then the old item is returned and the new item is not inserted. Otherwise returns nil if the insertion was unsuccessful. virtual RWClassID isA() const; Redefined from class RWCollectable to return __RWBTREE. virtual RWBoolean isEmpty() const; Redefined from class RWCollection. virtual RWBoolean isEqual(const RWCollectable* a) const; Inherited from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBTreeDictionary RWBTreeDictionary ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWBTree RWCollection RWCollectable Synopsis #include RWBTreeDictionary a; Description Dictionary class implemented as a B-tree, for the storage and retrieval of key-value pairs.
Public Member Operators RWBoolean operator<=(const RWBTreeDictionary& btr) const; Returns TRUE if self is a subset of btr. That is, for every item in self, there must be an item in btr that compares equal. This operator is not explicitly present unless you are compiling with an implementation of the C++ Standard Library. Normally it is inherited from RWBTree.
compareTo(const RWCollectable* a) const; Inherited from class RWCollectable. virtual RWBoolean contains(const RWCollectable* target) const; Inherited from class RWCollection. virtual size_t entries() const; Redefined from class RWCollection. virtual RWCollectable* find(const RWCollectable* target) const; Redefined from class RWCollection. Returns the key in the collection which compares equal to the object pointed to by target, or nil if no key is found.
isEmpty() const; Inherited from class RWBTree. virtual RWBoolean isEqual(const RWCollectable* a) const; Inherited from class RWCollectable. virtual size_t occurrencesOf(const RWCollectable* target) const; Redefined from class RWCollection. Returns the number of keys that compare equal with target. Because duplicates are not allowed, this function can only return 0 or 1. virtual RWCollectable* remove(const RWCollectable* target); Redefined from class RWCollection.
RWBTreeDictionary allocated off the heap and returns a pointer to this new collection. Because the new dictionary is allocated off the heap, you are responsible for deleting it when done. This is not a virtual function. RWStringID stringID(); (acts virtual) Inherited from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBTreeOnDisk ● Synopsis ● Description ● Persistence ● Enumerations ● Public Constructor ● Public Member Functions Synopsis typedef long RWstoredValue ; typedef int (*RWdiskTreeCompare)(const char*, const char*, size_t); #include #include RWFileManager fm("filename.
● Make sure all buffers used for keys are at least as long as the key length (remember, storage and comparison will not stop with a null value); ● Use a comparison function (such as memcmp()) that ignores nulls. This class is meant to be used with class RWFileManager which manages the allocation and deallocation of space in a disk file. When you construct an RWBTreeOnDisk you give the location of the root node in the constructor as argument start.
Public Constructor RWBTreeOnDisk(RWFileManager& f, unsigned nbuf createMode omode unsigned keylen RWBoolean ignoreNull RWoffset start styleMode smode unsigned halfOrder unsigned minFill = = = = = = = = 10, autoCreate, 16, FALSE, RWNIL, V6Style, 10, 10); Construct a B-tree on disk. The parameters are as follows: f The file in which the B-tree is to be managed. This is the only required parameter. nbuf The maximum number of nodes that can be cached in memory.
is passed through from the call to applyToKeyAndValue(). This member function may throw an RWFileErr exception. RWoffset baseLocation() const; Returns the offset of this tree's starting location within the RWFileManager. This is the value you will pass to a constructor as the start argument when you want to open one of several trees stored in one managed file. unsigned cacheCount() const; Returns the maximum number of nodes that may currently be cached.
Returns TRUE if ky is found, otherwise FALSE. If successful, the found key is returned as a reference in foundKy, and the value is returned as a reference in foundVal. This member function may throw an RWFileErr exception. RWstoredValue findValue(const char* ky)const; Returns the value for the key that compares equal to the string pointed to by ky. Returns RWNIL if no key is found. This member function may throw an RWFileErr exception. int height(); Returns the height of the RWBTreeOnDisk.
remove(const char* ky); Removes the key and value pair that has a key which matches ky. This member function may throw an RWFileErr exception. RWBoolean replaceValue(const RWCString& key, const RWstoredValue newval, RWstoredValue& oldVal); Attempts to replace the RWstoredValue now associated with key by the value newval. If successful, the previous value is returned by reference in oldVal; and the methed returns TRUE. Otherwise, returns FALSE.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWBufferedPageHeap RWBufferedPageHeap ● Synopsis ● Description ● Persistence ● Public Constructor ● Protected Member Functions ● Public Member Functions RWVirtualPageHeap Synopsis #include (Abstract base class ) Description This is an abstract base class that represents an abstract page heap buffered through a set of memory buffers.
Persistence None Public Constructor RWBufferedPageHeap(unsigned pgsize, unsigned nbufs=10); Constructs a buffered page heap with page size pgsize. The number of buffers (each of size pgsize) that will be allocated on the heap will be nbufs. If there is insufficient memory to satisfy the request, then the state of the resultant object as returned by member function isValid() will be FALSE, otherwise, TRUE.
Redefined from class RWVirtualPageHeap. It is never an error to call this function with argument zero. Even though this is not a pure virtual function, it is the responsibility of the specializing class to supply an appropriate definition for this function. All this definition does is release any buffers associated with the handle h. Just as the actual page allocation is done by the specializing class through virtual function allocate(), so must the actual deallocation be done by overriding deallocate().
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCacheManager ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Destructor ● Public Member Functions Synopsis #include RWFile f("file.dat"); RWCacheManager(&f, 100); // Construct a file // Cache 100 byte blocks to file.dat Description Class RWCacheManager caches fixed length blocks to and from an associated RWFile.
struct Record { int i; float f; char str[15]; }; main(){ RWoffset loc; RWFile file("file.dat"); // Construct a file // Construct a cache, using 20 slots for struct Record: RWCacheManager cache(&file, sizeof(Record), 20); Record r; // ... cache.write(loc, &r); // ... cache.read(loc, &r); } Public Constructor RWCacheManager(RWFile* file, unsigned blocksz, unsigned mxblks = 10); Construct a cache for the RWFile pointed to by file. The length of the fixed-size blocks is given by blocksz.
invalidate(); Invalidate the cache. RWBoolean read(RWoffset locn, void* dat); Return the data located at offset locn of the associated RWFile. The data is put in the buffer pointed to by dat. This buffer must be at least as long as the block size specified when the cache was constructed. Returns TRUE if the operation was successful, otherwise FALSE. RWBoolean write(RWoffset locn, void* dat); Write the block of data pointed to by dat to the offset locn of the associated RWFile.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCLIPstreambuf RWCLIPstreambuf ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Destructor ● Public Member Functions streambuf Synopsis #include #include iostream str( new RWCLIPstreambuf() ); Description Class RWCLIPstreambuf is a specialized streambuf that gets and puts sequences of characters to Microsoft Windows global memory.
RWCLIPstreambuf destructor to free any allocated memory. After the call to str(), it becomes the user's responsibility. In static mode, the user has the responsibility for freeing the memory handle. However, because the constructor locks and dereferences the handle, you should not free the memory until either the destructor or str() has been called, either of which will unlock the handle. Persistence None Example //Instructions: compile as a Windows program.
ostr << "Some text to be exchanged through the clipboard.\n"; ostr << "Might as well add a double: " << d << endl; ostr.put('\0'); // Include the terminating null // Lock the streambuf, get its handle: HANDLE hMem = buf->str(); OpenClipboard(owner); EmptyClipboard(); SetClipboardData(CF_TEXT, hMem); CloseClipboard(); // Don't delete the buffer!. Windows is now responsible for it. } The owner of the clipboard is passed in as parameter "owner".
Public Member Functions Because RWCLIPstreambuf inherits from streambuf, any of the latter's member functions can be used. Furthermore, RWCLIPstreambuf has been designed to be analogous to strstreambuf. However, note that the return type of str() is a HANDLE, rather than a char*. HANDLE str(); Returns an (unlocked) HANDLE to the global memory being used. The RWCLIPstreambuf should now be regarded as "frozen": the effect of inserting any more characters is undefined.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCollectable ● Synopsis ● Description ● Persistence ● Virtual Functions ● Static Public Member Functions ● Related Global Operators Synopsis typedef RWCollectable Object; #include // Smalltalk typedef Description Class RWCollectable is an abstract base class for collectable objects.
binaryStoreSize() const; Returns the number of bytes used by the virtual function saveGuts(RWFile&) to store an object. Typically, this involves adding up the space required to store all primitives, plus the results of calling recursiveStoreSize() for all objects inheriting from RWCollectable. See the Tool.h++ User's Guide Section entitled "Virtual Function binaryStoreSize" for details.
Returns TRUE if collectable object "matches" object at address t. The default definition is: return this == t; i.e., both objects have the same address (a test for identity). The definition may be redefined in any consistent way. virtual RWCollectable* newSpecies() const; Allocates a new object off the heap of the same type as self and returns a pointer to it. You are responsible for deleting the object when done with it.
static RWClassID classIsA(); Returns the RWClassID of this class. static RWBoolean isAtom(RWClassID id); Returns TRUE if id is the RWClassID that is associated with an RWCollectable class that has a programmer-chosen RWStringID. static RWspace nilStoreSize(); Returns the number of bytes required to store a rwnil pointer in an RWFile.
for more information. Various exceptions that could be thrown are RWInternalErr (if the RWFactory does not know how to make the object), and RWExternalErr (corrupted stream or file). In case an exception is thrown during this call, the pointer to the partly restored object will probably be lost, and memory will leak. For this reason, you may prefer to use the static methods tryRecursiveRestore() documented above.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCollectableAssociation RWCollectableAssociation ● Synopsis ● Description ● Persistence ● Related Classes ● Public Constructors ● Public Destructor ● Public Member Functions RWCollectable Synopsis #include Description RWCollectableAssociation inherits class RWCollectable. Used internally to associate a key with a value in the Tools.h++ "dictionary" collection classes.
Public Constructors RWCollectableAssociation(); RWCollectableAssociation(RWCollectable* k, RWCollectable* v); Construct an RWCollectableAssociation with the given key and value. Public Destructor virtual ~RWCollectableAssociation(); virtual RWspace binaryStoreSize() const; Redefined from class RWCollectable. Public Member Functions virtual int compareTo(const RWCollectable* c) const; Redefined from class RWCollectable. Returns the results of calling key()->compareTo(c).
virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const; Redefined from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCollectableDate RWCollectable RWCollectableDate RWDate ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Functions Synopsis typedef RWCollectableDate Date; #include RWCollectableDate d; // Smalltalk typedef Description Collectable Dates. Inherits classes RWDate and RWCollectable.
RWCollectableDate(unsigned day, unsigned month, unsigned year); RWCollectableDate(unsigned day, const char* mon, unsigned year,const RWLocale& locale = RWLocale::global()); RWCollectableDate(istream& s, const RWLocale& locale = RWLocale::global()); RWCollectableDate(const RWCString& str,const RWLocale& locale = RWLocale::global()); RWCollectableDate(const RWTime& t, const RWZone& zone = RWZone::local()); RWCollectableDate(const struct tm* tmb); RWCollectableDate(const RWDate& d); Calls the corresponding con
saveGuts(RWFile&) const; Redefined from class RWCollectable. RWStringID stringID(); (acts virtual) Inherited from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCollectableInt RWCollectable RWCollectableInt RWInteger ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Functions Synopsis typedef RWCollectableInt Integer; #include RWCollectableInt i; // Smalltalk typedef Description Collectable integers. Inherits classes RWInteger and RWCollectable.
Public Constructors RWCollectableInt(); Calls the appropriate base class constructor. See RWInteger::RWInteger(). RWCollectableInt(int i); Calls the appropriate base class constructor. See RWInteger::RWInteger(int). Public Member Functions virtual RWspace binaryStoreSize() const; Redefined from class RWCollectable. virtual int compareTo(const RWCollectable* c) const; Redefined from class RWCollectable. Returns the difference between self and the RWCollectableInt pointed to by c.
stringID(); (acts virtual) Inherited from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCollectableString RWCollectable RWCollectableString RWCString ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Functions Synopsis typedef RWCollectableString String; #include RWCollectableString c; // Smalltalk typedef Description Collectable strings.
Public Constructors RWCollectableString(); Construct an RWCollectableString with zero characters. RWCollectableString(const RWCString& s); Construct an RWCollectableString from the RWCString s. RWCollectableString(const char* c); Conversion from character string. RWCollectableString(const RWCSubString&); Conversion from sub-string. RWCollectableString(char c, size_t N); Construct an RWCollectableString with N characters (default blanks).
Redefined from class RWCollectable. Calls RWCString::operator==() (i.e., the equivalence operator) with c as the argument and returns the results. virtual void restoreGuts(RWvistream&); virtual void restoreGuts(RWFile&); virtual void saveGuts(RWvostream&) const; virtual void saveGuts(RWFile&) const; Redefined from class RWCollectable. RWStringID stringID(); (acts virtual) Inherited from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCollectableTime RWCollectable RWCollectableTime RWTime ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Functions Synopsis typedef RWCollectableTime Time; #include RWCollectableTime t; // Smalltalk typedef Description Inherits classes RWTime and RWCollectable.
unsigned sec = 0,const RWZone& zone = RWZone::local()); RWCollectableTime(const RWDate& day, unsigned hour=0, unsigned minute=0, unsigned sec = 0, const RWZone& zone = RWZone::local()); RWCollectableTime(const RWDate& day, const RWCString& str, const RWZone& zone = RWZone::local(), const RWLocale& locale = RWLocale::global()); RWCollectableTime(const struct tm* tmb, const RWZone& zone = RWZone::local()); Calls the corresponding constructor of RWTime.
Redefined from class RWCollectable. RWStringID stringID(); (acts virtual) Inherited from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCollection RWCollection RWCollectable ● Synopsis ● Description ● Persistence ● Public Member Operators ● Public Member Functions Synopsis #include typedef RWCollection Collection; // Smalltalk typedef Description Class RWCollection is an abstract base class for the Smalltalk-like collection classes.
Persistence Polymorphic Public Member Operators void operator+=(const RWCollection&); void operator-=(const RWCollection&); Adds or removes, respectively, each item in the argument to or from self. Using operator+=(somePreSortedCollection) on an RWBinaryTree can cause that tree to become unbalanced; possibly to the point of stack overflow. Public Member Functions virtual ~RWCollection(); Null definition (does nothing).
asSortedCollection() or asBinaryTree() methods will build a very unbalanced tree. virtual RWspace binaryStoreSize() const; Redefined from class RWCollectable. virtual void clear() = 0; Removes all objects from the collection. Does not delete the objects themselves. virtual void clearAndDestroy(); Removes all objects from the collection and deletes them. Takes into account duplicate objects within a collection and only deletes them once.
Adds an item to the collection and returns a pointer to it. If the item is already in the collection, some collections derived from RWCollection return the old instance, others return nil. virtual RWClassID isA() const; Redefined from class RWCollectable to return __RWCOLLECTION. virtual RWBoolean isEmpty() const = 0; Returns TRUE if the collection is empty, otherwise returns FALSE. virtual RWBoolean isEqual(const RWCollectable* a) const; Inherited from class RWCollectable.
select(RWtestCollectable tst, void* x) const; Evaluates the function pointed to by tst for each item in the collection. It inserts those items for which the function returns TRUE into a new collection allocated off the heap of the same type as self and returns a pointer to this new collection. Because the new collection is allocated off the heap, you are responsible for deleting it when done. This is not a virtual function.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCRegexp ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Destructor ● Assignment Operators ● Public Member Functions Synopsis #include RWCRegexp re(".*\\.doc");// Matches filename with suffix ".doc" Description Class RWCRegexp represents a regular expression.
1.5 A set of characters enclosed in brackets ([]) is a one-character RE that matches any of the characters in that set. E.g., "[akm]" matches either an "a", "k", or "m". A range of characters can be indicated with a dash. E.g., "[a-z]" matches any lower-case letter. However, if the first character of the set is the caret (^), then the RE matches any character except those in the set. It does not match the empty string. Example: [^akm] matches any character except "a", "k", or "m".
Example #include #include #include main(){ RWCString aString("Hark! Hark! the lark"); // A regular expression matching any lower-case word // starting with "l": RWCRegexp reg("l[a-z]*"); cout << aString(reg) << endl; // Prints "lark" } Public Constructors RWCRegexp(const char* pat); Construct a regular expression from the pattern given by pat. The status of the results can be found by using member function status().
Public Member Functions size_t index(const RWCString& str,size_t* len, size_t start=0) const; Returns the index of the first instance in the string str that matches the regular expression compiled in self, or RW_NPOS if there is no such match. The search starts at index start. The length of the matching pattern is returned in the variable pointed to by len. If an invalid regular expression is used for the search, an exception of type RWInternalErr will be thrown.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCRExpr ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Destructor ● Assignment Operators ● Public Member Functions Synopsis #include RWCRExpr re(".*\\.doc"); // Matches filename with suffix ".doc" Description Class RWCRExpr represents an extended regular expression such as those found in lex and awk.
+*?.[]^$(){}|\ 3. The period (.) matches any character. E.g., ".umpty" matches either "Humpty" or "Dumpty." 4. A set of characters enclosed in brackets ([ ]) is a one-character RE that matches any of the characters in that set. E.g., "[akm]" matches either an "a", "k", or "m". A range of characters can be indicated with a dash. E.g., "[a-z]" matches any lower-case letter. However, if the first character of the set is the caret (^), then the RE matches any character except those in the set.
main(){ RWCString aString("Hark! Hark! the lark"); // A regular expression matching any lowercase word or end of a //word starting with "l": RWCRExpr re("l[a-z]*"); cout << aString(re) << endl; // Prints "lark" } Public Constructors RWCRExpr(const char* pat); RWCRExpr(const RWCString& pat); Construct a regular expression from the pattern given by pat. The status of the results can be found by using member function status(). RWCRExpr(const RWCRExpr& r); Copy constructor.
Public Member Functions size_t index(const RWCString& str, size_t* len = NULL, size_t start=0) const; Returns the index of the first instance in the string str that matches the regular expression compiled in self, or RW_NPOS if there is no such match. The search starts at index start. The length of the matching pattern is returned in the variable pointed to by len. If an invalid regular expression is used for the search, an exception of type RWInternalErr will be thrown.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCString ● Synopsis ● Description ● Persistence ● Example ● Enumerations ● Public Constructors ● Type Conversion ● Assignment Operators ● Indexing Operators ● Public Member Functions ● Static Public Member Functions ● Related Global Operators ● Related Global Functions Synopsis #include
RWCString::mbLength() to get the number of characters. Note that the latter is much slower because it must determine the number of bytes in every character. Hence, if the string is known to be nothing but SBCS, then RWCString::length() is much to be preferred. ● One or more bytes of a multibyte character can be zero. Hence, MBCS cannot be counted on being null terminated. In practice, it is a rare MBCS that uses embedded nulls. Nevertheless, you should be aware of this and program defensively.
sensitive (exact) or case-insensitive (ignoreCase) semantics. enum RWCString::scopeType { one, all } Used to specify whether regular expression replace replaces the first one substring matched by the regular expression or replaces all substrings matched by the regular expression. Public Constructors RWCString(); Creates a string of length zero (the null string). RWCString(const char* cs); Conversion from the null-terminated character string cs.
Access to the RWCString's data as a null terminated string. This data is owned by the RWCString and may not be deleted or changed. If the RWCString object itself changes or goes out of scope, the pointer value previously returned may (will!) become invalid. While the string is null-terminated, note that its length is still given by the member function length(). That is, it may contain embedded nulls. Assignment Operators RWCString& operator=(const char* cs); Assignment operator.
macro RWBOUNDS_CHECK has been defined before including . In this case, if the index is out of range, then an exception of type RWBoundsErr will occur. RWCSubString operator()(size_t start, size_t len); const RWCSubString operator()(size_t start, size_t len) const; Substring operator. Returns an RWCSubString of self with length len, starting at index start. The first variant can be used as an lvalue. The sum of start plus len must be less than or equal to the string length.
RWCString& append(char c, size_t N); Append N copies of the character c to self. Returns a reference to self. RWCString& append(const RWCString& cstr); Append a copy of the string cstr to self. Returns a reference to self. RWCString& append(const RWCString& cstr, size_t N); Append the first N bytes or the length of cstr (whichever is less) of cstr to self. Returns a reference to self.
RWCString::ignoreCase. If caseCompare is RWCString::exact, then this function works for all string types. Otherwise, this function is incompatible with MBCS strings. This function is incompatible with const char* strings with embedded nulls. This function may be incompatible with const char* MBCS strings. RWBoolean contains(const char* str, caseCompare = RWCString::exact) const; RWBoolean contains(const RWCString& cs, caseCompare = RWCString::exact) const; Pattern matching.
size_t first(const char* str, size_t N) const; Returns the index of the first occurence in self of any character in str. Exactly N bytes in str are checked including any embedded nulls so str must point to a buffer containing at least N bytes. Returns RW_NPOS if there is no match. unsigned hash(caseCompare = RWCString::exact) const; Returns a suitable hash value. If caseCompare is RWCString::ignoreCase then this function will be incompatible with MBCS strings.
index(const RWCRegexp& re,size_t* ext,size_t i=0) const; Regular expression matching. Returns the index greater than or equal to i of the start of the first pattern that matches the regular expression re. Returns RW_NPOS if there is no such pattern. The length of the matching pattern is returned in the variable pointed to by ext. This function is incompatible with strings with embedded nulls. This function may be incompatible with MBCS strings.
Returns the index of the last occurrence in the string of the character c. Continues to search past embedded nulls. Returns RW_NPOS if there is no such character. This function is incompatible with MBCS strings. size_t length() const; Return the number of bytes in self. Note that if self contains multibyte characters, then this will not be the number of characters.
Prepend the first N bytes or the length of cstr (whichever is less) of cstr to self. Returns a reference to self. istream& readFile(istream& s); Reads characters from the input stream s, replacing the previous contents of self, until EOF is reached. Null characters are treated the same as other characters. istream& readLine(istream& s, RWBoolean skipWhite = TRUE); Reads characters from the input stream s, replacing the previous contents of self, until a newline (or an EOF) is encountered.
remove(size_t pos, size_t N); Removes N bytes or to the end of string (whichever comes first) starting at the byte position pos, which must be no greater than length(). Returns a reference to self. RWCString& replace(size_t pos, size_t N, const char* cs); Replaces N bytes or to the end of string (whichever comes first) starting at byte position pos, which must be no greater than length(), with a copy of the null-terminated string cs. Returns a reference to self.
Changes the length of self to n bytes, adding blanks or truncating as necessary. RWCSubString strip(stripType s = RWCString::trailing, char c = ' '); const RWCSubString strip(stripType s = RWCString::trailing, char c = ' ') const; Returns a substring of self where the character c has been stripped off the beginning, end, or both ends of the string. The first variant can be used as an lvalue.
Static Public Member Functions static unsigned hash(const RWCString& str); Returns the hash value of str as returned by str.hash(RWCString::exact). static size_t initialCapacity(size_t ic = 15); Sets the minimum initial capacity of an RWCString, and returns the old value. The initial setting is 15 bytes. Larger values will use more memory, but result in fewer resizes when concatenating or reading strings. Smaller values will waste less memory, but result in more resizes.
operator< (const RWBoolean operator< (const RWBoolean operator> (const RWBoolean operator> (const RWBoolean operator> (const RWBoolean operator<=(const RWBoolean operator<=(const RWBoolean operator<=(const RWBoolean operator>=(const RWBoolean operator>=(const RWBoolean operator>=(const char*, const RWCString&); RWCString&, const RWCString&); RWCString&, const char* char*, ); const RWCString&); RWCString&, const RWCString&); RWCString&, const char* char*, ); const RWCString&); RWCString&, const RWCS
RWFile& operator<<(RWFile&, const RWCString& str); Saves string str to a virtual stream or RWFile, respectively. RWvistream& operator>>(RWvistream&, RWCString& str); RWFile& operator>>(RWFile&, RWCString& str); Restores a string into str from a virtual stream or RWFile, respectively, replacing the previous contents of str. Related Global Functions RWCString strXForm(const RWCString&); Returns the result of applying ::strxfrm() to the argument string, to allow quicker collation than RWCString::collate().
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCSubString ● Synopsis ● Description ● Persistence ● Example ● Assignment Operators ● Indexing Operators ● Public Member Functions ● Global Logical Operators Synopsis #include RWCString s("test string"); s(6,3); // "tri" Description The class RWCSubString allows some subsection of an RWCString to be addressed by defining a starting position and an extent.
Persistence None Example #include #include main(){ RWCString s("What I tell you is true."); // Create a substring and use it as an lvalue: s(19, 0) = "three times "; cout << s << endl; } Program output: What I tell you is three times true. Assignment Operators RWCSubString& operator=(const RWCString&); Assignment from an RWCString. The statements: RWCString a; RWCString b; ... b(2, 3) = a; will copy a's data into the substring b(2,3).
not match: if they differ, b will be resized appropriately. Sets self's extent to be the extent of the assigned RWCSubString. If self is the null substring, then the statement has no effect. Returns a reference to self. RWCSubString& operator=(const char*); Assignment from a character string. Example: RWCString str("Mary had a lamb"); char dat[] = "Perrier"; str(11,4) = dat; // "Mary had a Perrier" Note that the number of characters selected need not match: if they differ, str will be resized appropriately.
Returns the extent (i.e., length) of the RWCSubString. RWBoolean operator!() const; Returns TRUE if this is a null substring. size_t start() const; Returns the starting element of the RWCSubString. void toLower(); Changes all upper-case letters in self to lower-case. Uses the standard C library function tolower(). void toUpper(); Changes all lower-case letters in self to upper-case. Uses the standard C library function toupper().
Returns the negation of the respective operator==().
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWCTokenizer ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Member Operators Synopsis #include RWCString str("a string of tokens"); RWCTokenizer(str); // Lex the above string Description Class RWCTokenizer is designed to break a string up into separate tokens, delimited by an arbitrary "white space.
// Advance until the null string is returned: while (!(token=next()).isNull()) cout << token << "\n"; } Program output: Something is rotten in the state of Denmark Public Constructor RWCTokenizer(const RWCString& s); Construct a tokenizer to lex the string s. Public Member Operators RWCSubString operator(); Advance to the next token and return it as a substring. The tokens are delimited by any of the four characters in " \t\n\0". (space, tab, newline and null).
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWDate ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Member Functions ● Related Global Operators Synopsis #include RWDate a; // Construct today's date Description Class RWDate represents a date, stored as a Julian day number.
Those with access to the Standard C++ Library-based versions of the Tools.h++ template collections should consider the following: // Figures out the current date just once: RWTValOrderedVector v(5000, RWDate()); Thanks to the smart allocation scheme of the standard collections, the above declaration will result in only one call to the default constructor followed by 5000 invocations of the copy constructor.
RWDate(unsigned day, unsigned month, unsigned year); Constructs an RWDate with the given day of the month, month of the year, and year. Days should be 1-31, months should be 1-12, and the year may be specified as (for example) 1990, or 90. The member function isValid() can be used to test whether the results are a valid date. RWDate(unsigned day, const char* mon, unsigned year, const RWLocale& locale = RWLocale::global()); Constructs an RWDate with the given day of the month, month and year.
Public Member Operators RWDate& operator=(const RWDate&); Assignment operator. RWDate operator++(); Prefix increment operator. Adds one day to self, then return the result. RWDate operator--(); Prefix decrement operator. Subtracts one day from self, then returns the result. RWDate operator++(int); Postfix increment operator. Adds one day to self, returning the initial value. RWDate operator--(int); Postfix decrement operator. Subtracts one day from self, returning the initial value.
between(const RWDate& a, const RWDate& b) const; Returns TRUE if this RWDate is between a and b, inclusive. size_t binaryStoreSize() const; Returns the number of bytes necessary to store the object using the global function RWFile& operator<<(RWFile&, const RWDate&); int compareTo(const RWDate* d) const; Compares self to the RWDate pointed to by d and returns: 0 if self == *d; 1 if self > *d; -1 if self < *d. unsigned day() const; Returns the day of the year (1-366) for this date.
RWBoolean isValid() const; Returns TRUE if this is a valid date, FALSE otherwise. The following two functions are provided as a service to users who need to manipulate the date representation directly. The julian day number is not the Julian date!. The julian day number is calculated using Algorithm 199 from Communications of the ACM, Volume 6, No. 8, (Aug. 1963), p. 444 and is valid for any valid Gregorian date in the Gregorian calendar. The Gregorian calendar was first introduced on Sep.
next(const char* dayName, const RWLocale& = RWLocale::global()) const; Returns the date of the next dayName (for example, the date of the previous Monday) The weekday name is interpreted according to the RWLocale argument. RWDate previous(unsigned dayNum) const; Returns the date of the previous numbered day of the week, where Monday = 1, ..., Sunday = 7. The variable dayNum must be between 1 and 7, inclusive.
static unsigned daysInYear(unsigned year); Returns the number of days in a given year. static RWBoolean dayWithinMonth(unsigned monthNum, unsigned dayNum, unsigned year); Returns TRUE if a day (1-31) is within a given month in a given year. static unsigned hash(const RWDate& d); Returns the hash value of d as returned by d.hash(). static unsigned indexOfMonth(const char* monthName, const RWLocale& = RWLocale::global()); Returns the number of the month (1-12) corresponding to the given monthName.
Related Global Operators RWBoolean operator<(const RWDate& d1, const RWDate& d2); Returns TRUE if the date d1 is before d2. RWBoolean operator<=(const RWDate& d1, const RWDate& d2); Returns TRUE if the date d1 is before or the same as d2. RWBoolean operator>(const RWDate& d1, const RWDate& d2); Returns TRUE if the date d1 is after d2. RWBoolean operator>=(const RWDate& d1, const RWDate& d2); Returns TRUE if the date d1 is after or the same as d2.
istream& operator>>(istream& s, RWDate& t); Reads t from istream s. One full line is read, and the string contained is converted according to the locale imbued in the stream (see class RWLocale), or by RWLocale::global() if none. The function RWDate::isValid() must be used to test whether the results are a valid date. RWvostream& operator<<(RWvostream&, const RWDate& date); RWFile& operator<<(RWFile&, const RWDate& date); Saves the date date to a virtual stream or RWFile, respectively.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWDDEstreambuf RWDDEstreambuf ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Destructor ● Public Member Functions RWCLIPstreambuf streambuf Synopsis #include #include
In dynamic mode, the RWDDEstreambuf "owns" any allocated memory until the member function str() is called, which "freezes" the buffer and returns an unlocked Windows handle to it. The effect of any further insertions is undefined. Until str() has been called, it is the responsibility of the RWDDEstreambuf destructor to free any allocated memory. After the call to str(), it becomes the user's responsibility. In static mode, the user always has the responsibility for freeing the memory handle.
GlobalFree(hMem); GlobalDeleteAtom(aItem); return FALSE; } return TRUE; } The handle of the DDE server is passed in as parameter hwndServer, the handle of the client as parameter hwndClient. An ostream is created, using an RWDDEstreambuf as its associated streambuf. The results can be used much like any other ostream, such as cout, except that characters will be inserted into Windows global memory, from where they can be transferred through the DDE. Note the parameters used in the constructor.
RWDDEstreambuf(HANDLE hMem); Constructs an RWDDEstreambuf in static mode, using the memory block with global handle hMem. The effect of gets and puts beyond the size of this block is unspecified. The format of the DDE transfer, and the specifics of DDE acknowledgments, memory allocations, etc., can be obtained by using the member functions defined below.
nothing has been inserted, then the returned HANDLE may be NULL. If it was constructed in static mode, then the returned handle will be the handle used to construct the RWDDEstreambuf.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWDiskPageHeap RWDiskPageHeap ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Destructor ● Public Member Functions RWBufferedPageHeap RWVirtualPageHeap Synopsis #include unsigned nbufs; unsigned pagesize; RWDiskPageHeap heap("filename", nbufs, pagesize) ; Description Class RWDiskPageHeap is a specializing type of buffered page heap.
#include #include struct Node { int key; RWHandle }; next; RWHandle head = 0; const int N = 100; // Exercise 100 Nodes main() { // Construct a disk-based page heap with page size equal // to the size of Node and with 10 buffers: RWDiskPageHeap heap(0, 10, sizeof(Node)); // Build the linked list: for (int i=0; ikey = i; newNode->next = head; head = h; heap.dirty(h); heap.
Public Constructor RWDiskPageHeap(const char* filename = 0, unsigned nbufs = 10, unsigned pgsize = 512); Constructs a new disk-based page heap. The heap will use a file with filename filename, otherwise it will negotiate with the operating system for a temporary filename. The number of buffers, each the size of the page size, will be nbufs. No more than this many pages can be locked at any one time. The size of each page is given by pgsize.
unlock(RWHandle h); Inherited from RWBufferedPageHeap.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWDlistCollectables RWDlistCollectables ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWSequenceable RWCollection RWCollectable Synopsis #include RWDlistCollectables a; Description Class RWDlistCollectables represents a group of ordered items, not accessible by an external key. Duplicates are allowed.
Public Member Functions virtual Collectable* append(RWCollectable*); Redefined from RWSequenceable. Inserts the item at the end of the collection and returns it. Returns nil if the insertion was unsuccesful. virtual void apply(RWapplyCollectable ap, void*); Redefined from class RWCollection to apply the user-supplied function pointed to by ap to each member of the collection, in order, from first to last.
found. virtual RWCollectable* first() const; Redefined from class RWSequenceable. Returns the item at the beginning of the list. RWCollectable* get(); Returns and removes the item at the beginning of the list. virtual unsigned hash() const; Inherited from class RWCollectable. virtual size_t index(const RWCollectable* c) const; Redefined from class RWSequenceable. Returns the index of the first item that isEqual to the item pointed to by c, or RW_NPOS if there is no such index.
Redefined from class RWCollection. Removes and returns the first item that isEqual to the item pointed to by target. Returns nil if there is no such item. virtual void removeAndDestroy(const RWCollectable* target); Inherited from class RWCollection. RWCollectable* removeReference(const RWCollectable* e); Removes and returns the first item that is identical to the item pointed to by e (that is, that has the address e). Returns nil if there is no such item.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWDlistCollectablesIterator RWDlistCollectablesIterator ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Operators ● Public Member Functions RWIterator Synopsis #include RWDlistCollectables d; RWDlistCollectablesIterator it(d) ; Description Iterator for class RWDlistCollectables. Traverses the linked-list from the first (head) to the last (tail) item.
Public Constructor RWDlistCollectablesIterator (RWDlistCollectables& d); Construct an RWDlistCollectablesIterator from an RWDlistCollectables. Immediately after construction, the position of the iterator is undefined. Public Member Operators virtual RWCollectable* operator()(); Redefined from class RWIterator. Advances the iterator to the next item and returns it. Returns nil when the end of the list is reached. void operator++(); Advances the iterator one item.
the iterator will be undefined. RWCollectable* findNextReference(const RWCollectable* e); Moves iterator to the next item which is identical to the item pointed to by e (that is, that has address e) and returns it. If no item is found, returns nil and the position of the iterator will be undefined. RWCollectable* insertAfterPoint(RWCollectable* a); Insert item a after the current cursor position and return the item. The cursor's position will be unchanged.
toLast(); Moves the iterator to the end of the list.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWeistream RWeistream RWbistream ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Member Functions ... ios ... RWvistream ... RWvios Synopsis #include RWeistream estr(cin); // using cin's streambuf // Construct an RWeistream, Description Class RWeistream specializes the base class RWbistream to restore values previously stored by RWeostream.
Example See RWeostream for an example of how the file "data.dat" might be created. Public Constructors RWeistream(streambuf* s); Construct an RWeistream from the streambuf s. For DOS, this streambuf must have been created in binary mode. Throw exception RWStreamErr if not a valid endian stream. RWeistream(istream& str); Construct an RWeistream using the streambuf associated with the istream str. For DOS, the str must have been opened in binary mode. Throw exception RWStreamErr if not a valid endian stream.
store whatever possible in v, and set the failbit. Also set the failbit if any values in the stream are too large to be stored in an element of v. virtual RWvistream& get(long* v, size_t N); Redefined from class RWbistream. Get a vector of longs and store them in the array beginning at v, compensating for any differences in size or endian format between the stream and the current environment. If the restore stops prematurely, store whatever possible in v, and set the failbit.
Redefined from class RWbistream. Get the next double from the input stream and store it in d, compensating for any difference in endian format between the stream and the current environment. virtual RWvistream& operator>>(float& f); Redefined from class RWbistream. Get the next float from the input stream and store it in f, compensating for any difference in endian format between the stream and the current environment. virtual RWvistream& operator>>(int& i); Redefined from class RWbistream.
Return the size of longs, as represented in the stream. size_t streamSizeofShort(); Return the size of shorts, as represented in the stream. size_t streamSizeofSizeT(); Return the size of size_ts, as represented in the stream. size_t streamSizeofWchar(); Returns the size of wchar_ts, as represented in the stream.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWeostream ... ios ... RWbostream RWeostream ... ● Synopsis ● Description ● Persistence ● Example ● Enumeration ● Public Constructors ● Public Destructor ● Public Member Functions RWvostream RWvios Synopsis #include
Example See RWeistream for an example of how the file "data.dat" might be read. Enumeration enum RWeostream::Endian { LittleEndian, BigEndian, HostEndian } Used to specify the format that RWeostreams should use to represent numeric values in the stream. HostEndian means to use the native format of the current environment. Public Constructors RWeostream(streambuf* s, Endian fmt = HostEndian); Construct an RWeostream from the streambuf s.
as a character, not a number. virtual RWvostream& operator<<(wchar_t wc); Redefined from class RWbostream. Store the wchar_t wc to the output stream in binary, using the appropriate endian representation. virtual RWvostream& operator<<(unsigned char c); Redefined from class RWbostream. Store the unsigned char c to the output stream. Note that c is treated as a character, not a number. virtual RWvostream& operator<<(double d); Redefined from class RWbostream.
operator<<(unsigned short s); Redefined from class RWbostream. Store the unsigned short s to the output stream in binary, using the appropriate endian representation. virtual RWvostream& put(char c); virtual RWvostream& put(unsigned char c); virtual RWvostream& put(const char* p, size_t N); Inherited from class RWbostream. virtual RWvostream& put(wchar_t wc); Redefined from class RWbostream. Store the wchar_t wc to the output stream in binary, using the appropriate endian representation.
put(const long* p, size_t N); Redefined from class RWbostream. Store the vector of longs starting at p to the output stream in binary, using the appropriate endian representation. virtual RWvostream& put(const unsigned long* p, size_t N); Redefined from class RWbostream. Store the vector of unsigned longs starting at p to the output stream in binary, using the appropriate endian representation. virtual RWvostream& put(const float* p, size_t N); Redefined from class RWbostream.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWFactory ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Operator ● Public Member Functions Synopsis typedef unsigned short RWClassID; typedef RWCollectable* (*RWuserCreator)(); #include RWFactory* theFactory; Description Class RWFactory can create an instance of an RWCollectable object, given a class ID.
Persistence None Example #include #include #include #include main(){ // Create new RWBag off the heap, using Class ID __RWBAG. RWBag* b = (RWBag*)getRWFactory ()->create(__RWBAG); b->insert( new RWCollectableDate ); // Insert today's date // ... b->clearAndDestroy(); // Cleanup: first delete members, delete b; // then the bag itself } Public Constructors RWFactory(); Construct an RWFactory.
Public Member Functions void addFunction(RWuserCreator uc, RWClassID id); Adds to the RWFactory the global function pointed to by uc, which creates an instance of an object with RWClassID id. void addFunction(RWuserCreator uc, RWClassID id, RWStringID sid); Adds to the RWFactory the global function pointed to by uc, which creates an instance of an object with RWClassID id and RWStringID sid.
Looks up the RWStringID associated with id and returns it. If there is no such association, returns RWStringID("NoID"). RWClassID classID(RWStringID) const; Looks up the RWClassID associated with sid and returns it. If there is no such association, returns __RWUNKNOWN.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWFile ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Functions ● Static Public Member Functions Synopsis #include RWFile f("filename"); Description Class RWFile encapsulates binary file operations using the Standard C stream library (functions fopen(), fread(), fwrite(), etc.).
mode is as given by the Standard C library function fopen(). If mode is zero (the default) then the constructor will attempt to open an existing file with the given filename for update (mode "rb+"). If this is not possible, then it will attempt to create a new file with the given filename (mode "wb+"). The resultant object should be checked for validity using function isValid(). ~RWFile(); Performs any pending I/O operations and closes the file.
const char* GetName(); Returns the file name. FILE* GetStream(); Returns the FILE* that underlies the RWFile interface. Provided for users who need to "get under the hood" for system-dependent inquiries, etc. Do not use to alter the state of the file! RWBoolean IsEmpty(); Returns TRUE if the file contains no data, FALSE otherwise. RWBoolean isValid() const; Returns TRUE if the file was successfully opened, FALSE otherwise.
Read(wchar_t* i, size_t RWBoolean Read(short* i, size_t RWBoolean Read(int* i, size_t RWBoolean Read(long* i, size_t RWBoolean Read(unsigned char* i, size_t RWBoolean Read(unsigned short* i,size_t RWBoolean Read(unsigned int* i, size_t RWBoolean Read(unsigned long* i, size_t RWBoolean Read(float* i, size_t RWBoolean Read(double* i, size_t count); count); count); count); count); count); count); count); count); count); Reads count instances of the indicated built-in type into a block pointed to by i.
RWBoolean Write(char i); RWBoolean Write(wchar_t i); RWBoolean Write(short i); RWBoolean Write(int i); RWBoolean Write(long i); RWBoolean Write(unsigned char i); RWBoolean Write(unsigned short i); RWBoolean Write(unsigned int i); RWBoolean Write(unsigned long i); RWBoolean Write(float f); RWBoolean Write(double d); Writes the appropriate built-in type. Returns TRUE if the write is successful.
Write(const double* i, size_t count); Writes count instances of the indicated built-in type from a block pointed to by i. Returns TRUE if the write is successful. RWBoolean Write(const char* string); Writes a character string, including the terminating null character, from a block pointed to by string. Returns TRUE if the write is successful. Beware of non-terminated strings when using this function.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWFileManager RWFileManager RWFile ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Functions Synopsis typedef long RWoffset ; typedef unsigned long RWspace; #include RWFileManager f("file.dat"); // (typically) Description Class RWFileManager allocates and deallocates storage in a disk file, much like a "freestore" manager.
Persistence None Public Constructor RWFileManager(const char* filename, const char* mode = 0); Constructs an RWFileManager for the file with path name filename using mode mode. The mode is as given by the Standard C library function fopen(). If mode is zero (the default) then the constructor will attempt to open an existing file with the given filename for update (mode "rb+"). If this is not possible, then it will attempt to create a new file with the given filename (mode "wb+").
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGBitVec(size) ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Assignment Operators ● Indexing Operators ● Public Member Functions ● Related Global Functions Synopsis #include declare(RWGBitVec,size) RWGBitVec(size) a; Description RWGBitVec(size) is a bit vector of fixed length size.
Example In this example, a bit vector 24 bits long is declared and exercised: #include "rw/gbitvec.h" #include const int VECSIZE = 8; declare(RWGBitVec, VECSIZE) // declare a 24 bit long vector implement(RWGBitVec, VECSIZE) // implement the vector main() { RWGBitVec(VECSIZE) a, b; a(2) = TRUE; b(3) = TRUE; // Allocate two vectors. // Set bit 2 (the third bit) of a on. // Set bit 3 (the fourth bit) of b on. RWGBitVec(VECSIZE) c = a ^ b; // Set c to the XOR of a and b.
Set all elements of self to the boolean value f. RWGBitVec(sz)& operator&=(const RWGBitVec(sz)& v); RWGBitVec(sz)& operator^=(const RWGBitVec(sz)& v); RWGBitVec(sz)& operator|=(const RWGBitVec(sz)& v); Logical assignments. Set each element of self to the logical AND, XOR, or OR, respectively, of self and the corresponding bit in v. Indexing Operators RWBitRef operator[](size_t i); Returns a reference to the ith bit of self. This reference can be used as an lvalue.
RWBoolean testBit(size_t i) const; Tests the bit with index i. The index i must be between 0 and size-1. No bounds checking is performed. The following are equivalent, although testBit(size_t) is slightly smaller and faster than using operator()(size_t): if( a(i) ) doSomething(); if( a.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGDlist(type) ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Assignment Operator ● Public Member Functions Synopsis #include 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.
typedef RWBoolean (*yourTester)(const type*, const void*); has been used for this tester function. Persistence None Example #include #include declare(RWGDlist,int) /* Declare a list of ints */ main() { RWGDlist(int) list; int *ip; // Define a list of ints list.insert(new int(5)); // Insert some ints list.insert(new int(7)); list.insert(new int(1)); list.
RWGDlist(type)(type* a); Construct a collection with one entry a. RWGDlist(type)(const RWGDlist(type)& a); Copy constructor. A shallow copy of a is made. Assignment Operator void operator=(const RWGDlist(type)& a); Assignment operator. A shallow copy of a is made. Public Member Functions type* append(type* a); Adds an item to the end of the collection. Returns nil if the insertion was unsuccessful.
RWBoolean containsReference(const type* e) const; Returns TRUE if the collection contains an item with the address e. size_t entries() const; Returns the number of items in the collection. type* find(yourTester t, const void* d) const; Returns the first item in the collection for which the user-provided function pointed to by t finds a match with d, or nil if no item is found. type* findReference(const type* e) const; Returns the first item in the collection with the address e, or nil if no item is found.
Returns the number of occurrences in the collection for which the user-provided function pointed to by t finds a match with d. size_t occurrencesOfReference(const type* e) const; Returns the number of items in the collection with the address e. type* prepend(type* a); Adds an item to the beginning of the collection. Returns nil if the insertion was unsuccessful.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGDlistIterator(type) ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Member Operators ● Public Member Functions Synopsis #include declare(RWGDlist, type) RWGDlist(type) a; RWGDlistIterator(type) I(a) ; Description Iterator for class RWGDlist(type), which allows sequential access to all the elements of a doubly-linked list.
Persistence None Example See class RWGDlist(type) Public Constructor RWGDlistIterator(type)( RWGDlist(type)& list); Construct an iterator for the RWGDlist(type) list. Immediately after construction, the position of the iterator is undefined. Public Member Operators type* operator()(); Advances the iterator to the next item and returns it. Returns nil if at the end of the collection. void operator++(); Advances the iterator one item. void operator--(); Moves the iterator back one item.
atLast() const; Returns TRUE if the iterator is at the end of the list, FALSE otherwise; type* findNext(yourTester t,const type* d); Moves the iterator to the next item for which the function pointed to by t finds a match with d and returns it. Returns nil if no match is found, in which case the position of the iterator will be undefined. type* findNextReference(const type* e); Moves the iterator to the next item with the address e and returns it.
Moves the iterator to the first item in the list. void toLast(); Moves the iterator to the last item in the list.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGOrderedVector(val) ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Member Functions Synopsis #include declare(RWGVector,val) declare(RWGOrderedVector,val) implement(RWGVector,val) implement(RWGOrderedVector,val) RWGOrderedVector(val) v;// Ordered vector of objects of val val.
To use this class you must declare and implement its base class as well as the class itself. For example, here is how you declare and implement an ordered collection of doubles: declare(RWGVector,double) // Declare base class declare(RWGOrderedVector,double) // Declare ordered vector // In one and only one .
Last Public Constructors RWGOrderedVector(val)(size_t capac=RWDEFAULT_CAPACITY); Construct an ordered vector of elements of val val. The initial capacity of the vector will be capac whose default value is RWDEFAULT_CAPACITY. The capacity will be automatically increased as necessary should too many items be inserted, a relatively expensive process because each item must be copied into the new storage.
Add the new value item to the end of the collection. void insertAt(size_t indx, val item); Add the new value item to the collection at position indx. The value of indx must be between zero and the length of the collection. No bounds checking is performed. Old items from index indx upwards will be shifted to higher indices. RWBoolean isEmpty() const; Returns TRUE if the collection has no entries. FALSE otherwise. void size_t length() const; Synonym for entries().
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGQueue(type) ● Synopsis ● Description ● Persistence ● Public Constructors ● Assignment Operator ● Public Member Functions Synopsis #include declare(RWGQueue, type) RWGQueue(type) a ; Description Class RWGQueue(type) represents a group of ordered elements, not accessible by an external key.
typedef RWBoolean (*yourTester)(const type*, const void*); has been used for this tester function. Persistence None Public Constructors RWGQueue(type)(); Construct an empty queue. RWGQueue(type)(type* a); Construct a queue with one entry a. RWGQueue(type)(const RWGQueue(type)& q); Copy constructor. A shallow copy of q is made. Assignment Operator void operator=(const RWGQueue(type)& q); Assignment operator. A shallow copy of q is made.
size_t entries() const; Returns the number of items in the queue. type* first() const; Returns the first item in the queue, or nil if the queue is empty. type* get(); Returns and removes the first item in the queue. Returns nil if the queue is empty. RWBoolean isEmpty() const; Returns TRUE if the queue is empty, otherwise FALSE. type* insert(type* a); Calls append(type*) with a as the argument. type* last(); Returns the last (most recently inserted) item in the queue, or nil if the queue is empty.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGSlist(type) ● Synopsis ● Description ● Persistence ● Public Constructors ● Assignment Operator ● Public Member Functions Synopsis #include declare(RWGSlist, type) RWGSlist(type) a ; Description Class RWGSlist(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 singly-linked list.
has been used for this tester function. Persistence None Public Constructors RWGSlist(type)(); Construct an empty collection. RWGSlist(type)(type* a); Construct a collection with one entry a. RWGSlist(type)(const RWGSlist(type)& a); Copy constructor. A shallow copy of a is made. Assignment Operator void operator=(const RWGSlist(type)&); Assignment operator. A shallow copy of a is made. Public Member Functions type* append(type* a); Adds an item to the end of the collection and returns it.
Returns a pointer to the ith item in the collection. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the number of items in the collection less one, or an exception of type TOOL_INDEX will be thrown. void clear(); Removes all items in the collection. RWBoolean contains(yourTester t, const void* d) const; Returns TRUE if the collection contains an item for which the user-defined function pointed to by t finds a match with d.
moved to i+1, etc. The index indx must be between 0 and the number of items in the collection, or an exception of type TOOL_INDEX will be thrown. RWBoolean isEmpty() const; Returns TRUE if the collection is empty, otherwise FALSE. type* last() const; Returns the last item of the collection. size_t occurrencesOf(yourTester t, const void* d) const; Returns the number of occurrences in the collection for which the user-provided function pointed to by t finds a match with d.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGSlistIterator(type) ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Operators ● Public Member Functions Synopsis #include declare(RWGSlist, type) RWGSlist(type) a ; RWGSlistIterator(type) I(a); Description Iterator for class RWGSlist(type), which allows sequential access to all the elements of a singly-linked list.
Persistence None Public Constructor RWGSlistIterator(type)( RWGSlist(type)& list); Constructs an iterator for the RWGSlist(type) list. Immediately after construction, the position of the iterator is undefined. Public Member Operators type* operator()(); Advances the iterator to the next item and returns it. Returns nil if it is at the end of the collection. void operator++(); Advances the iterator one item. void operator+=(size_t n); Advances the iterator n items.
Moves the iterator to the next item with the address e and returns it. Returns nil if no match is found, in which case the position of the iterator will be undefined. type* insertAfterPoint(type* a); Adds item a after the current iterator position and return the item. The position of the iterator is left unchanged. type* key() const; Returns the item at the current iterator position. type* remove(); Removes and returns the item at the current cursor position.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGSortedVector(val) RWGSortedVector(val) ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Member Functions RWGVector(val) Synopsis #include declare(RWGSortedVector,val) implement(RWGSortedVector, val) RWGSortedVector(val) v; // A sorted vector of vals .
● well-defined less-than semantics (val::operator<(const val&) or equiv.).. To use this class you must declare and implement its base class as well as the class itself. For example, here is how you declare and implement a sorted collection of doubles: declare(RWGVector,double) // Declare base class declare(RWGSortedVector,double) // Declare sorted vector // In one and only one .
// using the comparison function 'compFun': RWGSortedVector(int) avec(compFun); // Do some insertions: avec.insert(3); avec.insert(17); avec.insert(5); // 3 // 3 17 // 3 5 17 cout << avec(1); cout << avec.index(17); // Prints '5' // Prints '2' } Public Constructors RWGSortedVector(val)( int (*f)(const val*, const val*) ); Construct a sorted vector of elements of val val, using the comparison function pointed to by f. The initial capacity of the vector will be set by the value RWDEFAULT_CAPACITY.
the value. If duplicates are present, the index of the first instance is returned. RWBoolean insert(val v); Insert the new value v into the vector. A binary search, using the comparison function, is performed to determine where to insert the value. The item will be inserted after any duplicates. If the insertion causes the vector to exceed its capacity, it will automatically be resized by an amount given by RWDEFAULT_RESIZE. void removeAt(size_t indx); Remove the item at position indx from the collection.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGStack(type) ● Synopsis ● Description ● Persistence ● Public Constructors ● Assignment Operator ● Public Member Functions Synopsis #include declare(RWGStack,type) RWGStack(type) a ; Description Class RWGStack(type) represents a group of ordered elements, not accessible by an external key.
typedef RWBoolean (*yourTester)(const type*, const void*); has been used for this tester function. Persistence None Public Constructors RWGStack(type)(); Constructs an empty stack. RWGStack(type)(type* a); Constructs a stack with one entry a. RWGStack(type)(const RWGStack(type)& a); Copy constructor. A shallow copy of a is made. Assignment Operator void operator=(const RWGStack(type)& a); Assignment operator. A shallow copy of a is made.
RWBoolean isEmpty() const; Returns TRUE if the stack is empty, otherwise FALSE. size_t occurrencesOf(yourTester t, const void* d) const; Returns the number of items in the stack for which the user-provided function pointed to by t finds a match with d. size_t occurrencesOfReference(const type* e) const; Returns the number of items in the stack with the address e. type* pop(); Removes and returns the item at the top of the stack, or returns nil if the stack is empty.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWGVector(val) ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include declare(RWGVector,val) implement(RWGVector,val) RWGVector(val) a; // A Vector of val's. Description Class RWGVector(val) represents a group of ordered elements, accessible by an index. Duplicates are allowed.
Persistence None Example #include #include #include
Copy constructor. The entire vector is copied, including all embedded values. Public Member Operators RWGVector(val)& operator=(RWGVector(val)& s); Assignment operator. The entire vector is copied. RWGVector(val)& operator=(val v); Sets all elements of self to the value v. val operator()(size_t i) const; val& operator()(size_t i); Return the i'th element in the vector. The index i must be between zero and the length of the vector less one. No bounds checking is performed.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWHashDictionary RWHashDictionary RWSet RWCollection ... ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWHashTable ... RWCollectable Synopsis typedef RWHashDictionary Dictionary; #include RWHashDictionary a ; // Smalltalk typedef.
Public Constructors RWHashDictionary(size_t n = RWDEFAULT_CAPACITY); Construct an empty hashed dictionary using n hashing buckets. RWHashDictionary(const RWHashDictionary& hd); Copy constructor. A shallow copy of the collection hd is made. Public Member Operators void operator=(const RWHashDictionary& hd); Assignment operator. A shallow copy of the collection hd is made.
RWOrdered RWBinaryTree asSortedCollection() const; Converts the RWHashDictionary to an RWBag, RWSet, RWOrdered, or an RWBinaryTree. Note that since a dictionary contains pairs of keys and values, the result of this call will be a container holding RWCollectableAssociations. Note also that the return value is a copy of the data. This can be very expensive for large collections. Consider using operator+=() to insert each RWCollectableAssociation from this dictionary into a collection of your choice.
The value is put in v. You are responsible for defining v before calling this function. RWCollectable* findValue(const RWCollectable* target) const; Returns the value associated with the key which isEqual to the item pointed to by target, or nil if no key was found. RWCollectable* findValue(const RWCollectable* target, RWCollectable* newValue); Returns the value associated with the key which isEqual to the item pointed to by target, or nil if no key was found.
removeAndDestroy(const RWCollectable* target); Redefined from class RWCollection. Removes and deletes the key and value pair where the key isEqual to the item pointed to by target. Note that both the key and the value are deleted. Does nothing if the key is not found. RWCollectable* removeKeyAndValue(const RWCollectable* target, RWCollectable*& v); Removes the key and value pair where the key isEqual to the item pointed to by target. Returns the key, or nil if no match was found.
stringID(); (acts virtual) Inherited from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWHashDictionaryIterator RWHashDictionaryIterator ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Operator ● Public Member Functions RWIterator Synopsis #include RWHashDictionary hd; RWHashDictionaryIterator iter(hd); Description Iterator for class RWHashDictionary, allowing sequential access to all the elements of RWHashDictionary.
Persistence None Public Constructor RWHashDictionaryIterator(RWHashDictionary&); Construct an iterator for an RWHashDictionary collection. Immediately after construction, the position of the iterator is undefined until positioned. Public Member Operator virtual RWCollectable* operator()(); Redefined from class RWIterator. Advances the iterator to the next key-value pair and returns the key. Returns nil if the cursor is at the end of the collection. Use member function value() to recover the value.
RWCollectable* value() const; Returns the value at the current iterator position. RWCollectable* value(RWCollectable* newValue) const; Replaces the value at the current iterator position and returns the old value.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software rw_hashmap ● Synopsis ● Description ● Persistence ● Public Typedefs ● Public Constructors ● Public Destructor ● Public Operators ● Accessors ● Const Public Member Functions ● Mutators ● Special Methods for Maps Synopsis #include
Persistence None Public Typedefs typedef typedef typedef typedef typedef typedef typedef typedef K key_type; Hash key_hash; EQ key_equal; pair value_type; // or ... "const K" (unsigned) size_type; //from rw_slist (int) difference_type; // from rw_slist (value_type&) reference; (const value_type&) const_reference; //from rw_slist Iterators over rw_hashmap are forward iterators.
Construct an rw_hashmap with sz slots, using h as the hash object, and eq as the equality comparator, containing a copy of each pair referenced by the range starting with first and bounded by bound. If there are items in the range for which the K parts of the pairs match EQ, then only the first such item will be inserted into self. Public Destructor ~rw_hashmap(); The destructor releases the memory used by the container's implementation.
reference any item that has been stored in self. iterator end(); The iterator returned marks the location "off the end" of self. It may not be dereferenced. const_iterator end() const; The iterator returned marks the location "off the end" of self. It may not be dereferenced. pair equal_range(const key_type key) const; Returns pair(lower_bound(key), upper_bound(key)). Upper and lower bound have special meaning for hash-based collections.
Returns the number of slots in the hash table that self uses. bool empty() const; Returns true if self is empty. float fill_ratio() const; Returns the result of calculating size()/capacity(). size_type size() const; Returns the number of pairs currently held in self. Mutators void clear(); A synonym for erase(begin(),end()); size_type erase(const key_type& key); If there is a pair in self for which the first part is EQ to key, that pair is removed, and 1 is returned. Otherwise, 0 is returned.
returning 1. Otherwise, does nothing and returns 0. Note that the first argument is provided only for conformance with the ANSI associative container specification, and is ignored by the method, since hash table look up can be done in constant time.
contained in self, else returns end(). void resize(size_type sz); Resizes self's hash table to have sz slots; and re-hashes all self's elements into the new table. Can be very expensive if self holds many elements.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software rw_hashmultimap ● Synopsis ● Description ● Persistence ● Public Typedefs ● Public Constructors ● Public Destructor ● Public Operators ● Accessors ● Const Public Member Functions ● Mutators ● Special Methods for Multimaps Synopsis #include
Persistence None Public Typedefs typedef typedef typedef typedef typedef typedef typedef typedef K Hash EQ pair (unsigned) (int) (value_type&) (const value_type&) key_type; key_hash; key_equal; value_type; // or ... "const K" size_type; //from rw_slist difference_type; // from rw_slist reference; const_reference; //from rw_slist Iterators over rw_hashmultimap are forward iterators.
const EQ& eq = EQ()); Construct an rw_hashmultimap with sz slots, using h as the hash object, and eq as the equality comparator, containing a copy of each pair referenced by the range starting with first and bounded by bound. Public Destructor ~rw_hashmultimap(); The destructor releases the memory used by the container's implementation.
const_iterator end() const; The iterator returned marks the location "off the end" of self. It may not be dereferenced. pair equal_range(const key_type key) const; Returns pair(lower_bound(key), upper_bound(key)). Upper and lower bound have special meaning for hash-based collections. See discussion elsewhere. pair equal_range(const key_type key); Returns pair(lower_bound(key), upper_bound(key)).
float fill_ratio() const; Returns the result of calculating size()/capacity(). size_type size() const; Returns the number of items currently held in self. Mutators void clear(); A synonym for erase(begin(),end()); size_type erase(const key_type& key); Removes all pairs in self for which the first part is EQ to key, and returns the number of removed elements. iterator erase(iterator iter); Removes the element referenced by iter and returns an iterator referencing the "next" element.
copied into self. Returns the number of elements inserted. size_type insert(const_iterator first, const_iterator bound); For each element in the range beginning with first and bounded by bound, the element is copied into self. Returns the number of elements inserted. void swap(rw_hashmultimap& other); Exchanges the contents of self with other including the Hash and EQ objects. This method does not copy or destroy any of the items exchanged but exchanges the underlying hash tables.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software rw_hashmultiset ● Synopsis ● Description ● Persistence ● Public Typedefs ● Public Constructors ● Public Destructor ● Public Operators ● Accessors ● Const Public Member Functions ● Mutators ● Special Methods for Multisets Synopsis #include
Persistence None Public Typedefs typedef typedef typedef typedef typedef typedef typedef typedef T T Hash EQ (unsigned) (int) (value_type&) (const value_type&) key_type; value_type; // or ... "const K" key_hash; key_equal; size_type; //from rw_slist difference_type; // from rw_slist reference; const_reference; //from rw_slist Iterators over rw_hashmultiset are forward iterators.
const EQ& eq = EQ()); Construct an rw_hashmultiset with sz slots, using h as the hash object, and eq as the equals object, containing a copy of each item referenced by the range including first and bounded by bound. Public Destructor ~rw_hashmultiset(); The destructor releases the memory used by the container's implementation.
pair equal_range(const key_type key) const; Returns pair(lower_bound(key), upper_bound(key)). Upper and lower bound have special meaning for hash-based collections. See discussion elsewhere. pair equal_range(const key_type key); Returns pair(lower_bound(key), upper_bound(key)). Upper and lower bound have special meaning for hash-based collections. See discussion elsewhere.
size_type size() const; Returns the number of items currently held in self. Mutators void clear(); A synonym for erase(begin(),end()); size_type erase(const key_type& key); Removes all items in self which are EQ to key, and returns the number of removed elements. iterator erase(iterator iter); Removes the element referenced by iter and returns an iterator referencing the "next" element. If iter does not reference an item in self, the result is undefined.
copied into self. Returns the number of elements inserted. void swap(rw_hashmultiset& other); Exchanges the contents of self with other including the Hash and EQ objects. This method does not copy or destroy any of the items exchanged but exchanges the underlying hash tables. Special Methods for Multisets size_type count(const key_type& key) const; Returns the number of items in self which are EQ to key.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software rw_hashset ● Synopsis ● Description ● Persistence ● Public Typedefs ● Public Constructors ● Public Destructor ● Public Operators ● Accessors ● Const Public Member Functions ● Mutators ● Special Methods for Sets Synopsis #include
Persistence None Public Typedefs typedef typedef typedef typedef typedef typedef typedef typedef T T Hash EQ (unsigned) (int) (value_type&) (const value_type&) key_type; value_type; // or ... "const K" key_hash; key_equal; size_type; //from rw_slist difference_type; // from rw_slist reference; const_reference; //from rw_slist Iterators over rw_hashset are forward iterators.
Construct an rw_hashset with sz slots, using h as the hash object, and eq as the equality comparator, containing a copy of each item referenced by the range starting with first and bounded by bound. If there are items in the range which test EQ, then only the first such item will be inserted into self. Public Destructor ~rw_hashset(); The destructor releases the memory used by the container's implementation.
pair equal_range(const key_type key) const; Returns pair(lower_bound(key), upper_bound(key)). Upper and lower bound have special meaning for hash-based collections. See discussion elsewhere. pair equal_range(const key_type key); Returns pair(lower_bound(key), upper_bound(key)). Upper and lower bound have special meaning for hash-based collections. See discussion elsewhere.
size_type size() const; Returns the number of items currently held in self. Mutators void clear(); A synonym for erase(begin(),end()); size_type erase(const key_type& key); If there is an item EQ to key, it is removed, and 1 is returned. Otherwise, 0 is returned. iterator erase(iterator iter); Removes the element referenced by iter and returns an iterator referencing the "next" element. If iter does not reference an item in self, the result is undefined.
insert(const_iterator first, const_iterator bound); For each element in the range beginning with first and bounded by bound, if there is no item in self EQ to that element, the element is copied into self, or if there is such an element, it is skipped. Returns the number of elements inserted. void swap(rw_hashset& other); Exchanges the contents of self with other including the Hash and EQ objects.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWHashTable RWHashTable ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Member Functions RWCollection RWCollectable Synopsis #include RWHashTable h ; Description This class is a simple hash table for objects inheriting from RWCollectable. It uses chaining (as implemented by class RWSlistCollectables) to resolve hash collisions.
sag because each bucket must be searched linearly. The number of buckets can be changed by calling member function resize(). This will require that all objects be rehashed. The iterator for this class is RWHashTableIterator. Persistence None Example #include #include #include
Program output: Table contains 4 entries. It does contain the key February 22, 1983 Public Constructors RWHashTable(size_t N = RWCollection::DEFAULT_CAPACITY); Construct an empty hash table with N buckets. RWHashTable(const RWHashTable& t); Copy constructor. Create a new hash table as a shallow copy of the table t. The new table will have the same number of buckets as the old table. Hence, the members need not be and will not be rehashed.
Member Functions virtual void apply(RWapplyCollectable ap, void*); Redefined from RWCollection. The function pointed to by ap will be called for each member in the collection. Because of the nature of hashing collections, this will not be done in any particular order. The function should not do anything that could change the hash value or equality properties of the objects. virtual RWspace binaryStoreSize() const; Inherited from RWCollection. virtual void clear(); Redefined from RWCollection.
virtual RWClassID isA() const; Redefined from RWCollection to return __RWHASHTABLE. virtual RWBoolean isEmpty() const; Redefined from RWCollection. virtual RWBoolean isEqual(const RWCollectable*) const; Redefined from RWCollection. virtual RWCollectable* newSpecies() const; Redefined from RWCollection. virtual size_t occurrencesOf(const RWCollectable*) const; Redefined from RWCollection. virtual RWCollectable* remove(const RWCollectable*); Redefined from RWCollection.
(acts virtual) Inherited from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWHashTableIterator RWHashTableIterator ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Operator ● Public Member Functions RWIterator Synopsis #include RWHashTable h; RWHashTableIterator it(h); Description Iterator for class RWHashTable, which allows sequential access to all the elements of RWHashTable.
Public Constructor RWHashTableIterator(RWHashTable&); Construct an iterator for an RWHashTable. After construction, the position of the iterator is undefined. Public Member Operator virtual RWCollectable* operator()(); Redefined from class RWIterator. Advances the iterator to the next item and returns it. Returns nil when the end of the collection is reached. Public Member Functions virtual RWCollectable* findNext(const RWCollectable* target); Redefined from class RWIterator.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWIdentityDictionary RWIdentityDictionary RWHashDictionary RWCollection RWCollectable ... ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Operator ● Public Member Functions RWSet RWHashTable ... Synopsis #include
operator is not explicitly present unless you are compiling with an implementation of the Standard C++ Library. It is normally inherited from RWHashDictionary. Note: If you inherit from RWIdentityDictionary in the presence of the Standard C++ Library, we recommend that you override this operator and explicitly forward the call. Overload resolution in C++ will choose the Standard Library provided global operators over inherited class members.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWIdentitySet RWIdentitySet ... RWSet RWCollectable ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Functions RWHashTable RWCollection ... Synopsis #include
Public Member Functions The user interface to this class is identical to class RWSet and is not reproduced here. The only difference between the classes is that keys are found on the basis of identity rather than equality, and that the virtual function isA() returns __RWIDENTITYSET, the ClassId for RWIdentitySet.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWInteger ● Synopsis ● Description ● Persistence ● Public Constructors ● Type Conversion ● Public Member Functions ● Related Global Operators Synopsis #include RWInteger i; Description Integer class. This class is useful as a base class for classes that use integers as keys in dictionaries, etc.
Type Conversion operator int(); Type conversion to int. Public Member Functions RWspace binaryStoreSize() const; Returns the number of bytes necessary to store the object using the global function: RWFile& operator<<(RWFile&, const RWInteger&); int value() const; Returns the value of the RWInteger. int value(int newval); Changes the value of the RWInteger to newval and returns the old value. Related Global Operators ostream& operator<<(ostream& o, const RWInteger& x); Output x to ostream o.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWIterator ● Synopsis ● Description ● Persistence ● Public Virtual Functions Synopsis #include typedef RWIterator Iterator; // "Smalltalk" typedef Description Class RWIterator is an abstract base class for iterators used by the Smalltalk-like collection classes. The class contains virtual functions for positioning and resetting the iterator.
virtual RWCollectable* key() const = 0; Returns the item at the current iterator position. virtual RWCollectable* operator()() = 0; Advances the iterator and returns the next item, or nil if the end of the collection has been reached. virtual void reset() = 0; Resets the iterator to the state it had immediately after construction.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWLocale ● Synopsis ● Description ● Persistence ● Enumeration ● Public Member Functions ● Static Public Member Functions Synopsis #include #include (Abstract base class) Description RWLocale is an abstract base class. It defines an interface for formatting dates (including day and month names), times, numbers (including digit grouping), and currency, to and from strings.
Two implementations of RWLocale are provided with the library: ● Class RWLocaleSnapshot encapsulates the Standard C library locale facility, with two additional advantages: more than one locale can be active at the same time; and it supports conversions from strings to other types. ● There is also an internal class that mimics RWLocaleSnapshot("C").
consistently. See for a summary of strftime() formatting characters. RWCString asString(const struct tm* tmbuf,const char* format, const RWZone& zone) const; Converts components of the struct tm object to a string, according to the format string. Each format character in the format string must be preceded by %. Any characters not preceded by % are treated as ordinary characters which are returned unchanged. You may represent the special character % with "%%".
(optional) sign, and at the end. Digit group separators are allowed. Returns TRUE for a valid integer, FALSE for an error. If it returns FALSE, the long* argument is untouched. All valid numeric strings are accepted; all others are rejected. The following are examples of valid integral strings in an English-speaking locale: "1" " -02. " "+ 1,234" "1234545" "1,234,567" Table 1. Formatting characters used by strftime(). Examples are given (in parenthesis).
y Year of the century, from 00 (deprecated) 84 Y Year 1984 Z Time zone name [from tm::tm_isdst] PST or PDT virtual RWBoolean stringToDate(const RWCString&, struct tm*) const = 0; Interprets the RWCString as a date, and extracts the month, day, and year components to the tm argument. It returns TRUE for a valid date, FALSE otherwise. If it returns FALSE, the struct tm argument is untouched; otherwise it sets the tm_mday, tm_mon, and tm_year members.
RWDate or RWTime). The pointer may be retrieved from the stream with the static member RWLocale::of(). In this way a locale may be passed transparently through many levels of control to be available where needed, without intruding elsewhere. virtual int weekdayIndex(const RWCString&) const = 0; Interprets its argument as a full or abbreviated weekday name, returning values 1 through 7 to represent (respectively) Monday through Sunday, or 0 for an error.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWLocaleSnapshot RWLocaleSnapshot ● Synopsis ● Description ● Persistence ● Example ● Enumerations ● Public Constructor ● Public Member Functions ● Public Data Members RWLocale Synopsis #include #include
information. Class RWLocaleSnapshot has a set of public data members initialized by its constructor with information extracted from its execution environment. Persistence None Example Try this program with the environmental variable LANG set to various locales: #include #include #include main(){ RWLocaleSnapshot *userLocale = new RWLocaleSnapshot(""); RWLocale::global(userLocale); // Print a number using the global locale: cout << RWLocale::global().
localeName is 0, it simply uses the current locale. The most useful locale name is the empty string, "", which is a synonym for the user's chosen locale (usually specified by the environment variable LANG).
RWCString RWCString RWCString RWCString char char char char char char char char mon_thousands_sep_; mon_grouping_; positive_sign_; negative_sign_; int_frac_digits_; frac_digits_; p_cs_precedes_; p_sep_by_space_; n_cs_precedes_; n_sep_by_space_; p_sign_posn_; n_sign_posn_; These are defined identically as the correspondingly-named members of the standard C library type lconv, from .
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWModel ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Member Functions Synopsis #include (abstract base class) Description This abstract base class has been designed to implement the "Model" leg of a Model-View-Controller architecture. A companion class, RWModelClient, supplies the "View" leg. It maintains a list of dependent RWModelClient objects.
"Thermostat" and the "Dial": when the setting of the thermostat is changed, the dial must be notified so that it can update itself to reflect the new setting of the thermostat. #include
second argument.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWModelClient ● Synopsis ● Description ● Persistence ● Public Member Function Synopsis #include (abstract base class) Description This abstract base class has been designed to implement the "View" leg of a Model-View-Controller architecture. Class RWModel, supplies the "Model" leg. See class RWModel for details.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWOrdered RWOrdered RWSequenceable ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWCollection RWCollectable Synopsis #include RWOrdered a; Description Class RWOrdered represents a group of ordered items, accessible by an index number, but not accessible by an external key. Duplicates are allowed.
Public Member Operators RWBoolean operator==(const RWOrdered& od) const; Returns TRUE if for every item in self, the corresponding item in od at the same index isEqual. The two collections must also have the same number of members. RWCollectable*& operator[](size_t i); Returns the ith element in the collection. If i is out of range, an exception of type RWBoundsErr will occur. The results of this function can be used as an lvalue.
compareTo(const RWCollectable* a) const; Inherited from class RWCollectable. virtual RWBoolean contains(const RWCollectable* target) const; Inherited from class RWCollection. virtual size_t entries() const; Redefined from class RWCollection. virtual RWCollectable* find(const RWCollectable* target) const; Redefined from class RWCollection. Returns the first item that isEqual to the item pointed to by target, or nil if no item was found..
virtual RWCollectable* last() const; Redefined from class RWSequenceable. Returns the last item in the collection. virtual size_t occurrencesOf(const RWCollectable* target) const; Redefined from class RWCollection. Returns the number of items that compare isEqual to the item pointed to by target. RWCollectable* prepend(RWCollectable*); Redefined from class RWSequenceable. Adds the item to the beginning of the collection and returns it. Returns nil if the insertion was unsuccessful.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWOrderedIterator RWOrderedIterator ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operator ● Public Member Functions RWIterator Synopsis #include RWOrdered a ; RWOrderedIterator iter(a); Description Iterator for class RWOrdered. Traverses the collection from the first to the last item.
Public Constructors RWOrderedIterator(const RWOrdered& a); Construct an RWOrderedIterator from an RWOrdered. Immediately after construction the position of the iterator is undefined. Public Member Operator virtual RWCollectable* operator()(); Redefined from class RWIterator. Advances the iterator to the next item and returns it. Returns nil when the end of the collection is reached. Public Member Functions virtual RWCollectable* findNext(const RWCollectable*); Redefined from class RWIterator.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWpistream RWpistream RWvistream ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions RWvios Synopsis #include
Persistence None Example See RWpostream for an example of how to create an input stream for this program. #include main(){ // Construct an RWpistream to use standard input RWpistream pstr(cin); int i; float f; double d; char string[80]; pstr >> i; // Restore an int that was stored in binary pstr >> f >> d; // Restore a float & double pstr.getString(string, 80); // Restore a character string } Public Constructors RWpistream(streambuf* s); Initialize an RWpistream from the streambuf s.
store it in wc. virtual RWvistream& operator>>(double& d); Redefined from class RWvistream. Get the next double from the input stream and store it in d. virtual RWvistream& operator>>(float& f); Redefined from class RWvistream. Get the next float from the input stream and store it in f. virtual RWvistream& operator>>(int& i); Redefined from class RWvistream. Get the next int from the input stream and store it in i. virtual RWvistream& operator>>(long& l); Redefined from class RWvistream.
operator void*(); Inherited via RWvistream from RWvios. Public Member Functions virtual int get(); Redefined from class RWvistream. Get and return the next character from the input stream. Returns EOF if end of file is encountered. virtual RWvistream& get(char& c); Redefined from class RWvistream. Get the next char and store it in c. This member only preserves ASCII numerical codes, not the coresponding character symbol. virtual RWvistream& get(wchar_t& wc); Redefined from class RWvistream.
Redefined from class RWvistream. Get a vector of doubles and store them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason; get stores what has already been retrieved from the stream into v, and sets the failbit. virtual RWvistream& get(float* v, size_t N); Redefined from class RWvistream. Get a vector of floats and store them in the array beginning at v.
Redefined from class RWvistream. Get a vector of unsigned shorts and store them in the array beginning at v. If the restore operation stops prematurely, because there are no more data available on the stream, because an exception is thrown, or for some other reason; get stores what has already been retrieved from the stream into v, and sets the failbit. virtual RWvistream& get(unsigned int* v, size_t N); Redefined from class RWvistream.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWpostream RWpostream RWvostream ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Destructor ● Public Operators ● Public Member Functions RWvios Synopsis #include
The goal of class RWpostream and RWpistream is to store variables using nothing but printable ASCII characters. Hence, nonprintable characters must be converted into an external representation where they can be recognized. Furthermore, other characters may be merely bit values (a bit image, for example), having nothing to do with characters as symbols. For example, RWpostream pstrm(cout); char c = '\n'; pstr << c; pstr.put_; // Stores "newline" // Stores the number 10.
} Program output: 5 22.1 -0.05 "A string with\ttabs,\nnewlines and a \x07 bell." Public Constructors RWpostream(streambuf* s); Initialize an RWpostream from the streambuf s. RWpostream(ostream& str); Initialize an RWpostream from the streambuf associated with the output stream str. Public Destructor virtual ~RWvostream(); This virtual destructor allows specializing classes to deallocate any resources that they may have allocated.
Redefined from class RWvostream. Store the wide char wc to the output stream using a portable format. Note that wc is treated as a character, not a number. virtual RWvostream& operator<<(unsigned char c); Redefined from class RWvostream. Store the unsigned char c to the output stream using a portable format. Note that c is treated as a character, not a number. virtual RWvostream& operator<<(double d); Redefined from class RWvostream. Store the double d to the output stream using a portable format.
Redefined from class RWvostream. Store the unsigned short s to the output stream using a portable format. operator void*(); Inherited via RWvostream from RWvios. Public Member Functions int precision() const; Returns the currently set precision used for writing float and double data. At construction, the precision is set to RW_DEFAULT_PRECISION (defined in compiler.h.) int precision(int p); Changes the precision used for writing float and double data. Returns the previously set precision.
virtual RWvostream& put(const wchar_t* p, size_t N); Redefined from class RWvostream. Store the vector of wide chars starting at p to the output stream, preserving their values using a portable format. Note that the characters will be treated as literal numbers (i.e., not as a character string). virtual RWvostream& put(const unsigned char* p, size_t N); Redefined from class RWvostream. Store the vector of unsigned chars starting at p to the output stream using a portable format.
Redefined from class RWvostream. Store the vector of floats starting at p to the output stream using a portable format. virtual RWvostream& put(const double* p, size_t N); Redefined from class RWvostream. Store the vector of doubles starting at p to the output stream using a portable format. virtual RWvostream& putString(const char*s, size_t N); Store the character string, including embedded nulls, starting at s to the output string.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWSequenceable RWSequenceable ● Synopsis ● Description ● Persistence ● Public Member Functions RWCollection RWCollectable Synopsis #include typedef RWSequenceable SequenceableCollection; // Smalltalk typedef Description Class RWSequenceable is an abstract base class for collections that can be accessed by an index.
virtual const RWCollectable* at(size_t i) const; Allows access to the ith element of the collection. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the number of items in the collection less one, or an exception of type RWBoundsErr will be thrown. virtual RWCollectable* first() const = 0; Returns the first item in the collection.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWSet RWSet RWHashTable ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWCollection RWCollectable Synopsis typedef RWSet Set; // Smalltalk typedef. #include RWSet h; Description Class RWSet represents a group of unordered elements, not accessible by an external key, where duplicates are not allowed.
Persistence Polymorphic Public Constructors RWSet (size_t n = RWDEFAULT_CAPACITY); Constructs an empty set with n hashing buckets. RWSet (const RWSet & h); Copy constructor. Makes a shallow copy of the collection h. virtual ~RWSet(); Calls clear(). Public Member Operators void operator=(const RWSet& h); Assignment operator. Makes a shallow copy of the collection h.
Sets self to be the intersection of self and h. Returns self. Public Member Functions virtual void apply(RWapplyCollectable ap, void*); Redefined from class RWCollection to apply the user-supplied function pointed to by ap to each member of the collection in a (generally) unpredictable order. This supplied function must not do anything to the items that could change the ordering of the collection. virtual RWspace binaryStoreSize() const; Inherited from class RWCollection.
Adds c to the collection and returns it. If an item is already in the collection which isEqual to c, then the old item is returned and the new item is not inserted. virtual RWClassID isA() const; Redefined from class RWCollectable to return __RWSET. virtual RWBoolean isEmpty() const; Inherited from class RWCollectable. virtual RWBoolean isEqual(const RWCollectable* a) const; Redefined from class RWCollection.
virtual void saveGuts(RWFile&) const; Inherited from class RWCollection. RWStringID stringID(); (acts virtual) Inherited from class RWCollectable.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWSetIterator RWSetIterator RWHashTableIterator ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Operator ● Public Member Functions RWIterator Synopsis #include RWSet h; RWSetIterator it(h) ; Description Iterator for class RWSet, which allows sequential access to all the elements of RWSet.
Public Constructor RWSetIterator(RWSet&); Construct an iterator for an RWSet. After construction, the position of the iterator will be undefined. Public Member Operator virtual RWCollectable* operator()(); Inherited from RWHashTableIterator. Public Member Functions virtual RWCollectable* findNext(const RWCollectable* target); Inherited from RWHashTableIterator. virtual RWCollectable* key() const; Inherited from RWHashTableIterator. RWCollectable* remove(); Inherited from RWHashTableIterator.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software rw_slist ● Synopsis ● Description ● Public Typedefs ● Public Constructors ● Public Destructor ● Accessors ● Const Public Member Functions ● Mutators ● Special Methods for Lists ● Related Global Operators Synopsis #include rw_slist list; Description Class rw_slist maintains a collection of T, implemented as a singly-linked list.
typedef (scoped Iterator) typedef (scoped ConstIterator) iterator; const_iterator; Public Constructors rw_slist(); Construct an empty rw_slist. rw_slist(const rw_slist& list); Construct an rw_slist which is a copy of list. Each element from list will be copied into self. rw_slist(size_type count, const T& value); Construct an rw_slist containing exactly count copies of value.
const_iterator end() const; The iterator returned marks the location "off the end" of self. It may not be dereferenced. T& front(); References the first item in the list as an L-value. If self is empty, the behavior is undefined. const T& front(); References the first item in the list as an R-value. If self is empty, the behavior is undefined. Const Public Member Functions bool empty() const; Returns true if self is empty. size_type size() const; Returns the number of items currently held in self.
Insert a copy of each item in the range beginning at first and bounded by bound into self at a place just prior to the place referenced by loc. Returns an iterator referencing the last newly inserted element. (Note: ++(list.insert(loc,first,bound))==loc; ) iterator insert(iterator loc, const T* first, const T* bound); Insert a copy of each item in the range beginning at first and bounded by bound into self at a place just prior to the place referenced by loc.
Special Methods for Lists void merge(rw_slist& donor); Assuming both donor and self are sorted, moves every item from donor into self, leaving donor empty, and self sorted. If either list is unsorted, the move will take place, but the result may not be sorted. This method does not copy or destroy the items in donor, but re-links list nodes into self. void splice(iterator to, rw_slist& donor); Insert the entire contents of donor into self, just before the position referenced by to, leaving donor empty.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWSlistCollectables RWSlistCollectables ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWSequenceable RWCollection RWCollectable Synopsis // Smalltalk typedef: typedef RWSlistCollectables LinkedList ; #include
Public Member Operators RWBoolean operator==(const RWSlistCollectables& s) const; Returns TRUE if self and s have the same number of members and if for every item in self, the corresponding item at the same index in s isEqual to it. Public Member Functions virtual RWCollectable* append(RWCollectable*); Redefined from RWSequenceable. Inserts the item at the end of the collection and returns it. Returns nil if the insertion was unsuccessful.
find(const RWCollectable* target) const; Redefined from class RWCollection. The first item that matches target is returned, or nil if no item was found. RWCollectable* findReference(const RWCollectable* e) const; Returns the first item that is identical to the item pointed to by e (that is, that has the address e), or nil if none is found. virtual RWCollectable* first() const; Redefined from class RWSequenceable. Returns the item at the beginning of the list.
prepend(RWCollectable*); Redefined from class RWSequenceable. Adds the item to the beginning of the collection and returns it. Returns nil if the insertion was unsuccessful. virtual RWCollectable* remove(const RWCollectable* target); Redefined from class RWCollection. Removes and returns the first item that isEqual to the item pointed to by target. Returns nil if there is no such item. virtual void removeAndDestroy(const RWCollectable* target); Inherited from class RWCollection.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWSlistCollectablesIterator RWSlistCollectablesIterator ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Member Operators ● Public Member Functions RWIterator Synopsis // Smalltalk typedef. typedef RWSlistCollectablesIterator LinkedListIterator; #include
Public Constructor RWSlistCollectablesIterator (RWSlistCollectables&); Constructs an iterator from a singly-linked list. Immediately after construction, the position of the iterator will be undefined. Public Member Operators virtual RWCollectable* operator()(); Redefined from class RWIterator. Advances the iterator to the next element and returns it. Returns nil when the end of the collection is reached. void operator++(); Advances the iterator one item.
insertAfterPoint(RWCollectable* a); Insert item a after the current cursor position and return the item. The cursor's position will be unchanged. virtual RWCollectable* key() const; Redefined from class RWIterator. Returns the item at the current iterator position. RWCollectable* remove(); Removes and returns the item at the current cursor position. Afterwards, the iterator will be positioned at the previous item in the list. This function is not very efficient in a singly-linked list.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWSlistCollectablesQueue RWSlistCollectablesQueue ... RWCollection ● Synopsis ● Description ● Persistence ● Public Constructors ● Public Member Operators ● Public Member Functions RWSlistCollectables RWCollectable RWSequenceable ... Synopsis // Smalltalk typedef: typedef RWSlistCollectablesQueue Queue ; #include
Public Member Operators void operator=(const RWSlistCollectablesQueue & q); Assignment operator. A shallow copy of the queue q is made. Public Member Functions virtual void apply(RWapplyCollectable ap, void*); Inherited from class RWSlistCollectables. virtual RWCollectable* append(RWCollectable*); Inherited from class RWSlistCollectables. Adds an element to the end of the queue. virtual RWspace binaryStoreSize() const; Inherited from class RWCollection.
virtual RWCollectable* last() const; Inherited from class RWSlistCollectables. Returns the last item in the queue (the most recently inserted item). virtual size_t occurrencesOf(const RWCollectable* target) const; size_t occurrencesOfReference(const RWCollectable* e) const; Inherited from class RWSlistCollectables. virtual RWCollectable* remove(const RWCollectable*); Redefined from class RWSlistCollectables. Calls get(). The argument is ignored.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWSlistCollectablesStack RWSlistCollectablesStack ... RWCollection ● Synopsis ● Description ● Persistence ● Public Constructors ● Assignment Operator ● Public Member Functions RWSlistCollectables RWCollectable RWSequenceable ... Synopsis // Smalltalk typedef: typedef RWSlistCollectablesStack Stack; #include
Assignment Operator void operator=(const RWSlistCollectablesStack& s); Assignment operator. A shallow copy of the stack s is made. Public Member Functions virtual void apply(RWapplyCollectable ap, void*); virtual RWspace binaryStoreSize() const; virtual void clear(); Inherited from class RWSlistCollectables. virtual void clearAndDestroy(); virtual RWBoolean contains(const RWCollectable* target) const; Inherited from class RWCollection.
RWCollectable* pop(); Removes and returns the item at the top of the stack, or returns nil if the stack is empty. void push(RWCollectable*); Adds an item to the top of the stack. RWCollectable* top() const; Returns the item at the top of the stack or nil if the stack is empty.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWSortedVector RWSortedVector ...RWCollection ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Member Operators ● Public Member Functions RWOrdered RWSequenceable RWCollectable ... Synopsis #include
Persistence Polymorphic Example sortvec.cpp #include #include #include main(){ RWSortedVector sv; sv.insert(new RWCollectableString("dog")); sv.insert(new RWCollectableString("cat")); sv.insert(new RWCollectableString("fish")); RWSortedVectorIterator next(sv); RWCollectableString* item; while( item = (RWCollectableString*)next() ) cout << *item << endl; sv.
Returns the ith element in the collection. If i is out of range, an exception of type RWBoundsErr will be thrown. The return value cannot be used as an lvalue. const RWCollectable* operator()(size_t i); Returns the ith element in the collection. Bounds checking is enabled by defining the preprocessor directive RWBOUNDS_CHECK before including the header file "rwsortvec.h". In this case, if i is out of range, an exception of type RWBoundsErr will be thrown. The return value cannot be used as an lvalue.
Inherited from class RWOrdered. Note that RWOrdered::find() uses the virtual function index() to perform its search. Hence, a binary search will be used. virtual RWCollectable* first() const; Inherited from class RWOrdered. virtual unsigned hash() const; Inherited from class RWCollectable. virtual size_t index(const RWCollectable*) const; Redefined from class RWOrdered.
Inherited from class RWOrdered. Note that RWOrdered::remove() uses the virtual function index() to perform its search. Hence, a binary search will be used. virtual void removeAndDestroy(const RWCollectable* target); Inherited from class RWCollection. RWCollectable* removeAt(size_t index); Inherited from class RWOrdered. Removes the item at the position index in the collection and returns it.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTBitVec ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Assignment Operators ● Logical Operators ● Related Global Functions Synopsis #include RWTBitVec<22> // A 22 bit long vector Description RWTBitVec is a parameterized bit vector of fixed length size. Unlike class RWBitVec, its length cannot be changed at run time.
main() { RWTBitVec<24> a, b; a(2) = TRUE; b(3) = TRUE; RWTBitVec<24> c = a ^ b; } // // // // Allocate two vectors. Set bit 2 (the third bit) of a on. Set bit 3 (the fourth bit) of b on. Set c to the XOR of a and b. Public Constructor RWTBitVec(); Constructs an instance with all bits set to FALSE. RWTBitVec(RWBoolean val); Constructs an instance with all bits set to val. Assignment Operators RWTBitVec& operator=(const RWTBitVec& v); Sets self to a copy of v.
Logical Operators RWBoolean operator==(RWBoolean b) const; Returns TRUE if every bit of self is set to the value b. Otherwise, returns FALSE. RWBoolean operator!=(RWBoolean b) const; Returns TRUE if any bit of self is not set to the value b. Otherwise, returns FALSE. RWBoolean operator==(const RWTBitVec& v) const; Returns TRUE if each bit of self is set to the same value as the corresponding bit in v. Otherwise, returns FALSE.
bounds checking is performed. The following two lines are equivalent, although setBit(size_t) is slightly smaller and faster than using operator()(size_t) a(i) = TRUE; a.setBit(i); RWBoolean testBit(size_t i) const; Tests the bit with index i. The index i must be between 0 and size-1. No bounds checking is performed. The following are equivalent, although testBit(size_t) is slightly smaller and faster than using operator()(size_t): if( a(i) ) doSomething(); if( a.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTime ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Member Functions ● Related Global Operators Synopsis #include RWTime a; // Construct with current time Description Class RWTime represents a time, stored as the number of seconds since 00:00:00 January 1, 1901 UTC.
RWTValOrderedVector v(5000, RWTime()); Thanks to the smart allocation scheme of the standard collections, the above declaration will result in only one call to the default constructor followed by 5000 invocations of the copy constructor. In the case of RWTime, the copy constructor amounts to an assignment of one long to another, resulting in faster creation than the simple array.
RWTime(unsigned hour, unsigned minute, unsigned second=0, const RWZone& zone = RWZone::local()); Constructs a time with today's date, and the specified hour, minute, and second, relative to the time zone zone, which defaults to local time. RWTime(const RWDate& date, unsigned hour = 0, unsigned minute = 0,unsigned second = 0, const RWZone& = RWZone::local()); Constructs a time for a given date, hour, minute, and second, relative to the time zone zone, which defaults to local time.
Postfix increment operator. Add one second to self, returning the initial value. RWTime operator--(int); Postfix decrement operator. Subtract one second from self, returning the initial value. RWTime& operator+=(unsigned long s); Add s seconds to self, returning self. RWTime& operator-=(unsigned long s); Subtract s seconds from self, returning self.
by t and returns: 0 if self == *t; 1 if self > *t; -1 if self < *t; void extract(struct tm*,const RWZone& = RWZone::local()) const; Fills all members of the struct tm argument, adjusted to the time zone specified by the RWZone argument. If the time is invalid, the struct tm members are all set to -1. Note that the encoding of struct tm members is different from that used in RWTime and RWDate functions. unsigned hash() const; Returns a suitable hashing value.
minuteGMT() const; Returns the minute in UTC (GMT). unsigned second() const; Returns the second; local time or UTC (GMT). unsigned long seconds() const; Returns the number of seconds since 00:00:00 January 1, 1901 UTC. Static Public Member Functions static RWTime beginDST(unsigned year, const RWZone& zone = RWZone::local()); Return the start of Daylight-Saving Time (DST) for the given year, in the given time zone. Returns an "invalid time" if DST is not observed in that year and zone.
RWBoolean operator<(const RWTime& t1, const RWTime& t2); Returns TRUE if t1 is less than t2. RWBoolean operator<=(const RWTime& t1, const RWTime& t2); Returns TRUE if t1 is less than or equal to t2. RWBoolean operator>(const RWTime& t1, const RWTime& t2); Returns TRUE if t1 is greater than t2. RWBoolean operator>=(const RWTime& t1, const RWTime& t2); Returns TRUE if t1 is greater than or equal to t2. RWBoolean operator==(const RWTime& t1, const RWTime& t2); Returns TRUE if t1 is equal to t2.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTimer ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Member Functions Synopsis #include RWTimer timer; Description This class can measure elapsed CPU (user) time. The timer has two states: running and stopped. The timer measures the total amount of time spent in the "running" state since it was either constructed or reset.
Example This example prints out the amount of CPU time used while looping for 5 seconds (as measured using class RWTime). #include #include #include main() {RWTimer t; t.start(); RWTime start; start.now(); // Start the timer // Record starting time // Loop for 5 seconds: for (RWTime current; current.seconds() - start.seconds() < 5; current = RWTime::now()) {;} t.stop(); // Stop the timer cout << t.
Resets (and stops) the timer. void start(); Puts the timer in the "running" state. Time accumulates while in this state. void stop(); Puts the timer in the "stopped" state. Time will not accumulate while in this state.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTIsvDlist ● Synopsis ● Descripton ● Example ● Public Constructors ● Public Member Functions Synopsis #include RWTIsvDlist list; Descripton Class RWTIsvDlist is a class that implements intrusive doubly-linked lists. An intrusive list is one where the member of the list must inherit from a common base class, in this case RWIsvDlink.
struct Symbol : public RWIsvDlink { char name[10]; Symbol( const char* cs) { strncpy(name, cs, sizeof(name)); name[9] = '\0'; } }; void printem(Symbol* s, void*) { cout << s->name << endl; } main() { RWTIsvDlist list; list.insert( new Symbol("one") ); list.insert( new Symbol("two") ); list.prepend( new Symbol("zero") ); list.apply(printem, 0); list.
The item will be passed in as argument item. Client data may be passed through as parameter d. T* at(size_t i) const; Returns the item at index i. The index i must be between zero and the number of items in the collection less one, or an exception of type TOOL_INDEX will be thrown. void clear(); Removes all items from the list. void clearAndDestroy(); Removes and calls delete for each item in the list. Note that this assumes that each item was allocated off the heap.
first() const; Returns (but does not remove) the first item in the list, or nil if the list is empty. T* get(); Returns and removes the first item in the list, or nil if the list is empty. size_t index(RWBoolean (*testFun)(const T*, void*),void* d) const; Returns the index of the first item in the list for which the user-defined "tester" function pointed to by testFun returns TRUE. If there is no such item, then returns RW_NPOS.
For each item in the list this function will be called with the item as the first argument. Client data may be passed through as parameter d size_t occurrencesOfReference(const T* a) const; Returns the number of times which the item pointed to by a occurs in the list. Because items cannot be inserted into a list more than once, this function can only return zero or one. void prepend(T* a); Prepends the item pointed to by a to the beginning of the list.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTIsvDlistIterator ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Operators ● Public Member Functions Synopsis #include RWTIsvDlist list; RWTIsvDlistIterator iterator(list); Description Iterator for class RWTIsvDlist, allowing sequential access to all the elements of a doubly-linked parameterized intrusive list.
Public Operators T* operator++(); Advances the iterator one position, returning a pointer to the new link, or nil if the end of the list has been reached. T* operator--(); Reverses the iterator one position, returning a pointer to the new link, or nil if the beginning of the list has been reached. T* operator+=(size_t n); Advances the iterator n positions, returning a pointer to the new link, or nil if the end of the list has been reached.
key() const; Returns the link at the iterator's current position. Returns nil if the iterator is not valid. T* remove(); Removes and returns the current link from the iterator's associated collection. Returns nil if unsuccessful. Afterwards, if successful, the iterator will be positioned at the element immediately before the removed link.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTIsvSlist ● Synopsis ● Descripton ● Example ● Public Constructors ● Public Member Functions Synopsis #include RWTIsvSlist list; Descripton Class RWTIsvSlist is a class that implements intrusive singly-linked lists. An intrusive list is one where the member of the list must inherit from a common base class, in this case RWIsvSlink.
struct Symbol : public RWIsvSlink { char name[10]; Symbol( const char* cs) { strncpy(name, cs, sizeof(name)); name[9] = '\0'; } }; void printem(Symbol* s, void*) { cout << s->name << endl; } main(){ RWTIsvSlist list; list.insert( new Symbol("one") ); list.insert( new Symbol("two") ); list.prepend( new Symbol("zero") ); list.apply(printem, 0); list.
The item will be passed in as argument item. Client data may be passed through as parameter d. T* at(size_t i) const; Returns the item at index i. The index i must be between zero and the number of items in the collection less one, or an exception of type TOOL_INDEX will be thrown. void clear(); Removes all items from the list. void clearAndDestroy(); Removes and calls delete for each item in the list. Note that this assumes that each item was allocated off the heap.
Returns (but does not remove) the first item in the list, or nil if the list is empty. T* get(); Returns and removes the first item in the list, or nil if the list is empty. size_t index(RWBoolean (*testFun)(const T*, void*),void* d) const; Returns the index of the first item in the list for which the user-defined "tester" function pointed to by testFun returns TRUE. If there is no such item, then returns RW_NPOS.
size_t occurrencesOfReference(const T* a) const; Returns the number of times which the item pointed to by a occurs in the list. Because items cannot be inserted into a list more than once, this function can only return zero or one. void prepend(T* a); Prepends the item pointed to by a to the beginning of the list.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTIsvSlistIterator ● Synopsis ● Description ● Persistence ● Public Constructor ● Public Operators ● Public Member Functions Synopsis #include RWTIsvSlist list; RWTIsvSlistIterator iterator(list); Description Iterator for class RWTIsvSlist, allowing sequential access to all the elements of a singly-linked parameterized intrusive list.
Public Operators T* operator++(); Advances the iterator one position, returning a pointer to the new link, or nil if the end of the list has been reached. T* operator+=(size_t n); Advances the iterator n positions, returning a pointer to the new link, or nil if the end of the list has been reached. T* operator()(); Advances the iterator one position, returning a pointer to the new link, or nil if the end of the list has been reached.
T* removeNext(RWBoolean (*testFun)(const T*, void*),void*); Advances the iterator to the first link for which the tester function pointed to by testFun returns TRUE, removes and returns it. Returns FALSE if unsuccessful. Afterwards, if successful, the iterator will be positioned at the element immediately before the removed element. void reset(); Resets the iterator to the state it had immediately after construction. void reset(RWTIsvSlist& c); Resets the iterator to iterate over the collection c.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrDeque ● Synopsis ● Please Note ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include RWTPtrDeque deq; Please Note RWTPtrDeque requires the Standard C++ Library.
Persistence Isomorphic Example In this example, a double-ended queue of ints is exercised. // tpdeque.cpp #include #include /* * This program partitions integers into even and odd numbers */ int main(){ RWTPtrDeque numbers; int n; cout << "Input an assortment of integers (EOF to end):" << endl; while (cin >> n) { if (n % 2 == 0) numbers.pushFront(new int(n)); else numbers.pushBack(new int(n)); } while (numbers.entries()) { cout << *numbers.first() << endl; delete numbers.
Related Classes Classes RWTPtrDlist, RWTPtrSlist, and RWTPtrOrderedVector also provide a Rogue Wave pointer-based interface to C++-standard sequence collections. Class deque is the C++-standard collection that serves as the underlying implementation for this class.
Clears all elements of self and replaces them by copying all elements of stddeq. bool operator<(const RWTPtrDeque& deq); Returns true if self compares lexicographically less than deq, otherwise returns false. Items in each collection are dereferenced before being compared. Assumes that type T has well-defined less-than semantics. bool operator==(const RWTPtrDeque& deq); Returns true if self compares equal to deq, otherwise returns false.
function must have one of the prototypes: void yourfun(T* a, void* d); void yourfun(const T* a, void* d); void yourfun(T*& a, void* d); for reference semantics. Client data may be passed through parameter d. reference at(size_type i); const_reference at(size_type i) const; Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type RWBoundsErr.
Client data may be passed through parameter d. iterator end(); const_iterator end() const; Returns an iterator positioned "just past" the last element in self. size_type entries() const; Returns the number of items in self. T* find(const T* a) const; If there exists an element t in self such that the expression (*t == *a) is true, returns t. Otherwise, returns rwnil.
Returns the position of the first item t in self such that((*fn)(t,d)) is true, or returns the static member npos if no such item exists. fn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); Client data may be passed through parameter d. bool insert(T* a); Adds the item a to the end of the collection. Returns true.
Returns the number of elements t in self such that the expression((*fn)(t,d)) is true. fn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); Client data may be passed through parameter d. T* popBack(); Removes and returns the last item in the collection. T* popFront(); Removes and returns the first item in the collection. void prepend(T* a); Adds the item a to the beginning of the collection.
Removes all elements t in self such that the expression (*t == *a) is true. Returns the number of items removed. size_type removeAll(bool (*fn)(T*,void*), void* d); size_type removeAll(bool (*fn)(const T*,void*), void* d); Removes all elements t in self such that the expression ((*fn)(t,d))is true. Returns the number of items removed.
Client data may be passed through parameter d. void sort(); Sorts the collection using the less-than operator to compare elements. Elements are dereferenced before being compared. deque& std(); const deque& std() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self. Static Public Data Member size_type npos; This is the value returned by member functions such as index to indicate a non-position.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrDlist ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include RWTPtrDlist dlist; Please Note! If you have the Standard C++ Library, use the interface described here.
Persistence Isomorphic Example In this example, a pointer-based doubly-linked list of user type Dog is exercised. // // tpdlist.cpp // #include #include #include class Dog { char* name; public: Dog( const char* c) { name = new char[strlen(c)+1]; strcpy(name, c); } ~Dog() { delete name; } // Define a copy constructor: Dog(const Dog& dog) { name = new char[strlen(dog.name)+1]; strcpy(name, dog.
friend ostream& operator<<(ostream& str, const Dog& dog){ str << dog.name; return str;} }; main(){ RWTPtrDlist terriers; terriers.insert(new Dog("Cairn Terrier")); terriers.insert(new Dog("Irish Terrier")); terriers.insert(new Dog("Schnauzer")); Dog key1("Schnauzer"); cout << "The list " << (terriers.contains(&key1) ? "does " : "does not ") << "contain a Schnauzer\n"; Dog key2("Irish Terrier"); terriers.insertAt( terriers.index(&key2), new Dog("Fox Terrier") ); Dog* d; while (!terriers.
Class list is the C++-standard collection that serves as the underlying implementation for this class.
in each collection are dereferenced before being compared. Assumes that type T has well-defined less-than semantics. bool operator==(const RWTPtrDlist& lst); Returns true if self compares equal to lst, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. Elements are dereferenced before being compared.
Client data may be passed through parameter d. const const_reference at (size_type i); reference at(size_type i); Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type RWBoundsErr. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first element of self. void clear(); Clears the collection by removing all items from self.
const_iterator end() const; Returns an iterator positioned "just past" the last element in self. size_type entries() const; Returns the number of items in self. T* find(const T* a) const; If there exists an element t in self such that the expression (*t == *a) is true, returns t. Otherwise, returns rwnil. T* find(bool (*fn)(T*,void*), void* d) const; T* find(bool (*fn)(const T*,void*), void* d) const; If there exists an element t in self such that the expression ((*fn)(t,d)) is true, returns t.
static member npos if no such item exists. fn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); for the const version. Client data may be passed through parameter d. bool insert(T* a); Adds the item a to the end of the collection. Returns true. void insertAt(size_type i, T* a); Inserts the item a in front of the item at position i in self.
Returns the number of elements t in self such that the expression((*fn)(t,d)) is true. fn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); for the const version. Client data may be passed through parameter d. void prepend(T* a); Adds the item a to the beginning of the collection. T* remove(const T* a); Removes and returns the first element t in self such that the expression (*t == *a) is true.
removeAt(size_type i); Removes and returns the item at position i in self. self position must be between zero and one less then the number of entries in the collection, otherwise the function throws an exception of type RWBoundsErr. T* removeFirst(); Removes and returns the first item in the collection. T* removeLast(); Removes and returns the first item in the collection.
Static Public Data Member const size_type npos; This is the value returned by member functions such as index to indicate a non-position. The value is equal to ~(size_type)0. Related Global Operators RWvostream& operator<<(RWvostream& strm, const RWTPtrDlist& coll); RWFile& operator<<(RWFile& strm, const RWTPtrDlist& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrDlistIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrDlist dl; RWTPtrDlistIterator itr(dl); Please Note! If you have the Standard C++ Library, use the interface described here.
reset(). The iterator becomes valid after being advanced with either preincrement or operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. For operator--, decrementing past the first element will return a value equivalent to false. Persistence None Examples #include #include #include
Public Member Operators T* operator()(); Advances self to the next element, dereferences the resulting iterator and returns its value. If the iterator has advanced past the last item in the container, the element returned will be a nil pointer equivalent to boolean false. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created, self will reference the first element.
findNext(RWBoolean(*fn)(T*, void*), void* d); Returns the first element t encountered by iterating self forward such that the expression((*fn)(t,d)) is true. fn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter d. If no such element exists, returns a nil pointer equivalent to false. Leaves self referencing the found item, or "past the end.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashDictionary ● Synopsis ● Please Note! Synopsis #define RWTPtrHashDictionary RWTPtrHashMap Please Note! If you have the Standard C++ Library, refer to the reference for this class under its new name: RWTPtrHashMap. Although the old name (RWTPtrHashDictionary) is still supported, we recommend that you use the new name when coding your applications.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashDictionaryIterator ● Synopsis ● Please Note! Synopsis #define RWTPtrHashDictionaryIterator RWTPtrHashMapIterator Please Note! If you have the Standard C++ Library, refer to the reference for this class under its new name: RWTPtrHashMapIterator. Although the old name (RWTPtrHashDictionaryIterator) is still supported, we recommend that you use the new name when coding your applications.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashMap ● Synopsis ● Please Note! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTPtrHashMap m; Please Note! If you have the Standard C++ Library, use the interface described here.
Equivalent keys within the collection will be grouped together based on an equality object of type EQ. EQ must ensure this grouping via public member bool operator()(const K& x, const K& y) which should return true if x and y are equivalent. RWTPtrHashMap will not accept a key that compares equal to any key already in the collection. (RWTPtrHashMultiMap may contain multiple keys that compare equal to each other.) Equality is based on the comparison object and not on the == operator.
There was 1 second place winner. Related Classes Class RWTPtrHashMultiMap offers the same interface to a pointer-based collection that accepts multiple keys that compare equal to each other. Class rw_hashmap,rw_deref_compare > is the C++-standard library style collection that serves as the underlying implementation for this collection.
This Tools.h++ 6.x style constructor creates an empty hashed map which uses the hash object h and has an initial capacity of sz. RWTPtrHashMap (const value_type* first,value_type* last); Constructs a map by copying elements from the array of pairs pointed to by first, up to, but not including, the pair pointed to by last.
applyToKeyAndValue(void (*fn)(const K*, T*&,void*),void* d); void applyToKeyAndValue (void (*fn)(const K*, const T*, void*), void* d) const; This is a deprecated version of the apply member above. It behaves exactly the same as apply. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first pair in self. size_type capacity() const; Returns the number of buckets(slots) available in the underlying hash representation. See resize below.
const_iterator end() const; Returns an iterator positioned "just past" the last association in self. size_type entries() const; Returns the number of associations in self. float fillRatio() const; Returns the ratio entries()/capacity(). const K* find(const K* key) const; If there exists a key j in self that compares equal to *key, then j is returned. Otherwise, returns rwnil.
collection already holds an association with the equivalent key. bool insertKeyAndValue(K* key,T* a); This is a deprecated version of the insert member above. It behaves exactly the same as insert. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise. size_type occurrencesOf(const K* key) const; Returns the number of keys j in self that compare equal to *key.
Returns the number removed. fn points to a user-defined tester function which must have prototype: bool yourTester(value_type a, void* d); Client data may be passed through parameter d. void resize(size_type sz); Changes the capacity of self by creating a new hashed map with a capacity of sz . resize copies every element of self into the new container and finally swaps the internal representation of the new container with the internal representation of self.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashMapIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrHashMap m; RWTPtrHashMap itr(m); Please Note! If you have the Standard C++ Library, use the interface described here.
reset(). The iterator becomes valid after being advanced with either a preincrement or operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Once this state is reached, continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include struct silly_h{ unsigned long operator()(RWCString x) const { return x.
Public Constructors RWTPtrHashMapIterator(RWTPtrHashMap&h); Creates an iterator for the hashed map h. The iterator begins in an undefined state and must be advanced before the first element will be accessible. Public Member Operators K* operator()(); Advances self to the next element, dereferences the resulting iterator and returns its key. If the iterator has advanced past the last item in the container, the element returned will be a nil pointer equivalent to boolean false.
Returns the value portion of the association pointed to by self. The behavior is undefined if the map is empty.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashMultiMap ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include
bool operator()(const K& x, const K& y) which should return true if x and y are equivalent. RWTPtrHashMultiMap may contain multiple keys that compare equal to each other. (RWTPtrHashMap will not accept a key that compares equal to any key already in the collection.) Equality is based on the comparison object and not on the == operator. Persistence Isomorphic Examples // // tphmap.cpp // #include #include #include
rw_hashmultimap<,rw_deref_hash,rw_deref_compare > is the C++-standard style collection that serves as the underlying implementation for this collection.
Public Member Operators RWTPtrHashMultiMap& operator=(const container_type&jjj m); RWTPtrHashMultiMap& operator=(const RWTPtrHashMultiMap& m); Destroys all associations in self and replaces them by copying all associations from m. bool operator==(const RWTPtrHashMultiMap& m); Returns true if self compares equal to m, otherwise returns false.
resize below. void clear(); Clears the collection by removing all items from self. void clearAndDestroy(); Removes all associations from the collection and uses operator delete to destroy the objects pointed to by the keys and their associated items. Do not use self method if multiple pointers to the same keys or items are stored. bool contains(const K* key) const; Returns true if there exists a key j in self that compares equal to *key, otherwise returns false.
bool yourTester(value_type a, void* d); Client data may be passed through parameter d. T* findValue(const K* key); const T* findValue(const K* key) const; If there exists a key j in self that compares equal to *key, returns the item associated with j. Otherwise, returns rwnil. const K* findKeyAndValue(const K* key, T*& tr); const K* findKeyAndValue(const K* key, const T*& tr) const; If there exists a key j in self that compares equal to *key, assigns the item associated with j to tr, and returns j.
K* remove(bool (*fn)(value_type,void*), void* d); Removes the first association a in self such that the expression ((*fn)(a,d)) is true and returns its key. Returns rwnil if there is no such association. fn points to a user-defined tester function which must have prototype: bool yourTester(value_type a, void* d); Client data may be passed through parameter d. size_type removeAll(const K* key); Removes all associations with key j in self that compare equal to *key. Returns the number of associations removed.
operator>>(RWvistream& strm, RWTPtrHashMultiMap& coll); RWFile& operator>>(RWFile& strm, RWTPtrHashMultiMap& coll); Restores the contents of the collection coll from the input stream strm.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashMultiMapIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrHashMultiMap m; RWTPtrHashMultiMap itr(m); Standard C++ Library Dependent! RWTPtrHashMultiMapIterator requires the Standard C++ Library.
The current item referenced by this iterator is undefined after construction or after a call to reset(). The iterator becomes valid after being advanced with either a preincrement or operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include
Public Constructors RWTPtrHashMultiMapIterator (RWTPtrHashMultiMap&h); Creates an iterator for the hashed multi-map h. The iterator begins in an undefined state and must be advanced before the first element will be accessible. Public Member Operators K* operator()(); Advances self to the next element, dereferences the resulting iterator and returns its key.
Returns the value portion of the association referenced by self. Undefined if self is not valid.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashSet ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTPtrHashSet s; Please Note! If you have the Standard C++ Library, use the interface described here.
must ensure this grouping via public member bool operator()(const T& x, const T& y) which should return true if x and y are equivalent, false otherwise. RWTPtrHashSet will not accept an item that compares equal to an item already in the collection. (RWTPtrHashMultiSet may contain multiple items that compare equal to each other.) Equality is based on the equality object and not on the == operator. Persistence Isomorphic Example // // tphset2.cpp // #include
return 0; } Related Classes Class RWTPtrHashMultiSet offers the same interface to a pointer-based collection that accepts multiple items that compare equal to each other. Class rw_hashset,rw_deref_compare > is the C++-standard collection that serves as the underlying implementation for RWTPtrHashSet.
size_type sz=1024,const H& h = H(),const EQ& eq = EQ()); Constructs a set by copying elements from the array of T*s pointed to by first, up to, but not including, the element pointed to by last. The underlying hash table representation will have sz buckets, will use h for its hashing function and will use eq to determine equality between elements.
Removes all items from the collection and uses operator delete to destroy the objects pointed to by those items. Do not use self method if multiple pointers to the same object are stored. (If the equality operator is reflexive, the container cannot hold such multiple pointers.) bool contains(const T* a) const; Returns true if there exists an element t in self such that the expression(*t == *a) is true, otherwise returns false.
Client data may be passed through parameter d. bool insert(T* a); Adds the item a to the collection. Returns true if the insertion is successful, otherwise returns false. The function will return true unless the collection already holds an element with an equivalent key. void intersection(const RWTPtrHashSet& s); Destructively performs a set theoretic intersection of self and s, replacing the contents of self with the result.
Removes and returns the first element t in self such that the expression ((*fn)(t,d)) is true. Returns rwnil if there is no such element. fn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter d. size_type removeAll(const T* a); Removes all elements t in self that compare equal to *a. Returns the number of items removed.
const RWTPtrHashSet& coll); RWFile& operator<<(RWFile& strm, const RWTPtrHashSet& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved. RWvistream& operator>>(RWvistream& strm, RWTPtrHashSet& coll); RWFile& operator>>(RWFile& strm, RWTPtrHashSet& coll); Restores the contents of the collection coll from the input stream strm.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashMultiSetIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrHashMultiSet m; RWTPtrHashMultiSet itr(m); Please Note! If you have the Standard C++ Library, use the interface described here.
The current item referenced by this iterator is undefined after construction or after a call to reset() operation. The iterator becomes valid after being advanced with either a preincrement or operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include
Public Constructors RWTPtrHashMultiSetIterator (RWTPtrHashMultiSet&h); Creates an iterator for the hashed multi-set h. The iterator begins in an undefined state and must be advanced before the first element will be accessible. Public Member Operators T* operator()(); Advances self to the next element, dereferences the resulting iterator and returns its value.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashSetIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrHashSet m; RWTPtrHashSet itr(m); Please Note! If you have the Standard C++ Library, use the interface described here.
reset(). The iterator becomes valid after being advanced with either a pre-increment or an operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include struct silly_h{ unsigned long operator()(RWCString x) const { return x.
Public Constructors RWTPtrHashSetIterator(RWTPtrHashSet&h); Creates an iterator for the hashed set h. The iterator begins in an undefined state and must be advanced before the first element will be accessible. Public Member Operators T* operator()(); Advances self to the next element, dereferences the resulting iterator and returns its value. If the iterator has advanced past the last item in the container, the element returned will be a nil pointer equivalent to boolean false.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashTable ● Synopsis ● Please Note! Synopsis #define RWTPtrHashTable RWTPtrHashMultiSet Please Note! If you have the Standard C++ Library, refer to the reference for this class under its new name: RWTPtrHashMultiSet. Although the old name (RWTPtrHashTable) is still supported, we recommend that you use the new name when coding your applications.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashTableIterator ● Synopsis ● Please Note! Synopsis #define RWTPtrHashTableIterator RWTPtrHashMultiSetIterator Please Note! If you have the Standard C++ Library, refer to the reference for this class under its new name: RWTPtrHashMultiSetIterator. Although the old name (RWTPtrHashTableIterator) is still supported, we recommend that you use the new name when coding your applications.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrMap ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operations Synopsis #include RWTPtrMap m; Standard C++ Library Dependent! RWTPtrMap requires the Standard C++ Library.
which returns true if x and its partner should precede y and its partner within the collection. The structure less from the C++-standard header file is an example. Note that keys will be dereferenced before being compared. RWTPtrMap will not accept a key that compares equal to any key already in the collection. (RWTPtrMultiMap may contain multiple keys that compare equal to each other.) Equality is based on the comparison object and not on the == operator.
new RWDate(5, "Jan", 1981); // Print a birthday: RWCString key("John"); cout << *birthdays[&key] << endl; return 0; } Program Output: 04/12/75 Related Classes Class RWTPtrMultiMap offers the same interface to a pointer-based collection that accepts multiple keys that compare equal to each other. RWTPtrSet maintains a pointer-based collection of keys without the associated items.
Copy constructor. RWTPtrMap(const container_type& m); Constructs a map by copying all elements from m. RWTPtrMap (value_type* first,value_type* last, const container_comp& comp = container_comp()); Constructs a map by copying elements from the array of pairs pointed to by first, up to, but not including, the pair pointed to by last.
apply(void (*fn)(const K*,const T*,void*),void* d) const; Applies the user-defined function pointed to by fn to every association in the collection. This function must have one of the prototypes: void yourfun(const K* key, T*& a, void* d); void yourfun(const K* key, const T* a, void* d); Client data may be passed through parameter d.
Client data may be passed through parameter d. iterator end(); const_iterator end() const; Returns an iterator positioned "just past" the last association in self. size_type entries() const; Returns the number of associations in self. const K* find(const K* key) const; If there exists a key j in self that compares equal to *key, then j is returned. Otherwise, returns rwnil.
bool insertKeyAndValue(K* key, T* a); This is a deprecated version of the insert member above. It behaves exactly the same as insert. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise. size_type occurrencesOf(const K* key) const; Returns the number of keys j in self that compare equal to *key. size_type occurrencesOf (bool (*fn)(value_type,void*), void* d) const; Returns the number of associations a in self such that the expression((*fn)(a,d)) is true.
bool yourTester(value_type a, void* d); Client data may be passed through parameter d. container_type std(); const container_type std() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrMapIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPMap map; RWTPMapIterator itr(map); Standard C++ Library Dependent! RWTPtrMapIterator requires the Standard C++ Library.
For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTPtrMap > age; RWTPtrMapIterator > itr(age); age.insert(new RWCString("John") ,new int(30)); age.
nil pointer equivalent to boolean false. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created self will now reference the first element. If, before iteration, self referenced the last association in the multimap, self will now point to an undefined value and a value equivalent to false will be returned. Otherwise, a value equivalent to true is returned. Note: no post-increment operator is provided.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrMultiMap ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTPtrMultiMap m; Standard C++ Library Dependent! RWTPtrMultiMap requires the Standard C++ Library.
structure less from the C++-standard header file is an example. Note that keys will be dereferenced before being compared. RWTPtrMultiMap may contain multiple keys that compare equal to each other. (RWTPtrMap will not accept a key that compares equal to any key already in the collection.) Equality is based on the comparison object and not on the == operator. Given a comparison object comp, keys a and b are equal if !comp(a,b) && !comp(b,a). Persistence Isomorphic.
RWMMap::const_iterator iter = birthdays.std().lower_bound(&ivanstr); while (++idx <= n) cout << idx << ". " << *(*iter++).second << endl; return 0; } Program Output: There are 3 Ivans: 1. 11/02/80 2. 06/19/71 3. 07/06/50 Related Classes Class RWTPtrMap offers the same interface to a pointer-based collection that will not accept multiple keys that compare equal to each other. RWTPtrMultiSet maintains a pointer-based collection of keys without the associated values.
Constructs an empty map with comparator comp. RWTPtrMultiMap(const container_type& m); Constructs a multimap by copying all element from m. RWTPtrMultiMap(const RWTPtrMultiMap& rwm); Copy constructor. RWTPtrMultiMap(value_type* first,value_type* last, const container_comp& comp = container_comp()); Constructs a multimap by copying elements from the array of pairs pointed to by first, up to, but not including, the pair pointed to by last.
void applyToKeyAndValue(void (*fn)(const K*, T*&,void*),void* d); void applyToKeyAndValue (void (*fn)(const K*,const T*,void*),void* d) const; This is a deprecated version of the apply member above. It behaves exactly the same as apply. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first pair in self. void clear(); Clears the collection by removing all items from self.
find(const K* key) const; If there exists a key j in self that compares equal to *key, then j is returned. Otherwise, returns rwnil. value_type find(bool (*fn)(value_type,void*), void* d) const; If there exists an association a in self such that the expression ((*fn)(a,d)) is true, then returns a. Otherwise, returns pair. fn points to a user-defined tester function which must have prototype: bool yourTester(value_type a, void* d); Client data may be passed through parameter d.
Returns the number of associations a in self such that the expression((*fn)(a,d)) is true. fn points to a user-defined tester function which must have prototype: bool yourTester(value_type a, void* d); Client data may be passed through parameter d. K* remove(const K* key); Removes the first association with key j in self such that the expression (*j == *key) is true and returns j. Returns rwnil if there is no such association.
const RWTPtrMultiMap& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved. RWvistream& operator>>(RWvistream& strm, RWTPtrMultiMap& coll); RWFile& operator>>(RWFile& strm, RWTPtrMultiMap& coll); Restores the contents of the collection coll from the input stream strm.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrMultiMapIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrMultiMap map; RWTPtrMultiMapIterator itr(map); Standard C++ Library Dependent! RWTPtrMultiMapIterator requires the Standard C++ Library.
Persistence None Examples #include #include #include #include int main(){ RWTPtrMultiMap > age; RWTPtrMultiMapIterator > itr(age); age.insert(new RWCString("John"), new int(30)); age.insert(new RWCString("Steve"),new int(17)); age.insert(new RWCString("Mark"), new int(24)); age.insert(new RWCString("Steve"),new int(24)); for(;itr();) cout << *itr.key() << "\'s age is " << *itr.
Advances self to the next element. If the iterator has been reset or just created self will now reference the first element. If, before iteration, self referenced the last association in the multimap, self will now point to an undefined value and a value equivalent to false will be returned. Otherwise, a value equivalent to true is returned. Note: no post-increment operator is provided.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrMultiSet ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTPtrMultiSet s; Standard C++ Library Dependent! RWTPtrMultiSet requires the Standard C++ Library.
Persistence Isomorphic. Examples In this example, a multi-set of RWCStrings is exercised. // // tpmset.cpp // #include #include #include #include main(){ RWTPtrMultiSet > set; set.insert(new RWCString("one")); set.insert(new RWCString("two")); set.insert(new RWCString("three")); set.insert(new RWCString("one")); // OK: duplicates allowd cout << set.entries() << endl; // Prints "4" set.clearAndDestroy(); cout << set.
Public Constructors RWTPtrMultiSet(const container_comp& = container_comp()); Constructs an empty set. RWTPtrMultiSet(const RWTPtrMultiSet& rws); Copy constructor. RWTPtrMultiSet(const container_type>& ms); Constructs a multimap by copying all elements from ms.
Returns an iterator positioned at the first element of self. void clear(); Clears the collection by removing all items from self. void clearAndDestroy(); Removes all items from the collection and uses operator delete to destroy the objects pointed to by those items. Do not use this method if multiple pointers to the same object are stored. bool contains(const T* a) const; Returns true if there exists an element t in self that compares equal to *a, otherwise returns false.
bool insert(T* a); Adds the item a to the collection. Returns true. void intersection(const RWTPtrMultiSet& s); Sets self to the intersection of self and s. Elements from each set are dereferenced before being compared. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise. bool isEquivalent(const RWTPtrMultiSet& s) const; Returns true if there is set equivalence between self and s, and returns false otherwise.
Removes all elements t in self that compare equal to *a. Returns the number of items removed. size_type removeAll(bool (*fn)(const T*,void*), void* d); Removes all elements t in self such that the expression ((*fn)(t,d))is true. Returns the number of items removed. fn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter d.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrMultiSetIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrMultiSet set; RWTPtrMultiSetIterator itr(set); Standard C++ Library Dependent! RWTPtrMultiSetIterator requires the Standard C++ Library.
operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTPtrMultiSet > a; RWTPtrMultiSetIterator > itr(a); a.insert(new RWCString("John")); a.insert(new RWCString("Steve")); a.
Public Member Operators T* operator()(); Advances self to the next element, dereferences the resulting iterator and returns its value. If the iterator has advanced past the last item in the container, the element returned will be a nil pointer equivalent to boolean false. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created self will now reference the first element.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrOrderedVector ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include
Persistence Isomorphic Example In this example, a pointer-based vector of type RWDate is exercised. // // tporddat.cpp // #include #include #include main(){ RWTPtrOrderedVector week(7); RWDate begin; // Today's date for (int i=0; i<7; i++) week.
implementation for this class. Public Typedefs typedef typedef typedef typedef typedef typedef typedef typedef vector container_type::iterator container_type::const_iterator container_type::size_type container_type::difference_type T* T*& T* const& container_type; iterator; const_iterator; size_type; difference_type; value_type; reference; const_reference; Public Constructors RWTPtrOrderedVector(); Constructs an empty vector.
operator==(const RWTPtrOrderedVector& vec) const; Returns true if self compares equal to vec, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. Elements are dereferenced before being compared. reference operator()(size_type i); const_reference operator()(size_type i) const; Returns a reference to the ith element of self.
const_reference at(size_type i) const; Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type RWBoundsErr. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first element of self. void clear(); Clears the collection by removing all items from self.
const_iterator end() const; Returns an iterator positioned "just past" the last element in self. size_type entries(); Returns the number of items in self. T* find(const T* a) const; If there exists an element t in self such that the expression (*t == *a) is true, returns t. Otherwise, returns rwnil. T* find(bool (*fn)(T*,void*), void* d) const; T* find(bool (*fn)(const T*,void*), void* d) const; If there exists an element t in self such that the expression ((*fn)(t,d)) is true, returns t.
bool yourTester(const T* a, void* d); Client data may be passed through parameter d. bool insert(T* a); Adds the item a to the end of the collection. Returns true. void insertAt(size_type i, T* a); Inserts the item a in front of the item at position i in self. This position must be between zero and the number of entries in the collection, otherwise the function throws an exception of type RWBoundsErr. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise.
Returns the number of elements t in self such that the expression ((*fn)(t,d)) is true. fn points to a user-defined tester function which must have one of the prototypes: bool yourTester(T* a, void* d); bool yourTester(const T* a, void* d); Client data may be passed through parameter d. void prepend(T* a); Adds the item a to the beginning of the collection. T* remove(const T* a); Removes and returns the first element t in self such that the expression (*t == *a) is true.
removeAt(size_type i); Removes and returns the item at position i in self. This position must be between zero and one less then the number of entries in the collection, otherwise the function throws an exception of type RWBoundsErr. T* removeFirst(); Removes and returns the first item in the collection. T* removeLast(); Removes and returns the first item in the collection.
implementation for self. Static Public Data Member const size_type npos; This is the value returned by member functions such as index to indicate a non-position. The value is equal to ~(size_type)0. Related Global Operators RWvostream& operator<<(RWvostream& strm, const RWTPtrOrderedVector& coll); RWFile& operator<<(RWFile& strm, const RWTPtrOrderedVector& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrSet ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTPtrSet s; Standard C++ Library Dependent! RWTPtrSet requires the Standard C++ Library.
!comp(a,b) && !comp(b,a). Persistence Isomorphic. Examples In this example, a pointer-based set of RWCStrings is exercised. // //tpset.cpp // #include #include #include #include main(){ RWTPtrSet > set; set.insert(new set.insert(new set.insert(new set.insert(new RWCString("one")); RWCString("two")); RWCString("three")); RWCString("one")); // Rejected: duplicate entry cout << set.entries() << endl; // Prints "3" set.
typedef T*const& const_reference; Public Constructors RWTPtrSet(const container_comp& comp = container_comp()); Constructs an empty set. RWTPtrSet(const RWTPtrSet& rws); Copy constructor. RWTPtrSet(const container_type& s); Creates a pointer based set by copying all elements from s.
begin() const; Returns an iterator positioned at the first element of self. void clear(); Clears the collection by removing all items from self. void clearAndDestroy(); Removes all items from the collection and uses operator delete to destroy the objects pointed to by those items. bool contains(const T* a) const; Returns true if there exists an element t in self that compares equal with *a, otherwise returns false.
Adds the item a to the collection. Returns true if the insertion is successful, otherwise returns false. The function will return true unless the collection already holds an element with an equivalent key. void intersection(const RWTPtrSet& s); Sets self to the intersection of self and s. Elements from each set are dereferenced before being compared. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise.
Removes all elements t in self that compares equal with *a. Returns the number of items removed. size_type removeAll(bool (*fn)(const T*,void*), void* d); Removes all elements t in self such that the expression ((*fn)(t,d))is true. Returns the number of items removed. fn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter d.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrSetIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrSet set; RWTPtrSetIterator itr(set); Standard C++ Library Dependent! RWTPtrSetIterator requires the Standard C++ Library.
operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTPtrSet > a; RWTPtrSetIterator > itr(a); a.insert(new RWCString("John")); a.insert(new RWCString("Steve")); a.
Public Member Operators T* operator()(); Advances self to the next element, dereferences the resulting iterator and returns its value. If the iterator has advanced past the last item in the container, the element returned will be a nil pointer equivalent to boolean false. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created self will now reference the first element.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrSlist ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include RWTPtrSlist slist; Please Note! If you have the Standard C++ Library, use the interface described here.
Persistence Isomorphic Example // // tpsldat.cpp // #include #include #include main(){ RWTPtrSlist dates; dates.insert(new RWDate(2, "June", 52)); dates.insert(new RWDate(30, "March", 46)); dates.insert(new RWDate(1, "April", 90)); // 6/2/52 // 3/30/46 // 4/1/90 // Now look for one of the dates: RWDate * ret = dates.find(new RWDate(2,"June",52)); if (ret){ cout << "Found date " << ret << endl; } // Remove in reverse order: while (!dates.
Public Typedefs typedef typedef typedef typedef typedef typedef typedef typedef rw_slist container_type::size_type container_type::difference_type container_type::iterator container_type::const_iterator T* T*& T*const& container_type; size_type; difference_type; iterator; const_iterator; value_type; reference; const_reference; Public Constructors RWTPtrSlist(); Constructs an empty, singly-linked list. RWTPtrSlist(const RWTPtrSlist& rwlst); Copy constructor.
Returns true if self compares equal to lst, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. Elements are dereferenced before being compared. reference operator()(size_type i); const_reference operator()(size_type i) const; Returns a reference to the ith element of self.
Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type RWBoundsErr. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first element of self. void clear(); Clears the collection by removing all items from self. void clearAndDestroy(); Removes all items from the collection and uses operator delete to destroy the objects pointed to by those items.
T* find(const T* a) const; If there exists an element t in self such that the expression (*t == *a) is true, returns t. Otherwise, returns rwnil. T* find(bool (*fn)(T*,void*),void* d) const; T* find(bool (*fn)(const T*,void*),void* d) const; If there exists an element t in self such that the expression ((*fn)(t,d)) is true, returns t. Otherwise, returns rwnil.
Adds the item a to the end of the collection. Returns true. void insertAt(size_type i, T* a); Inserts the item a in front of the item at position i in self. This position must be between zero and the number of entries in the collection, otherwise the function throws an exception of type RWBoundsErr. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise. T*& last(); T*const& last() const; Returns a reference to the last item in the collection.
T* remove(const T* a); Removes and returns the first element t in self such that the expression (*t == *a) is true. Returns rwnil if there is no such element. T* remove(bool (*fn)(T*,void*), void* d); T* remove(bool (*fn)(const T*,void*), void* d); Removes and returns the first element t in self such that the expression ((*fn)(t,d)) is true. Returns rwnil if there is no such element.
Removes and returns the first item in the collection. size_type replaceAll(const T* oldVal,T* newVal); Replaces with newVal all elements t in self such that the expression (*t == *oldVal) is true. Returns the number of items replaced. size_type replaceAll(bool (*fn)(T*, void*),void* x,T* newVal); size_type replaceAll(bool (*fn)(const T*, void*),void* x,T* newVal); Replaces with newVal all elements t in self such that the expression ((*fn)(t,d))is true. Returns the number of items replaced.
been saved. RWvistream& operator>>(RWvistream& strm, RWTPtrSlist& coll); RWFile& operator>>(RWFile& strm, RWTPtrSlist& coll); Restores the contents of the collection coll from the input stream strm. RWvistream& operator>>(RWvistream& strm, RWTPtrSlist*& p); RWFile& operator>>(RWFile& strm, RWTPtrSlist*& p); Looks at the next object on the input stream strm and either creates a new collection off the heap and sets p to point to it, or sets p to point to a previously read instance.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrSlistIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrSlist dl; RWTPtrSlistIterator itr(dl); Please Note! If you have the Standard C++ Library, use the interface described here.
reset(). The iterator becomes valid after being advanced with either a preincrement or operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTPtrSlist a; RWTPtrSlistIterator itr(a); a.insert(new RWCString("John")); a.
Public Member Operators T* operator()(); Advances self to the next element, dereferences the resulting iterator and returns its value. If the iterator has advanced past the last item in the container, the element returned will be a nil pointer equivalent to boolean false. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created self will now reference the first element.
Leaves self referencing the prior item, or in reset condition. T* key(); Returns the stored value pointed to by self. Undefined if self is not referencing a value within the list. T* remove(); Returns the stored value pointed to by self. and removes it from the collection. Undefined if self is not referencing a value within the list. Leaves self referencing the prior item, or in reset condition.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrSortedDlist ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include
bool operator()(const T& x, const T& y) which returns true if x should precede y within the collection. The structure less from the C++-standard header file is an example. Note that items in the collection will be dereferenced before being compared. Persistence Isomorphic. Example In this example, a sorted doubly-linked list of RWDates is exercised. // // tpsrtdli.cpp // #include #include #include
Related Classes Class RWTPtrSortedVector is an alternative always-sorted pointer-based collection. RWTPtrDlist is an unsorted pointer-based doubly-linked list. Class list is the C++-standard collection that serves as the underlying implementation for this class.
in each collection are dereferenced before being compared. bool operator==(const RWTPtrSortedDlist& lst) const; Returns true if self compares equal to lst, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. Elements are dereferenced before being compared.
Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type RWBoundsErr. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first element of self. void clear(); Clears the collection by removing all items from self. void clearAndDestroy(); Removes all items from the collection and uses operator delete to destroy the objects pointed to by those items.
If there exists an element t in self such that the expression (*t == *a) is true, returns t. Otherwise, returns rwnil. const T* find(bool (*fn)(const T*,void*), void* d) const; If there exists an element t in self such that the expression ((*fn)(t,d)) is true, returns t. Otherwise, returns rwnil. fn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter d.
Returns true if the collection is sorted relative to the supplied comparator object, false otherwise. T*& last(); T* const& last() const; Returns a reference to the last item in the collection. size_type merge(const RWTPtrSortedDlist& dl); Inserts all elements of dl into self, preserving sorted order. Returns the number of items inserted. size_type occurrencesOf(const T* a) const; Returns the number of elements t in self such that the expression (*t == *a) is true.
Removes all elements t in self such that the expression ((*fn)(t,d))is true. Returns the number of items removed. fn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter d. T* removeAt(size_type i); Removes and returns the item at position i in self. This position must be between zero and one less then the number of entries in the collection, otherwise the function throws an exception of type RWBoundsErr.
operator>>(RWFile& strm, RWTPtrSortedDlist& coll); Restores the contents of the collection coll from the input stream strm. RWvistream& operator>>(RWvistream& strm, RWTPtrSortedDlist*& p); RWFile& operator>>(RWFile& strm, RWTPtrSortedDlist*& p); Looks at the next object on the input stream strm and either creates a new collection off the heap and sets p to point to it, or sets p to point to a previously read instance.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrSortedDlistIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTPtrSortedDlist dl; RWTPtrSortedDlistIterator itr(dl); Standard C++ Library Dependent! RWTPtrSortedDlistIterator requires the Standard C++ Library.
operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTPtrSortedDlist > a; RWTPtrSortedDlistIterator > itr(a); a.insert(new RWCString("John")); a.insert(new RWCString("Steve")); a.
Public Member Operators T* operator()(); Advances self to the next element, dereferences the resulting iterator and returns its value. If the iterator has advanced past the last item in the container, the element returned will be a nil pointer equivalent to boolean false. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created self will now reference the first element.
findNext(RWBoolean(*fn)(T*, void*), void* d); Returns the first element t encountered by iterating self forward such that the expression((*fn)(t,d)) is true. fn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter d. Otherwise returns nil. Leaves self referencing found item or "off the end." T* key(); Returns the stored value pointed to by self. Undefined if self is not referencing a value within the list.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrSortedVector ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include
via a public member bool operator()(const T& x, const T& y) which returns true if x should precede y within the collection. The structure less from the C++-standard header file is an example. Note that items in the collection will be dereferenced before being compared. Persistence Isomorphic. Example In this example, a sorted vector of RWDates is exercised. // // tpsrtvec.cpp // #include #include #include
05/14/90 Related Classes RWTPtrSortedDlist is an alternative always-sorted pointer-based collection. RWTPtrOrderedVector is an unsorted pointer-based vector. Class vector is the Standard C++ Library collection that serves as the underlying implementation for this class.
Public Member Operators bool operator<(const RWTPtrSortedVector& vec) const; Returns true if self compares lexicographically less than vec, otherwise returns false. Items in each collection are dereferenced before being compared. bool operator==(const RWTPtrSortedVector& vec) const; Returns true if self compares equal to vec, otherwise returns false.
Client data may be passed through parameter d. reference at(size_type i); const_reference at(size_type i) const; Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type RWBoundsErr. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first element of self. void clear(); Clears the collection by removing all items from self.
const_iterator end() const; Returns an iterator positioned "just past" the last element in self. size_type entries() const; Returns the number of items in self. const T* find(const T* a) const; If there exists an element t in self such that the expression (*t == *a) is true, returns t. Otherwise, returns rwnil. const T* find(bool (*fn)(const T*,void*), void* d) const; If there exists an element t in self such that the expression ((*fn)(t,d)) is true, returns t. Otherwise, returns rwnil.
Adds the item a to self. The collection remains sorted. Returns true. size_type insert(const vector& a); Inserts all elements of a into self. The collection remains sorted. Returns the number of items inserted. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise. bool isSorted() const; Returns true if the collection is sorted relative to the supplied comparator object, false otherwise.
Removes and returns the first element t in self such that the expression (*t == *a) is true. Returns rwnil if there is no such element. T* remove(bool (*fn)(const T*,void*), void* d); Removes and returns the first element t in self such that the expression ((*fn)(t,d)) is true. Returns rwnil if there is no such element. fn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter d.
Returns a reference to the underlying C++-standard collection that serves as the implementation for self. Static Public Data Member const size_type npos; This is the value returned by member functions such as index to indicate a non-position. The value is equal to ~(size_type)0.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTPtrVector ● Synopsis ● Descripton ● Persistence ● Example ● Public Constructors ● Public operators ● Public Member Functions Synopsis #include RWTPtrVector vec; Descripton Class RWTPtrVector is a simple parameterized vector of pointers to objects of type T. It is most useful when you know precisely how many pointers must be held in the collection.
main() { RWTPtrVector week(7); RWDate begin; // Today's date for (int i=0; i<7; i++) week[i] = new RWDate(begin++); for (i=0; i<7; i++) { cout << *week[i] << endl; delete week[i]; } return 0; } Program output: March 16, 1996 March 17, 1996 March 18, 1996 March 19, 1996 March 20, 1996 March 21, 1996 March 22, 1996 Public Constructors RWTPtrVector(); Constructs an empty vector of length zero. RWTPtrVector(size_t n); Constructs a vector of length n.
Public operators RWTPtrVector& operator=(const RWTPtrVector& v); Sets self to a shallow copy of v. Afterwards, the two vectors will have the same length and pointersheld by the two vectors will point to the same items. RWTPtrVector& operator=(T* p); Sets all elements in self to point to the item *p. T*& operator()(size_t i); T* operator()(size_t i) const; Returns the ith value in the vector. The first variant can be used as an l-value, the second cannot.
Changes the length of the vector to N. If this results in the vector being lengthened, then the initial value of the additional elements is set to nil.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTQueue ● Synopsis ● Description ● Persistence ● Example ● Public Member Functions Synopsis #include RWTQueue queue; Description This class represents a parameterized queue. Not only can the type of object inserted into the queue be parameterized, but also the implementation. Parameter T represents the type of object in the queue, either a class or built in type.
Example In this example a queue of RWCStrings, implemented as a singly-linked list, is exercised. #include #include #include #include main() { RWTQueue > queue; queue.insert("one"); // Type conversion occurs queue.insert("two"); queue.insert("three"); while (!queue.isEmpty()) cout << queue.
queue). RWBoolean isEmpty() const; Returns TRUE if there are no items in the queue, otherwise FALSE. void insert(T a); Inserts the item a at the end of the queue. T last() const; Returns, but does not remove, the last item in the queue (the item most recently inserted into the queue).
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTStack ● Synopsis ● Description ● Persistence ● Example ● Public Member Functions Synopsis #include RWTStack stack; Description This class maintains a stack of values. Not only can the type of object inserted onto the stack be parameterized, but also the implementation of the stack. Parameter T represents the type of object in the stack, either a class or built in type.
Persistence None Example In this example a stack of ints, implemented as an ordered vector, is exercised. #include #include #include main() { RWTStack > stack; stack.push(1); stack.push(5); stack.push(6); while (!stack.isEmpty()) cout << stack.pop() << endl; return 0; } Program output: 6 5 1 Public Member Functions void clear(); Removes all items from the stack.
Push the item a onto the top of the stack. T pop(); Pop (remove and return) the item at the top of the stack. If there are no items on the stack then an exception of type TOOL_INDEX will occur. T top() const; Returns (but does not remove) the item at the top of the stack.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValDeque ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include
Persistence Isomorphic Example In this example, a double-ended queue of ints is exercised. // // tvdqint.cpp // #include #include /* * This program partitions integers into even and odd numbers */ int main(){ RWTValDeque numbers; int n; cout << "Input an assortment of integers (EOF to end):" << endl; while (cin >> n) { if (n % 2 == 0) numbers.pushFront(n); else numbers.pushBack(n); } while (numbers.entries()) { cout << numbers.
4 2 1 3 5 Related Classes Classes RWTValSlist, RWTValDlist, RWTValSortedDlist, and RWTValOrderedVector also provide a Rogue Wave interface to C++-standard sequence collections. The list classes should be considered for frequent insertions (or removals) in the interior of the collection. The vector may be more efficient if most insertions and removals occur at the end of the collection.
Public Member Operators RWTValDeque& operator=(const RWTValDeque& deq); RWTValDeque& operator=(const deque& deq); Calls the destructor on all elements of self and replaces them by copying all elements of deq. bool operator<(const RWTValDeque& deq) const; bool operator<(const deque& deq) const; Returns true if self compares lexicographically less than deq, otherwise returns false. Type T must have well-defined less-than semantics (T::operator<(const T&) or equivalent).
Public Member Functions void append(const_reference a); Adds the item a to the end of the collection. void apply(void (*fn)(reference,void*), void* d); void apply(void (*fn)(const_reference,void*), void* d) const; Applies the user-defined function pointed to by fn to every item in the collection. This function must have one of the prototypes: void yourfun(const_reference a, void* d); void yourfun(reference a, void* d); Client data may be passed through parameter d.
prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. iterator end(); const_iterator end() const; Returns a past-the-end valued iterator of self. size_type entries() const; Returns the number of elements in self. bool find(const_reference a,T& k) const; If there exists an element t in self such that the expression (t == a) is true, assigns t to k and returns true. Otherwise, returns false and leaves the value of k unchanged.
Client data may be passed through parameter d. bool insert(const_reference a); Adds the item a to the end of the collection. Returns true. void insertAt(size_type i, const_reference a); Inserts the item a in front of the item at position i in self. This position must be between 0 and the number of entries in the collection, otherwise the function throws an exception of type RWBoundsErr. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise.
prepend(const_reference a); Adds the item a to the beginning of the collection. T popBack(); Removes and returns the last item in the collection. T popFront(); Removes and returns the first item in the collection. void pushBack(const_reference a); Adds the item a to the end of the collection. void pushFront(const_reference a); Adds the item a to the beginning of the collection. bool remove(const_reference a); Removes the first element t in self such that the expression (t == a) is true and returns true.
Client data may be passed through parameter d. T removeAt(size_type i); Removes and returns the item at position i in self. This position must be between 0 and one less then the number of entries in the collection, otherwise the function throws an exception of type RWBoundsErr. T removeFirst(); Removes and returns the first item in the collection. T removeLast(); Removes and returns the first item in the collection.
Static Public Data Member const size_type npos; This is the value returned by member functions such as index to indicate a non-position. The value is equal to ~(size_type)0. Related Global Operators RWvostream& operator<<(RWvostream& strm, const RWTValDeque& coll); RWFile& operator<<(RWFile& strm, const RWTValDeque& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValDlist ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include RWTValDlist dlist; Please Note! If you have the Standard C++ Library, use the interface described here.
Persistence Isomorphic Example In this example, a doubly-linked list of user type Dog is exercised. // // tvdldog.cpp // #include #include #include class Dog { char* name; public: Dog( const char* c = "") { name = new char[strlen(c)+1]; strcpy(name, c); } ~Dog() { delete name; } // Define a copy constructor: Dog(const Dog& dog) { name = new char[strlen(dog.name)+1]; strcpy(name, dog.
friend ostream& operator<<(ostream& str, const Dog& dog){ str << dog.name; return str;} }; main(){ RWTValDlist terriers; terriers.insert("Cairn Terrier"); terriers.insert("Irish Terrier"); terriers.insert("Schnauzer"); // NB: type conversion occurs cout << "The list " << (terriers.contains("Schnauzer") ? "does " : "does not ") << "contain a Schnauzer\n"; terriers.insertAt( terriers.index("Irish Terrier"), "Fox Terrier" ); while (!terriers.isEmpty()) cout << terriers.
typedef T typedef T& typedef const T& value_type; reference; const_reference; Public Constructors RWTValDlist(); Constructs an empty, doubly-linked list. RWTValDlist(const list& lst); Constructs a doubly-linked list by copying all elements of lst. RWTValDlist(const RWTValDlist& rwlst); Copy constructor. RWTValDlist(size_type n, const T& val = T()); Constructs a doubly-linked list with n elements, each initialized to val.
operator()(size_type i); const_reference operator()(size_type i) const; Returns a reference to the ith element of self. Index i should be between 0 and one less then the number of entries, otherwise the results are undefined--no bounds checking is performed. reference operator[](size_type i); const_reference operator[](size_type i) const; Returns a reference to the ith element of self.
void clear(); Clears the collection by removing all items from self. Each item will have its destructor called. bool contains(const_reference a) const; Returns true if there exists an element t in self such that the expression(t == a) is true, otherwise returns false. bool contains(bool (*fn)(const_reference,void*), void* d) const; Returns true if there exists an element t in self such that the expression ((*fn)(t,d)) is true, otherwise returns false.
Returns a reference to the first element of self. T get(); Removes and returns the first element in the collection. If the collection is empty, the function throws an exception of type RWBoundsErr. This method is identical to removeFirst and is included for compatibility with previous versions. size_type index(const_reference a) const; Returns the position of the first item t in self such that (t == a), or returns the static member npos if no such item exists.
minElement(); const_reference minElement() const; Returns a reference to the minimum or maximum element in the collection. Type T must have well-defined less-than semantics (T::operator<(const T&) or equivalent). size_type occurrencesOf(const_reference a) const; Returns the number of elements t in self such that the expression (t == a) is true. size_type occurrencesOf(bool (*fn)(const_reference,void*),void* d) const; Returns the number of elements t in self such that the expression((*fn)(t,d)) is true.
bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. T removeAt(size_type i); Removes and returns the item at position i in self. This position must be between 0 and one less then the number of entries in the collection, otherwise the function throws an exception of type RWBoundsErr. T removeFirst(); Removes and returns the first item in the collection. T removeLast(); Removes and returns the first item in the collection.
Static Public Data Member const size_type npos; This is the value returned by member functions such as index to indicate a non-position. The value is equal to ~(size_type)0. Related Global Operators RWvostream& operator<<(RWvostream& strm, const RWTValDlist& coll); RWFile& operator<<(RWFile& strm, const RWTValDlist& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValDlistIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValDlist dl; RWTValDlistIterator itr(dl); Please Note! If you have the Standard C++ Library, use the interface described here.
reset(). The iterator becomes valid after being advanced with either a preincrement or operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equal to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTValDlist a; RWTValDlistIterator itr(a); a.insert("John"); a.insert("Steve"); a.
Public Member Operators RWBoolean operator()(); Advances self to the next element and returns its value. If the iterator has advanced past the last item in the container, the element returned will be a nil pointer equivalent to boolean false. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created, self will reference the first element.
Advances self to the first element t encountered by iterating forward such that the expression((*fn)(t,d)) is true. fn points to a user-defined tester function which must have prototype: bool yourTester(const T a, void* d); Client data may be passed through parameter d. Returns true if an element was found, returns false otherwise. T key(); Returns the stored value referenced by self. RWBoolean remove(); Removes the value referenced by self from the collection.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashDictionary ● Synopsis ● Please Note! Synopsis #define RWTValHashDictionary RWTValHashMap Please Note! If you have the Standard C++ Library, refer to the reference for this class under its new name: RWTValHashMap. Although the old name (RWTValHashDictionary) is still supported, we recommend that you use the new name when coding your applications.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashDictionaryIterator ● Synopsis ● Please Note! Synopsis #define RWTValHashDictionaryIterator RWTValHashMapIterator Please Note! If you have the Standard C++ Library, refer to the reference for this class under its new name: RWTValHashMapIterator. Although the old name (RWTValHashDictionaryIterator) is still supported, we recommend that you use the new name when coding your applications.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashMap ● Synopsis ● Please Note! ● Description ● Persistence ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTValHashMap m; Please Note! If you have the Standard C++ Library, use the interface described here.
Equivalent keys within the collection will be grouped together based on an equality object of type EQ. EQ must ensure this grouping via public member bool operator()(const K& x, const K& y) which should return true if x and y are equivalent. RWTValHashMap will not accept a key that compares equal to any key already in the collection. (RWTValHashMultiMap may contain multiple keys that compare equal to each other.) Equality is based on the equality object and not on the == operator.
Creates an empty hashed map which uses the hash object h and has an initial capacity of sz. RWTValHashMap(const RWTValHashMap& rwm); Copy constructor. RWTValHashMap(const value_type* first, const value_type* last); Constructs a map by copying elements from the array of value_type pairs pointed to by first, up to, but not including, the pair pointed to by last.
Client data may be passed through parameter d. void applyToKeyAndValue(void (*fn)(const K&, T&,void*),void* d); void applyToKeyAndValue (void (*fn)(const K&, const T, void*),void* d) const; This is a deprecated version of the apply member above. It behaves exactly the same as apply. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first pair in self. size_type capacity() const; Returns the number of buckets(slots) available in the underlying hash representation.
size_type entries() const; Returns the number of associations in self. float fillRatio() const; Returns the ratio entries()/capacity(). bool find(const K& key, K& r) const; If there exists a key j in self that compares equal to key, assigns j to r and returns true. Otherwise, returns false and leaves the value of r unchanged.
isEmpty() const; Returns true if there are no items in the collection, false otherwise. size_type occurrencesOf(const K& key) const; Returns the number of keys j in self that compare equal to key. size_type occurrencesOf(bool (*fn)(const_reference,void*),void* d) const; Returns the number of associations a in self such that the expression((*fn)(a,d)) is true.
Changes the capacity of self by creating a new hashed map with a capacity of sz . resize copies every element of self into the new container and finally swaps the internal representation of the new container with the internal representation of self. rw_hashmap& std(); const rw_hashmap& std() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashMapIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValHashMap m; RWTValHashMap itr(m); Please Note! If you have the Standard C++ Library, use the interface described here.
object, EQ, will remain adjacent. The current item referenced by this iterator is undefined after construction or after a call to reset(). The iterator becomes valid after being advanced with either a preincrement or an operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Example #include #include
Public Constructors RWTValHashMapIterator (RWTValHashMap&h); Creates an iterator for the hashmap h. The iterator begins in an undefined state and must be advanced before the first element will be accessible. Public Member Operators RWBoolean operator()(); Advances self to the next element. Returns false if the iterator has advanced past the last item in the container and true otherwise. RWBoolean operator++(); Advances self to the next element.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashMultiMap ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include
bool operator()(const K& x, const K& y) const which should return true if x and y are equivalent. RWTValHashMultiMap may contain multiple keys that compare equal to each other. (RWTValHashMap will not accept a key that compares equal to any key already in the collection.) Equality is based on the comparison object and not on the == operator. Persistence Isomorphic. Examples // // tvhmmrat.cpp // #include #include #include
Related Classes Class RWTValHashMap offers the same interface to a collection that will not accept multiple keys that compare equal to each other. Class rw_hashmultimap is the C++-standard collection that serves as the underlying implementation for this collection.
bool operator==(const rw_hashmultimap& m) const; Returns true if self compares equal to m, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual keys that compare equal to each other.
bool contains (bool (*fn)(const_reference,void*), void* d) const; Returns true if there exists an association a in self such that the expression ((*fn)(a,d)) is true, otherwise returns false. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. iterator end(); const_iterator end() const; Returns an iterator positioned "just past" the last association in self.
and tr unchanged. bool insert(const K& key, const T& a); Adds key with associated item a to the collection. Returns true. bool insertKeyAndValue(const K& key, const T& a); This is a deprecated version of the insert member above. It behaves exactly the same as insert. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise. size_type occurrencesOf(const K& key) const; Returns the number of keys j in self that compares equal to key.
removeAll(bool (*fn)(const_reference,void*), void* d); Removes all associations a in self such that the expression ((*fn)(a,d))is true. Returns the number of items removed. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. void resize(size_type sz); Changes the capacity of self by creating a new hashed multimap with a capacity of sz .
heap and sets p to point to it, or sets p to point to a previously read instance. If a collection is created off the heap, then you are responsible for deleting it.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashMultiMapIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Example ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include
The current item referenced by this iterator is undefined after construction or after a call to reset(). The iterator becomes valid after being advanced with either a preincrement or operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Example #include #include #include
Public Constructors RWTValHashMultiMapIterator (RWTValHashMultiMap&h); Creates an iterator for the hash multimap h. The iterator begins in an undefined state and must be advanced before the first element will be accessible. Public Member Operators RWBoolean operator()(); Advances self to the next element, dereferences the resulting iterator and returns false if the iterator has advanced past the last item in the container and true otherwise.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashMultiSet ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTValHashMultiSet Please Note! If you have the Standard C++ Library, use the interface described here.
Persistence Isomorphic Example // // tvhmsstr.cpp // #include #include #include struct silly_hash{ unsigned long operator()(RWCString x) const { return x.length() * (long)x[0]; } }; main(){ RWTValHashMultiSet > set1; RWTValHashMultiSet > set2; set1.insert("one"); set1.insert("two"); set1.insert("three"); set1.insert("one"); set1.
Public Typedefs typedef typedef typedef typedef typedef typedef typedef rw_hashmultiset container_type::iterator container_type::const_iterator container_type::size_type T T& const T& container_type; iterator; const_iterator; size_type; value_type; reference; const_reference; Public Constructors RWTValHashMultiSet (size_type sz = 1024,const H& h = H(),const EQ& eq = EQ()); Constructs an empty set.
iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first element of self. size_type capacity() const; Returns the number of buckets(slots) available in the underlying hash representation. See resize below. void clear(); Clears the collection by removing all items from self. Each item will have its destructor called. bool contains(const_reference a) const; Returns true if there exists an element t in self that compares equal to a, otherwise returns false.
Adds the item a to the collection. Returns true. void intersection(const RWTValHashMultiSet& s); Destructively performs a set theoretic intersection of self and s, replacing the contents of self with the result. bool isEmpty() const; Returns true if there are no items in the collection, false otherwise. bool isEquivalent(const RWTValHashMultiSet& s) const; Returns true if there is set equivalence between self and s, and returns false otherwise.
Changes the capacity of self by creating a new hashed multi-set with a capacity of sz . resize copies every element of self into the new container and finally swaps the internal representation of the new container with the internal representation of self. rw_hashmultiset& std(); const rw_hashmultiset& std() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashMultiSetIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValHashMultiSet m; RWTValHashMultiSet itr(m); Please Note! If you have the Standard C++ Library, use the interface described here.
The current item referenced by this iterator is undefined after construction or after a call to reset(). The iterator becomes valid after being advanced with either a preincrement or operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Example #include #include #include
Public Constructors RWTValHashMultiSetIterator (RWTValHashMultiSet&h); Creates an iterator for the hashed multi-set h. The iterator begins in an undefined state and must be advanced before the first element will be accessible Public Member Operators RWBoolean operator()(); Advances self to the next element. Returns false if the iterator has advanced past the last item in the container and true otherwise. RWBoolean operator++(); Advances self to the next element.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashSet ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTValHashSet s; Please Note! If you have the Standard C++ Library, use the interface described here.
Objects within the collection will be grouped together based on an equality object of type EQ. EQ must ensure this grouping via public member bool operator()(const T& x, const T& y) const which should return true if x and y are equivalent, false otherwise. RWTValHashSet will not accept an item that compares equal to an item already in the collection. (RWTValHashMultiSet may contain multiple items that compare equal to each other.
set2.insert("one"); cout << ((set1.isEquivalent(set2)) ? "TRUE" : "FALSE") << endl; // Prints "FALSE" set2.intersection(set1); set1.clear(); cout << set1.entries() << endl; cout << set2.entries() << endl; // Prints "0" // Prints "1" return 0; } Related Classes Class RWTValHashMultiSet offers the same interface to a collection that accepts multiple items that compare equal to each other.
RWTPtrHashSet (const H& h,size_type sz = RWDEFAULT_CAPACITY); Creates an empty hashed set which uses the hash object h and has an initial hash table capacity of sz. RWTValHashSet(const T* first,const T* last, size_type sz = 1024,const H& h = H(),const EQ& eq = EQ()); Constructs a set by copying elements from the array of Ts pointed to by first, up to, but not including, the element pointed to by last.
size_type capacity() const; Returns the number of buckets(slots) available in the underlying hash representation. See resize below. void clear(); Clears the collection by removing all items from self. Each item will have its destructor called. bool contains(const_reference a) const; Returns true if there exists an element t in self that compares equal to a, otherwise returns false.
If there exists an element t in self that compares equal to a, assigns t to k and returns true. Otherwise, returns false and leaves the value of k unchanged. bool find(bool (*fn)(const_reference,void*), void* d, value_type& k) const; If there exists an element t in self such that the expression ((*fn)(t,d)) is true, assigns t to k and returns true. Otherwise, returns false and leaves the value of k unchanged.
occurrencesOf (bool (*fn)(const_reference,void*),void* d) const; Returns the number of elements t in self such that the expression((*fn)(t,d)) is true. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. bool remove(const_reference a); Removes the first element t in self that compares equal to a. Returns false if there is no such element.
Returns a reference to the underlying collection that serves as the implementation for self. This reference may be used freely, providing access to the C++-standard interface as well as interoperability with other software components that make use of the C++-standard collections. void symmetricDifference(const RWTValHashSet& s); void symmetricDifference(const rw_hashset& s); Destructively performs a set theoretic symmetric difference operation on self and s. Self is replaced by the result.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashSetIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValHashSet m; RWTValHashSetIterator itr(m); Please Note! If you have the Standard C++ Library, use the interface described here.
object, EQ, will remain adjacent. The current item referenced by this iterator is undefined after construction or after a call to reset(). The iterator becomes valid after being advanced with either a pre-increment or an operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Example #include #include
Public Constructors RWTValHashSetIterator (RWTValHashSet&h); Creates an iterator for the hashset h. The iterator begins in an undefined state and must be advanced before the first element will be accessible. Public Member Operators RWBoolean operator()(); Advances self to the next element. Returns false if the iterator has advanced past the last item in the container and true otherwise. RWBoolean operator++(); Advances self to the next element.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashTable ● Synopsis ● Please Note! Synopsis #define RWTValHashTable RWTValHashMultiSet Please Note! If you have the Standard C++ Library, refer to the reference for this class under its new name: RWTValHashMultiSet. Although the old name (RWTValHashTable) is still supported, we recommend that you use the new name when coding your applications.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValHashTableIterator ● Synopsis ● Please Note! Synopsis #define RWTValHashTableIterator RWTValHashMultiSetIterator Please Note! If you have the Standard C++ Library, refer to the reference for this class under its new name: RWTValHashMultiSetIterator. Although the old name (RWTValHashTableIterator) is still supported, we recommend that you use the new name when coding your applications.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValMap ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTValMap m; Standard C++ Library Dependent! RWTValMap requires the Standard C++ Library.
which returns true if x and its partner should precede y and its partner within the collection. The structure less from the C++-standard header file is an example. RWTValMap will not accept a key that compares equal to any key already in the collection. (RWTValMultiMap may contain multiple keys that compare equal to each other.) Equality is based on the comparison object and not on the == operator.
Related Classes Class RWTValMultiMap offers the same interface to a collection that accepts multiple keys that compare equal to each other. RWTValSet maintains a collection of keys without the associated values. Class map is the C++-standard collection that serves as the underlying implementation for this collection.
bool operator<(const container_type & m) const; Returns true if self compares lexicographically less than m, otherwise returns false. Assumes that type K has well-defined less-than semantics (T::operator<(const K&) or equivalent). bool operator==(const RWTValMap& m) const; bool operator==(const container_type & m) const; Returns true if self compares equal to m, otherwise returns false.
begin() const; Returns an iterator positioned at the first pair in self. void clear(); Clears the collection by removing all items from self. Each key and its associated item will have its destructor called. bool contains(const K& key) const; Returns true if there exists a key j in self that compares equal to key, otherwise returns false.
Client data may be passed through parameter d. bool findValue(const K& key, T& r) const; If there exists a key j in self that compares equal to key, assigns the item associated with j to r and returns true. Otherwise, returns false and leaves the value of r unchanged. bool findKeyValue(const K& key, K& kr, T& tr) const; If there exists a key j in self that compares equal to key, assigns j to kr, assigns the item associated with j to tr, and returns true.
remove(bool (*fn)(const_reference,void*), void* d); Removes the first association a in self such that the expression ((*fn)(a,d)) is true and returns true. Returns false if there is no such element. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. size_type removeAll(const K& key); Removes all associations with key j in self such that j compares equal to key. Returns the number of items removed.
Restores the contents of the collection coll from the input stream strm. RWvistream& operator>>(RWvistream& strm, RWTValMap*& p); RWFile& operator>>(RWFile& strm, RWTValMap*& p); Looks at the next object on the input stream strm and either creates a new collection off the heap and sets p to point to it, or sets p to point to a previously read instance. If a collection is created off the heap, then you are responsible for deleting it.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValMapIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● xamples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValMap vm; RWTValMapIterator itr(vm); Standard C++ Library Dependent! RWTValMapIterator requires the Standard C++ Library.
For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None xamples #include #include #include int main(){ RWTValMap > age; RWTValMapIterator > itr(age); age.insert("John", 30); age.insert("Steve",17); age.
Public Member Operators RWBoolean operator()(); Advances self to the next element. If the iterator has advanced past the last element in the collection, false will be returned. Otherwise, true will be returned. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created self will now reference the first element. If, before iteration, self pointed to the last association in the map, self will now reference an undefined value and false will be returned.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValMultiMap ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTValMultiMap m; Standard C++ Library Dependent! RWTValMultiMap requires the Standard C++ Library.
which returns true if x and its partner should precede y and its partner within the collection. The structure less from the C++-standard header file is an example. RWTValMultiMap may contain multiple keys that compare equal to each other. (RWTValMap will not accept a key that compares equal to any key already in the collection.) Equality is based on the comparison object and not on the == operator.
} Program Output: There are 3 Ivans: 1. 11/02/80 2. 06/19/71 3. 07/06/50 Related Classes Class RWTValMap offers the same interface to a collection that will not accept multiple keys that compare equal to each other. RWTValMultiSet maintains a collection of keys without the associated values. Class multimap is the C++-standard collection that serves as the underlying implementation for this collection.
Public Member Operators RWTValMultiMap& operator=(const RWTValMultiMap& m); RWTValMultiMap& operator=(const container_type& m) const; Destroys all elements of self and replaces them by copying all associations from m. bool operator<(const RWTValMultiMap& m); bool operator<(const container_type& m) const; Returns true if self compares lexicographically less than m, otherwise returns false.
iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first pair in self. void clear(); Clears the collection by removing all items from self. Each key and its associated item will have its destructor called. bool contains(const K& key) const; Returns true if there exists a key j in self that compares equal to key, otherwise returns false.
a to r and returns true. Otherwise, returns false and leaves the value of k unchanged. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. bool findValue(const K& key, T& r) const; If there exists a key j in self that compares equal to key, assigns the item associated with j to r and returns true. Otherwise, returns false and leaves the value of r unchanged.
true. Returns false if there is no such association. bool remove(bool (*fn)(const_reference,void*), void* d); Removes the first association a in self such that the expression ((*fn)(a,d)) is true and returns true. Returns false if there is no such element. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d.
RWFile& operator>>(RWFile& strm, RWTValMultiMap& coll); Restores the contents of the collection coll from the input stream strm. RWvistream& operator>>(RWvistream& strm, RWTValMultiMap*& p); RWFile& operator>>(RWFile& strm, RWTValMultiMap*& p); Looks at the next object on the input stream strm and either creates a new collection off the heap and sets p to point to it, or sets p to point to a previously read instance.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValMultiMapIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValMultiMap vm; RWTValMultiMapIterator itr(vm); Standard C++ Library Dependent! RWTValMultiMapIterator requires the Standard C++ Library.
operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTValMultiMap > a; RWTValMultiMapIterator > itr(a); a.insert("John", 30); a.insert("Steve",17); a.insert("Mark",24); a.
Public Member Operators RWBoolean operator()(); Advances self to the next element. If the iterator has advanced past the last item in the collection, returns false. Otherwise, returns true. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created self will now reference the first element. If, before iteration, self referenced the last association in the multi-map, self will now reference an undefined value and false will be returned.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValMultiSet ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTValMultiSet Standard C++ Library Dependent! RWTValMultiSet requires the Standard C++ Library.
C++-standard header file is an example. RWTValMultiSet may contain multiple items that compare equal to each other. (RWTValSet will not accept an item that compares equal to an item already in the collection.) Persistence Isomorphic. Examples In this example, a multi-set of RWCStrings is exercised. // // tvmsstr.cpp // #include #include #include main(){ RWTValMultiSet > set; set.insert("one"); set.
Public Typedefs typedef typedef typedef typedef typedef typedef multiset container_type::iterator container_type::const_iterator container_type::size_type T const T& container_type; iterator; const_iterator; size_type; value_type; const_reference; Public Constructors RWTValMultiSet(const C& cmp = C()); Constructs an empty set. RWTValMultiSet(const container_type& s); Constructs a set by copying all elements of s.
operator==(const container_type& s) const; Returns true if self compares equal to s, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. Public Member Functions void apply(void (*fn)(const_reference,void*), void* d) const; Applies the user-defined function pointed to by fn to every item in the collection.
Sets self to the set-theoretic difference given by (self - s). iterator end(); const_iterator end() const; Returns an iterator positioned "just past" the last element in self. size_type entries() const; Returns the number of items in self. bool find(const_reference a, T& k) const; If there exists an element t in self that compares equal to a, assigns t to k and returns true. Otherwise, returns false and leaves the value of k unchanged.
Returns true if self is a proper subset of s, and returns false otherwise. bool isSubsetOf(const RWTValMultiSet& s) const; Returns true if self is a subset of s or if self is set equivalent to rhs, false otherwise. size_type occurrencesOf(const_reference a) const; Returns the number of elements t in self that compare equal to a. size_type occurrencesOf(bool (*fn)(const_reference,void*),void* d) const; Returns the number of elements t in self such that the expression((*fn)(t,d)) is true.
std(); const multiset& std() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self. This reference may be used freely, providing access to the C++-standard interface as well as interoperability with other software components that make use of the C++-standard collections. void symmetricDifference(const RWTValMultiSet& s); void symmetricDifference(const container_type& s); Sets self to the symmetric difference of self and s.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValMultiSetIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValMultiSet< T,C> vs; RWTValMultiSetIterator< T,C> itr(vs); Standard C++ Library Dependent! RWTValMultiSetIterator requires the Standard C++ Library.
operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTValMultiSet > a; RWTValMultiSetIterator > itr(a); a.insert("John"); a.insert("Steve"); a.insert("Mark"); a.
Public Member Operators RWBoolean operator()(); Advances self to the next element. If the iterator has advanced past the last element in the collection, false will be returned. Otherwise, true will be returned. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created self will now reference the first element. If, before iteration, self referenced the last association in the multi-set, self will now reference an undefined value and false will be returned.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValOrderedVector ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include
Persistence Isomorphic Example In this example, a vector of type double is exercised. // // tvordvec.cpp // #include #include main() { RWTValOrderedVector vec; vec.insert(22.0); vec.insert(5.3); vec.insert(-102.5); vec.insert(15.0); vec.insert(5.3); cout << vec.entries() << " entries\n" << endl; for (int i=0; i
Public Typedefs typedef typedef typedef typedef typedef typedef typedef vector container_type::iterator container_type::const_iterator container_type::size_type T T& const T& container_type; iterator; const_iterator; size_type; value_type; reference; const_reference; Public Constructors RWTValOrderedVector(); Constructs an empty vector. RWTValOrderedVector(const vector& vec); Constructs a vector by copying all elements of vec.
Returns true if self compares lexicographically less than vec, otherwise returns false. Type T must have well-defined less-than semantics (T::operator<(const T&) or equivalent). bool operator==(const RWTValOrderedVector& vec) const; bool operator==(const vector& vec) const; Returns true if self compares equal to vec, otherwise returns false.
reference at(size_type i); const_reference at(size_type i) const; Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type RWBoundsErr. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first element of self. void clear(); Clears the collection by removing all items from self. Each item will have its destructor called.
Returns the number of elements in self. bool find(const_reference a, value_type& k) const; If there exists an element t in self such that the expression (t == a) is true, assigns t to k and returns true. Otherwise, returns false and leaves the value of k unchanged. bool find(bool (*fn)(const_reference,void*), void* d, value_type& k) const; If there exists an element t in self such that the expression ((*fn)(t,d)) is true, assigns t to k and returns true.
bool isEmpty() const; Returns true if there are no items in the collection, false otherwise. reference last(); const_reference last() const; Returns a reference to the last item in the collection. size_type length() const; Returns the number of elements in self. reference maxElement(); const_reference maxElement() const; reference minElement(); const_reference minElement() const; Returns a reference to the minimum or maximum element in the collection.
true. Returns false if there is no such element. bool remove(bool (*fn)(const_reference,void*), void* d); Removes the first element t in self such that the expression ((*fn)(t,d)) is true and returns true. Returns false if there is no such element. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d.
Replaces all elements t in self such that the expression ((*fn)(t,d))is true. Returns the number of items replaced. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. void resize(size_type n); Modify the capacity of the vector to be at least as large as n. The function has no effect if the capacity is already as large as n.
Restores the contents of the collection coll from the input stream strm. RWvistream& operator>>(RWvistream& strm, RWTValOrderedVector*& p); RWFile& operator>>(RWFile& strm, RWTValOrderedVector*& p); Looks at the next object on the input stream strm and either creates a new collection off the heap and sets p to point to it, or sets p to point to a previously read instance. If a collection is created off the heap, then you are responsible for deleting it.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValSet ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Related Global Operators Synopsis #include RWTValSet s; Standard C++ Library Dependent! RWTValSet requires the Standard C++ Library.
C++-standard header file is an example. RWTValSet will not accept an item that compares equal to an item already in the collection. (RWTValMultiSet may contain multiple items that compare equal to each other.) Equality is based on the comparison object and not on the == operator. Given a comparison object comp, items a and b are equal if !comp(a,b) && !comp(b,a). Persistence Isomorphic. Examples In this example, a set of RWCStrings is exercised. // // tvsstr.
Public Typedefs typedef typedef typedef typedef typedef typedef set container_type::iterator container_type::const_iterator container_type::size_type T const T& container_type; iterator; const_iterator; size_type; value_type; const_reference; Public Constructors RWTValSet(const C& comp = C()); Constructs an empty set. RWTValSet(const container_type& s); Constructs a set by copying all elements of s. RWTValSet(const RWTValSet& rws); Copy constructor.
operator==(const set& s) const; Returns true if self compares equal to s, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. Public Member Functions void apply(void (*fn)(const_reference,void*), void* d) const; Applies the user-defined function pointed to by fn to every item in the collection.
Sets self to the set-theoretic difference given by (self - s). iterator end(); const_iterator end() const; Returns an iterator positioned "just past" the last element in self. size_type entries() const; Returns the number of items in self. bool find(const_reference a, T& k) const; If there exists an element t in self that compares equal to a, assigns t to k and returns true. Otherwise, returns false and leaves the value of k unchanged.
isProperSubsetOf(const RWTValSet& s) const; Returns true if self is a proper subset of s, and returns false otherwise. bool isSubsetOf(const RWTValSet& s) const; Returns true if self is a subset of s; false otherwise. size_type occurrencesOf(const_reference a) const; Returns the number of elements t in self that compare equal to a. size_type occurrencesOf(bool (*fn)(const T&,void*),void* d) const; Returns the number of elements t in self such that the expression((*fn)(t,d)) is true.
Client data may be passed through parameter d. set& std(); const set& std() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self. This reference may be used freely, providing access to the C++-standard interface as well as interoperability with other software components that make use of the C++-standard collections.
collection is created off the heap, then you are responsible for deleting it.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValSetIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValSet vs; RWTValSetIterator itr(vs); Standard C++ Library Dependent! RWTValSetIterator requires the Standard C++ Library.
operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTValSet > a; RWTValSetIterator > itr(a); a.insert("John"); a.insert("Steve"); a.
Public Member Operators RWBoolean operator()(); Advances self to the next element. If the iterator has advanced past the last element in the collection, false will be returned. Otherwise, true will be returned. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created self will now reference the first element. If, before iteration, self referenced the last association in the set, self will now reference an undefined value and false will be returned.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValSlist ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include RWTValSlist lst; Please Note! If you have the Standard C++ Library, use the interface described here.
Persistence Isomorphic Example In this example, a singly-linked list of RWDates is exercised. // // tvslint.cpp // #include #include 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 lst(vec, vec+10); RWTValSlistIterator itr(lst); lst.apply(div5, 0); lst.sort(); for(;itr();) cout << itr.
Public Typedefs typedef typedef typedef typedef typedef typedef typedef rw_slist container_type::iterator container_type::const_iterator container_type::size_type T T& const T& container_type; iterator; const_iterator; size_type; value_type; reference; const_reference; Public Constructors RWTValSlist(); Constructs an empty, singly-linked list. RWTValSlist(const rw_slist& lst); Constructs a singly-linked list by copying all elements of lst.
bool operator==(const RWTValSlist& lst) const; bool operator==(const rw_slist& lst) const; Returns true if self compares equal to lst, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. reference operator()(size_type i); const_reference operator()(size_type i) const; Returns a reference to the ith element of self.
Returns a reference to the ith element of self. Index i must be between 0 and one less then the number of entries in self, otherwise the function throws an exception of type RWBoundsErr. iterator begin(); const_iterator begin() const; Returns an iterator positioned at the first element of self. void clear(); Clears the collection by removing all items from self. Each item will have its destructor called.
(bool (*fn)(const_reference,void*),void* d,reference k) const; If there exists an element t in self such that the expression ((*fn)(t,d)) is true, assigns t to k and returns true. Otherwise, returns false and leaves the value of k unchanged. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. reference first(); const_reference first() const; Returns a reference to the first element of self.
Returns true if there are no items in the collection, false otherwise. T last() const; Returns a reference to the last item in the collection. reference maxElement(); const_reference maxElement() const; reference minElement(); const_reference minElement() const; Returns a reference to the minimum or maximum element in the collection. Type T must have well-defined less-than semantics (T::operator<(const T&) or equivalent).
size_type removeAll(const_reference a); Removes all elements t in self such that the expression (t == a) is true. Returns the number of items removed. size_type removeAll(bool (*fn)(const_reference,void*), void* d); Removes all elements t in self such that the expression ((*fn)(t,d))is true. Returns the number of items removed. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d.
Sorts the collection using the less-than operator to compare elements. rw_slist& std(); const rw_slist& std() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self. This reference may be used freely, providing access to the C++-standard interface as well as interoperability with other software components that make use of the C++-standard collections.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValSlistIterator ● Synopsis ● Please Note! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValSlist dl; RWTValSlistIterator itr(dl); Please Note! If you have the Standard C++ Library, use the interface described here.
reset(). The iterator becomes valid after being advanced with either a preincrement or operator(). For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equal to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTValSlist a; RWTValSlistIterator itr(a); a.insert("John"); a.insert("Steve"); a.
Public Member Operators RWBoolean operator()(); Advances self to the next element. If the iterator has advanced past the last element in the collection, false will be returned. Otherwise, true will be returned. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created, self will reference the first element.
expression((*fn)(t,d)) is true. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d. Returns true if an element was found, returns false otherwise. void insertAfterPoint(T* p); Inserts the pointer p into the container directly after the element referenced by self. T key(); Returns the stored value referenced by self. RWBoolean remove(); Removes the value referenced by self from the collection.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValSortedDlist ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include
Persistence Isomorphic. Example In this example, a sorted doubly-linked list of RWDates is exercised. // // tvsdldat.cpp // #include #include #include #include main(){ RWTValSortedDList > 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)); lst.
implementation for this class. Public Typedefs typedef typedef typedef typedef typedef typedef typedef list container_type::const_iterator container_type::const_iterator container_type::size_type T T& const T& container_type; iterator; const_iterator; size_type; value_type; reference; const_reference; Public Constructors RWTValSortedDlist(); Constructs an empty doubly-linked list.
Assumes that type T has well-defined less-than semantics (T::operator<(const T&) or equivalent). bool operator==(const RWTValSortedDlist& lst) const; bool operator==(const list& lst) const; Returns true if self compares equal to lst, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other.
clear(); Clears the collection by removing all items from self. Each item will have its destructor called. bool contains(const_reference a) const; Returns true if there exists an element t in self such that the expression(t==a) is true, otherwise returns false. bool contains(bool (*fn)(const_reference,void*), void* d) const; Returns true if there exists an element t in self such that the expression ((*fn)(t,d)) is true, otherwise returns false.
first() const; Returns a reference to the first element of self. size_type index(const_reference a) const; Returns the position of the first item t in self such that (t == a), or returns the static member npos if no such item exists. size_type index(bool (*fn)(const_reference,void*), void* d) const; Returns the position of the first item t in self such that((*fn)(t,d)) is true, or returns the static member npos if no such item exists.
Returns the number of elements t in self such that the expression (t == a) is true. size_type occurrencesOf(bool (*fn)(const_reference,void*), void* d) const; Returns the number of elements t in self such that the expression((*fn)(t,d)) is true. fn points to a user-defined tester function which must have prototype: bool yourTester(const_reference a, void* d); Client data may be passed through parameter d.
Removes and returns the first item in the collection. T removeLast(); Removes and returns the first item in the collection. list& std(); const list& std() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self. It is your responsibility not to violate the ordering of the elements within the collection.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValSortedDlistIterator ● Synopsis ● Standard C++ Library Dependent! ● Description ● Persistence ● Examples ● Public Constructors ● Public Member Operators ● Public Member Functions Synopsis #include RWTValSortedDlist dl; RWTValSortedDlistIterator itr(dl); Standard C++ Library Dependent! RWTValSortedDlistIterator requires the Standard C++ Library.
For both operator++ and operator(), iterating past the last element will return a value equivalent to boolean false. Continued increments will return a value equivalent to false until reset() is called. Persistence None Examples #include #include #include int main(){ RWTValSortedDlist > a; RWTValSortedDlistIterator > itr(a); a.insert("John"); a.insert("Steve"); a.insert("Mark"); a.
container, the element returned will be a nil pointer equivalent to boolean false. RWBoolean operator++(); Advances self to the next element. If the iterator has been reset or just created, self will reference the first element. If, before iteration, self referenced the last value in the list, self will now point to an undefined value distinct from the reset value and false will be returned. Otherwise, true is returned. Note: no postincrement operator is provided.
T key(); Returns the stored value referenced by self. RWBoolean remove(); Removes the stored value referenced by self from the collection. Returns true if the value was successfully removed, false otherwise. RWBoolean removeNext(const T); Removes the first element t, encountered by iterating self forward, such that the expression (t == a) is true. Returns true if such an element is successfully removed, false otherwise.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValSortedVector ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Related Classes ● Public Typedefs ● Public Constructors ● Public Member Operators ● Public Member Functions ● Static Public Data Member ● Related Global Operators Synopsis #include
Persistence Isomorphic Example In this example, a sorted vector of RWDates is exercised. // // tvsvcdat.cpp // #include #include #include main(){ RWTValSortedVector > vec; vec.insert(RWDate(10, "Aug", 1991)); vec.insert(RWDate(9, "Aug", 1991)); vec.insert(RWDate(1, "Sep", 1991)); vec.insert(RWDate(14, "May", 1990)); vec.insert(RWDate(1, "Sep", 1991)); vec.insert(RWDate(2, "June", 1991)); // Add a duplicate for (int i=0; i
Public Typedefs typedef typedef typedef typedef typedef typedef typedef vector container_type::const_iterator container_type::const_iterator container_type::size_type T const T& const T& container_type; iterator; const_iterator; size_type; value_type; reference; const_reference; Public Constructors RWTValSortedVector(); Constructs an empty vector. RWTValSortedVector(const vector& vec); Constructs a vector by copying and sorting all elements of vec.
Returns true if self compares equal to vec, otherwise returns false. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. reference operator()(size_type i); const_reference operator()(size_type i) const; Returns a reference to the ith element of self.
clear(); Clears the collection by removing all items from self. Each item will have its destructor called. bool contains(const_reference a) const; Returns true if there exists an element t in self such that the expression(t==a) is true, otherwise returns false. bool contains(bool (*fn)(const_reference,void*), void* d) const; Returns true if there exists an element t in self such that the expression ((*fn)(t,d)) is true, otherwise returns false.
Client data may be passed through parameter d. reference first(); const_reference first() const; Returns a reference to the first element of self. size_type index(const_reference a) const; Returns the position of the first item t in self such that (t == a), or returns the static member npos if no such item exists.
Returns the maximum number of elements which can be stored in self without first resizing. size_type merge(const RWTValSortedVector& dl); Inserts all elements of dl into self, preserving sorted order. size_type occurrencesOf(const_reference a) const; Returns the number of elements t in self such that the expression (t == a) is true. size_type occurrencesOf(bool (*fn)(const_reference,void*), void* d) const; Returns the number of elements t in self such that the expression((*fn)(t,d)) is true.
Client data may be passed through parameter d. value_type removeAt(size_type i); Removes and returns the item at position i in self. This position must be between zero and one less then the number of entries in the collection, otherwise the function throws an exception of type RWBoundsErr. value_type removeFirst(); Removes and returns the first item in the collection. value_type removeLast(); Removes and returns the first item in the collection.
operator>>(RWvistream& strm, RWTValSortedVector& coll); RWFile& operator>>(RWFile& strm, RWTValSortedVector& coll); Restores the contents of the collection coll from the input stream strm. RWvistream& operator>>(RWvistream& strm, RWTValSortedVector*& p); RWFile& operator>>(RWFile& strm, RWTValSortedVector*& p); Looks at the next object on the input stream strm and either creates a new collection off the heap and sets p to point to it, or sets p to point to a previously read instance.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValVector ● Synopsis ● Descripton ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions Synopsis #include RWTValVector vec; Descripton Class RWTValVector is a simple parameterized vector of objects of type T. It is most useful when you know precisely how many objects have to be held in the collection.
Example #include #include #include main() { RWTValVector week(7); RWDate begin; // Today's date for (int i=0; i<7; i++) week[i] = begin++; for (i=0; i<7; i++) cout << week[i] << endl; return 0; } Program output: March 16, 1996 March 17, 1996 March 18, 1996 March 19, 1996 March 20, 1996 March 21, 1996 March 22, 1996 Public Constructors RWTValVector(); Constructs an empty vector of length zero.
Calls the destructor for every element in self. Public Operators RWTValVector& operator=(const RWTValVector& v); Sets self to the same length as v and then copies all elements of v into self. RWTValVector& operator=(const T& ival); Sets all elements in self to the value ival. const T& operator()(size_t i) const; T& operator()(size_t i); Returns a reference to the ith value in the vector. The index i must be between 0 and the length of the vector less one. No bounds checking is performed.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWTValVirtualArray ● Synopsis ● Description ● Persistence ● Example ● Public Constructors ● Public Destructor ● Public Operators ● Public Member Functions Synopsis #include RWVirtualPageHeap* heap; RWTValVirtualArray array(1000L, heap); Description This class represents a virtual array of elements of type T of almost any length.
elements is equal to the page size divided by the element size, rounded downwards. Example: for a page size of 512 bytes, and an element size of 8, then 64 elements would be put on a page. The indexing operator (operator[](long)) actually returns an object of type RWTVirtualElement. Consider this example: double d = vec[j]; vec[i] = 22.0; Assume that vec is of type RWTValVirtualArray.
friend ostream& operator<<(ostream& str, ErsatzInt& i) { str << atoi(i.buf); return str; } }; main() { RWDiskPageHeap heap; RWTValVirtualArray vec1(10000L, &heap); for (long i=0; i<10000L; i++) vec1[i] = i; // Some compilers may need a cast here cout << vec1[100] << endl; cout << vec1[300] << endl; // Prints "100" // Prints "300" RWTValVirtualArray vec2 = vec1.slice(5000L, 500L); cout << vec2.
Public Destructor ~RWTValVirtualArray(); Releases all pages allocated by the vector. Public Operators RWTValVirtualArray& operator=(const RWTValVirtualArray& v); Sets self to a copy of v. The resultant vector will use the same heap and have the same length as v. The actual copy will not be made until a write, minimizing the amount of heap allocations and copying that must be done. void operator=(const RWTVirtualSlice& sl); Sets self equal to a slice of another vector.
Returns a copy of the value at index i. The index i must be between zero and the length of the vector less one or an exception of type TOOL_LONGINDEX will occur. void set(long i, const T& v); Sets the value at the index i to v. The index i must be between zero and the length of the vector less one or an exception of type TOOL_LONGINDEX will occur. RWTVirtualSlice slice(long start, long length); Returns a reference to a slice of self.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWVirtualPageHeap ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Destructor ● Public Member Functions ● Public Pure Virtual Functions Synopsis #include (Abstract base class) Description This is an abstract base class representing an abstract page heap of fixed sized pages.
Locked pages use up memory. In fact, some specializing classes may have only a fixed number of buffers in which to do their swapping. If you are not using the page, you should call unlock(). After calling unlock() the original address returned by lock() is no longer valid -- to use the page again, it must be locked again with lock(). When you are completely done with the page then call deallocate() to return it to the abstract heap.
Public Constructor RWVirtualPageHeap(unsigned pgsize); Sets the size of a page. Public Destructor virtual ~RWVirtualPageHeap(); The destructor has been made virtual to give specializing classes a chance to deallocate any resources that they may have allocated. Public Member Functions unsigned pageSize() const; Returns the page size for this abstract page heap. Public Pure Virtual Functions virtual RWHandle allocate() = 0 Allocates a page off the abstract heap and returns a handle for it.
function the address returned by lock() is no longer valid.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWvios ● Synopsis ● Description ● Persistence ● Public Member Functions Synopsis #include (abstract base class) Description RWvios is an abstract base class. It defines an interface similar to the C++ streams class ios. However, unlike ios, it offers the advantage of not necessarily being associated with a streambuf.
virtual int fail() = 0; Returns a nonzero integer if the fail or bad bit has been set. Normally, this indicates that some storage or retrieval has failed but that the stream is still in a usable state. virtual int bad() = 0; Returns a nonzero integer if the bad bit has been set. Normally this indicates that a severe error has occurred from which recovery is probably impossible. virtual int good() = 0; Returns a nonzero integer if no error bits have been set.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWvistream RWvistream RWvios ● Synopsis ● Description ● Persistence ● Example ● Public Destructor ● Public Operators ● Public Member Functions Synopsis #include Description Class RWvistream is an abstract base class. It provides an interface for format-independent retrieval of fundamental types and arrays of fundamental types.
Persistence None Example #include void restoreStuff( RWvistream& str) { int i; double d; char string[80]; str >> i; // Restore an int str >> d; // Restore a double // Restore a character string, up to 80 characters long: str.getString(string, sizeof(string)); if(str.fail()) cerr << "Oh, oh, bad news.\n"; } Public Destructor virtual ~RWvistream(); This virtual destructor allows specializing classes to deallocate any resources that they may have allocated.
operator>>(int& i) = 0; Get the next int from the input stream and store it in i. virtual RWvistream& operator>>(long& l) = 0; Get the next long from the input stream and store it in l. virtual RWvistream& operator>>(short& s) = 0; Get the next short from the input stream and store it in s. virtual RWvistream& operator>>(unsigned char& c) = 0; Get the next unsigned char from the input stream and store it in c.
virtual RWvistream& get(unsigned char& c) = 0; Get the next unsigned char from the input stream, returning its value in c. virtual RWvistream& get(char* v, size_t N) = 0; Get a vector of chars and store them in the array beginning at v. If the restore operation stops prematurely because there are no more data available on the stream, because an exception is thrown, or for some other reason, get stores what has already been retrieved from the stream into v, and sets the failbit.
exception is thrown, or for some other reason,get stores what has already been retrieved from the stream into v, and sets the failbit. virtual RWvistream& get(short* v, size_t N) = 0; Get a vector of N shorts and store them in the array beginning at v. If the restore operation stops prematurely because there are no more data available on the stream, because an exception is thrown, or for some other reason,get stores what has already been retrieved from the stream into v, and sets the failbit.
characters have been read and the Nth character is not the string terminator, then the failbit of the stream will be set. In either case, the string will be terminated with a null byte. virtual RWvistream& getString(wchar_t* ws, size_t N) = 0; Restores a wide character string from the input stream that was stored to the output stream with RWvostream::putstring and stores it in the array beginning at ws. The function stops reading at the end of the string or after N-1 characters, whichever comes first.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWvostream RWvostream RWvios ● Synopsis ● Description ● Persistence ● Example ● Public Destructor ● Public Operators ● Public Member Functions Synopsis #include Description Class RWvostream is an abstract base class. It provides an interface for format-independent storage of fundamental types and arrays of fundamental types.
appropriate for the final output sink. The model is one where variables are inserted into the output stream, either individually or as homogeneous vectors, to be restored in the same order using RWvistream. Storage and retrieval of characters requires some explanation. Characters can be thought of as either representing some alphanumeric or control character, or as the literal number.
operator<<(const wchar_t* ws) = 0; Store the wide character string starting at ws to the output stream. The character string is expected to be null terminated. virtual RWvostream& operator<<(char c) = 0; Store the char c to the output stream. Note that c is treated as a character, not a number. virtual RWvostream& operator<<(wchar_t wc) = 0; Store the wchar_t wc to the output stream. Note that wc is treated as a character, not a number.
virtual RWvostream& operator<<(unsigned short s) = 0; Store the unsigned short s to the output stream. operator void*(); Inherited from RWvios. Public Member Functions virtual RWvostream& flush(); Send the contents of the stream buffer to output immediately. virtual RWvostream& put(char c) = 0; Store the char c to the output stream, preserving its value. virtual RWvostream& put(wchar_t wc) = 0; Store the wchar_t wc to the output stream, preserving its value.
put(const unsigned short* p, size_t N) = 0; Store the vector of N unsigned shorts starting at p to the output stream. virtual RWvostream& put(const int* p, size_t N) = 0; Store the vector of N ints starting at p to the output stream. virtual RWvostream& put(const unsigned int* p, size_t N) = 0; Store the vector of N unsigned ints starting at p to the output stream. virtual RWvostream& put(const long* p, size_t N) = 0; Store the vector of N longs starting at p to the output stream.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWWString ● Synopsis ● Description ● Persistence ● Example ● Enumerations ● Public Constructors ● Type Conversion ● Assignment Operators ● Indexing Operators ● Public Member Functions ● Static Public Member Functions ● Related Global Operators ● Related Global Functions Synopsis #include
assignment operators still reference the old object and hence are very fast. An actual copy is made only when a "write" is performed, that is if the object is about to be changed. The net result is excellent performance, but with easy-to-understand copy semantics. A separate RWWSubString class supports substring extraction and modification operations. Persistence Simple Example #include #include main(){ RWWString a(L"There is no joy in Beantown"); a.
resizing) is given by the parameter ic. RWWString(const RWWString& str); Copy constructor. The created string will copy str's data. RWWString(const RWWSubString& ss); Conversion from sub-string. The created string will copy the substring represented by ss. RWWString(char c); Constructs a string containing the single character c. RWWString(char c, size_t N); Constructs a string containing the character c repeated N times.
operator=(const RWWSubString& sub); Assignment operator. The string will copy sub's data. Returns a reference to self. RWWString& operator+=(const wchar_t* cs); Append the null-terminated character string pointed to by cs to self. Returns a reference to self. RWWString& operator+=(const RWWString& str); Append the string str to self. Returns a reference to self. Indexing Operators wchar_t& operator[](size_t i); wchar_t operator[](size_t i) const; Return the ith character.
append(const RWWString& cstr); Append a copy of the string cstr to self. Returns a reference to self. RWWString& append(const RWWString& cstr, size_t N); Append the first N characters or the length of cstr (whichever is less) of cstr to self. Returns a reference to self. size_t binaryStoreSize() const; Returns the number of bytes necessary to store the object using the global function: RWFile& operator<<(RWFile&, const RWWString&); size_t capacity() const; Return the current capacity of self.
first(wchar_t c) const; Returns the index of the first occurrence of the wide character c in self. Returns RW_NPOS if there is no such character or if there is an embedded null prior to finding c. size_t first(wchar_t c, size_t) const; Returns the index of the first occurrence of the wide character c in self. Continues to search past embedded nulls. Returns RW_NPOS if there is no such character.
insert(size_t pos, const RWWString& str); Insert a copy of the string str into self at position pos. Returns a reference to self. RWWString& insert(size_t pos, const RWWString& str, size_t N); Insert a copy of the first N wide characters or the length of str (whichever is less) of str into self at position pos. Returns a reference to self. RWBoolean isAscii() const; Returns TRUE if it is safe to perform the conversion toAscii() (that is, if all characters of self are ASCII characters).
Reads characters from the input stream s, replacing the previous contents of self, until a newline (or an EOF) is encountered. The newline is removed from the input stream but is not stored. The input stream is treated as a sequence of multibyte characters, each of which is converted to a wide character (using the Standard C library function mbtowc()) before storing. Null characters are treated the same as other characters.
RWWString& replace(size_t pos, size_t N1, const RWWString& str, size_t N2); Replaces N1 characters or to the end of string (whichever comes first) starting at position pos, which must be no greater than length(), with a copy of the first N2 characters, or the length of str (whichever is less), from str. Returns a reference to self. void resize(size_t n); Changes the length of self, adding blanks (i.e., L' ') or truncating as necessary.
Static Public Member Functions static unsigned hash(const RWWString& wstr); Returns the hash value of wstr as returned by wstr.hash(RWWString::exact). static size_t initialCapacity(size_t ic = 15); Sets the minimum initial capacity of an RWWString, and returns the old value. The initial setting is 15 wide characters. Larger values will use more memory, but result in fewer resizes when concatenating or reading strings. Smaller values will waste less memory, but result in more resizes.
RWBoolean operator<=(const RWBoolean operator<=(const RWBoolean operator>=(const RWBoolean operator>=(const RWBoolean operator>=(const wchar_t*, const RWWString&); RWWString&, const RWWString&); RWWString&, const wchar_t* wchar_t*, ); const RWWString&); RWWString&, const RWWString&); Comparisons are done lexicographically, byte by byte. Case sensitivity is exact. Use member collate() or strxfrm() for locale sensitivity.
RWWString toUpper(const RWWString& str); Returns a version of str where all lower-case characters have been replaced with upper-case characters. Uses the C library function towupper().
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWWSubString ● Synopsis ● Description ● Persistence ● Example ● Assignment Operators ● Indexing Operators ● Public Member Functions ● Global Logical Operators Synopsis #include RWWString s(L"test string"); s(6,3); // "tri" Description The class RWWSubString allows some subsection of an RWWString to be addressed by defining a starting position and an extent.
Persistence None Example #include #include main(){ RWWString // Create s(15,0) = cout << s return 0; } s(L"What I tell you is true."); a substring and use it as an lvalue: RWWString(L" three times"); << endl; Program output: What I tell you three times is true. Assignment Operators void operator=(const RWWString&); Assignment from an RWWString. The statements: RWWString a; RWWString b; ... b(2, 3) = a; will copy a's data into the substring b(2,3).
Indexing Operators wchar_t operator[](size_t i); wchar_t& operator[](size_t i) const; Returns the ith character of the substring. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the length of the substring less one. Bounds checking is performed: if the index is out of range, then an exception of type RWBoundsErr will be thrown. wchar_t operator()(size_t i); wchar_t& operator()(size_t i) const; Returns the ith character of the substring.
void toUpper(); Changes all lower-case letters in self to upper-case. Uses the C library function towupper().
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWWTokenizer ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Member Function Synopsis #include RWWString str("a string of tokens", RWWString::ascii); RWWTokenizer(str); // Lex the above string Description Class RWWTokenizer is designed to break a string up into separate tokens, delimited by arbitrary "white space.
RWWTokenizer next(a); // Tokenize the string a RWWString token; // Will receive each token // Advance until the null string is returned: while (!(token=next()).isNull()) cout << token << "\n"; } Program output: Something is rotten in the state of Denmark Public Constructor RWWTokenizer(const RWWString& s); Construct a tokenizer to lex the string s. Public Member Function RWWSubString operator(); Advance to the next token and return it as a substring.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWXDRistream (Unix only) RWvistream RWvios RWXDRistream RWios ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Destructor ● Public Member Functions Synopsis #include XDR xdr; xdrstdio_create(&xdr, stdin, XDR_DECODE); RWXDRistream rw_xdr(&xdr); Description Class RWXDRistream is a portable input stream based on XDR routines.
An XDR stream must first be created by calling the appropriate creation routine. XDR streams currently exist for encoding/decoding of data to or from standard iostreams and file streams, TCP/IP connections and Unix files, and memory. These creation routines take arguments that are tailored to the specific properties of the stream. After the XDR stream has been created, it can then be used as the argument to the constructor for a RWXDRistream object.
Public Constructor RWXDRistream(XDR* xp); Initialize an RWXDRistream from the XDR structure xp. RWXDristream(streambuf*); Initialize RWXDRistream with a pointer to streambuf. Streambuf must be already allocated. RWXDRistream(istream&); Initialize RWXDRistream with an input stream. Public Destructor ~virtual RWXDRistream(); Deallocate previously allocated resources. Public Member Functions virtual int get(); Redefined from class RWvistream. Gets and returns the next character from the XDR input stream.
stream and stores them in v. If the operation fails, it sets the failbit. virtual RWvistream& get(unsigned char* v, size_t N); Redefined from class RWvistream. Gets a vector of N unsigned characters from the XDR input stream and stores them in v. If the operation fails, it sets the failbit. virtual RWvistream& get(double* v, size_t N); Redefined from class RWvistream. Gets a vector of N doubles from the XDR input stream and stores them in v. If the operation fails, it sets the failbit.
input stream and stores them in v. If the operation fails, it sets the failbit. virtual RWvistream& get(wchar_t* v, size_t N); Redefined from class RWvistream. Gets a vector of N wide characters from the XDR input stream and stores them in v. If the operation fails, it sets the failbit. virtual RWvistream& getString(char* s, size_t maxlen); Redefined from class RWvistream.
stores it in s. If the operation fails, it sets the failbit. virtual RWvistream& operator>>(wchar_t& wc); Redefined from class RWvistream. Gets the next wide character from the XDR input stream and stores it in wc. If the operation fails, it sets the failbit. virtual RWvistream& operator>>(unsigned char& c); Redefined from class RWvistream. Gets the next unsigned character from the XDR input stream and stores it in c. If the operation fails, it sets the failbit.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWXDRostream (Unix only) RWvostream RWvios RWXDRostream RWios ● Synopsis ● Description ● Persistence ● Example ● Public Constructor ● Public Destructor ● Public Member Functions Synopsis #include XDR xdr; xdrstdio_create(&xdr, stdout, XDR_ENCODE) ; RWXDRostream rw_xdr(&xdr); Description Class RWXDRostream is a portable output stream based on XDR routines.
An XDR stream must first be created by calling the appropriate creation routine. XDR streams currently exist for encoding/decoding of data to or from standard iostreams and file streams, TCP/IP connections and Unix files, and memory. These creation routines take arguments that are tailored to the specific properties of the stream. After the XDR stream has been created, it can then be used as an argument to the constructor for a RWXDRostream object.
Initialize RWXDRostream with an output stream. Public Destructor virtual ~RWXDRostream(); Deallocate previously allocated resources. Public Member Functions virtual RWvostream& operator<<(const char* s); Redefined from class RWvostream. Store the character string starting at s to the output stream using the XDR format. The character string is expected to be null terminated. virtual RWvostream& operator<<(char c); Redefined from class RWvostream.
XDR format. virtual RWvostream& operator<<(unsigned int i); Redefined from class RWvostream. Store the unsigned integer i to the output stream using the XDR format. virtual RWvostream& operator<<(long l); Redefined from class RWvostream. Store the long l to the output stream using the XDR format. virtual RWvostream& operator<<(unsigned long l); Redefined from class RWvostream. Store the unsigned long l to the output stream using the XDR format.
Redefined from class RWvostream. Store the vector of N characters starting at p to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& put(const wchar_t* p, size_t N); Redefined from class RWvostream. Store the vector of N wide characters starting at p to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& put(const short* p, size_t N); Redefined from class RWvostream.
Redefined from class RWvostream. Store the vector of N doubles starting at p to the output stream using the XDR format. If the operation fails, it sets the failbit. Virtual RWXDRostream& flush(); Send the contents of the stream buffer to output immediately. Virtual RWXDRostream& putString(const char*s, size_t N); Store the character string for retrieval by RWXDRistream::getString.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWZone ● Synopsis ● Description ● Persistence ● Example ● Enumerations ● Public Member Functions ● Static Public Member Functions Synopsis #include #include (abstract base class) Description RWZone is an abstract base class.
RWZone::utc(), respectively. See the class RWZoneSimple for details. Persistence None Example #include #include #include main(){ RWTime now; cout << now.asString('\0', RWZone::local()) << endl; cout << now.asString("%x %X", RWZone::utc()) << endl; return 0; } Enumerations enum DstRule { NoDST, NoAm, WeEu }; Used by the static member function dstRule(), described below, and by constructors for classes derived from RWZone.
is negative for zones east of Greenwich, England. virtual int altZoneOffset() const = 0; Returns the number of seconds west of UTC for daylight-saving time in this zone. virtual RWBoolean daylightObserved() const = 0; Returns TRUE if daylight-saving time is observed for this zone. virtual RWBoolean isDaylight(const struct tm* tspec) const = 0; Returns TRUE if the time and date represented in the struct tm argument is in the range of daylight-saving time for this zone.
Returns a reference to an RWZone representing standard local time, with no daylight-saving time corrections. By default this is an instance of RWZoneSimple with offset and zone name from the operating system. static const RWZone& utc(); Returns a reference to an RWZone representing UTC (GMT) universal time. static const RWZone* local(const RWZone*); static const RWZone* standard(const RWZone*); These functions allow the values returned by the other functions above to be set. Each returns the previous value.
Click on the banner to return to the Class Reference home page. ©Copyright 1996 Rogue Wave Software RWZoneSimple RWZoneSimple RWZone ● Synopsis ● Description ● Persistence ● Examples ● Constructors ● struct RWDaylightRule ● struct RWDaylight-Boundary Synopsis #include #include RWZoneSimple myZone(USCentral); Description RWZoneSimple is an implementation of the abstract interface defined by class RWZone.
all, then the local zone instance will use U.S. (RWZone::NoAm) daylight-saving time rules. Note for developers outside North America: for some time zones this default will not be correct because these time zones rely on the C standard global variable _daylight. This variable is set whenever any alternate time zone rule is available, whether it represents daylight-saving time or not.
// last Sun in Apr to last in Oct const RWDaylightRule usRule76 = { &usRule75, 1976, 1, { 3, 4, 0, 120 }, { 9, 4, 0, 120 } }; // first Sun in Apr to last in Oct const RWDaylightRule usRuleLate = { &usRule76, 1987, 1, { 3, 0, 0, 120 }, { 9, 4, 0, 120 } }; // last Sun in Mar to last in Sep const RWDaylightRule euRuleLate = { 0, 0000, 1, { 2, 4, 0, 120 }, { 8, 4, 0, 120 } }; Given these definitions, RWZone::local(new RWZoneSimple(RWZone::USCentral, &usRuleLate)); is equivalent to the first example given above
Constructs an RWZoneSimple instance in which daylight-saving time is not observed. Argument tzoff is the offset from UTC (in seconds, positive if west of 0 degrees longitude) and tzname is the name of the zone. RWZoneSimple(RWZone::StdZone zone, const RWDaylightRule* rule); Constructs an RWZoneSimple instance in which offsets and names are specified by the StdZone argument. Daylight-saving time is computed according to the rule argument, if non-zero; otherwise, DST is not observed.
(See RWDaylightBoundary below.) RWDaylightBoundary end_; This structure indicates the time of year, to the minute, when standard time resumes during this period. (See RWDaylightBoundary below.) struct RWDaylight-Boundary struct RWExport RWDaylightBoundary { // this struct uses struct tm conventions: int month_; // [0..11] int week_; // [0..4], or -1 int weekday_; // [0..6], 0=Sunday; or, [1..31] if week_== -1 int minute_; // [0..
©Copyright 1996 Rogue Wave Software Tools.h++ 7.0 Class Reference Appendix A: Alternate Template Class Interfaces If you do not have the Standard C++ Library, use the template class interfaces described in this Appendix. If you do have the Standard C++ Library use the interfaces described in the main section of the Class Reference.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrDlist Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions ● Related Global Operators Synopsis #include
● well-defined equality semantics (T::operator==(const T&)). Persistence Isomorphic Example In this example, a doubly-linked list of pointers to the user type Dog is exercised. Contrast this approach with the example given under RWTValDlist. #include #include #include
main() { RWTPtrDlist terriers; terriers.insert(new Dog("Cairn Terrier")); terriers.insert(new Dog("Irish Terrier")); terriers.insert(new Dog("Schnauzer")); Dog key1("Schnauzer"); cout << "The list " << (terriers.contains(&key1) ? "does " : "does not ") << "contain a Schnauzer\n"; Dog key2("Irish Terrier"); terriers.insertAt( terriers.index(&key2), new Dog("Fox Terrier") ); Dog* d; while (!terriers.isEmpty()) { d = terriers.
Sets self to a shallow copy of c. Afterwards, pointers will be shared between the two collections. T*& operator[](size_t i); T* const& operator[](size_t i) const; Returns a pointer to the ith value in the list. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the number of items in the collection less one, or an exception of type RWBoundsError will be thrown.
by testFun returns TRUE . Returns FALSE otherwise. The tester function must have the prototype: RWBoolean yourTester(T*, void* d); This function will be called for each item in the list, with a pointer to the item as the first argument. Client data may be passed through as parameter d. size_t entries() const; Returns the number of items that are currently in the collection.
This function will be called for each item in the list, with a pointer to the item as the first argument. Client data may be passed through as parameter d. void insert(T* a); Adds the object pointed to by a to the end of the list. void insertAt(size_t i, T* a); Adds the object pointed to by a at the index position i. This position must be between zero and the number of items in the list, or an exception of type RWBoundsError will be thrown.
TRUE and returns a pointer to it, or nil if there is no such object. The tester function must have the prototype: RWBoolean yourTester(T*, void* d); This function will be called for each item in the list, with a pointer to the item as the first argument. Client data may be passed through as parameter d. size_t removeAll(const T* a); Removes all objects which are equal to the object pointed to by a. Returns the number of objects removed. Equality is measured by the class-defined equality operator for type T.
operator>>(RWFile& strm, RWTPtrDlist& coll); Restores the contents of the collection coll from the input stream strm. RWvistream& operator>>(RWvistream& strm, RWTPtrDlist*& p); RWFile& operator>>(RWFile& strm, RWTPtrDlist*& p); Looks at the next object on the input stream strm and either creates a new collection off the heap and sets p to point to it, or sets p to point to a previously read instance. If a collection is created off the heap, then you are responsible for deleting it.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrDlistIterator Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Public Constructor ● Public Member Operators ● Public Member Functions Synopsis #include
it will bring undefined results. Persistence None Public Constructor RWTPtrDlistIterator(RWTPtrDlist& c); Constructs an iterator to be used with the list c. Public Member Operators RWBoolean operator++(); Advances the iterator to the next item and returns TRUE. When the end of the collection is reached, returns FALSE and the position of the iterator will be undefined. RWBoolean operator--(); Retreats the iterator to the previous item and returns TRUE.
pointer to it. If no item is found, returns nil and the position of the iterator will be undefined. Equality is measured by the class-defined equality operator for type T. T* findNext(RWBoolean (*testFun)(T*, void*), void*); Advances the iterator to the first element for which the tester function pointed to by testFun returns TRUE and returns a pointer to it. If no item is found, returns nil and the position of the iterator will be undefined.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashDictionary Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions Synopsis #include
Parameters K and V represent the type of the key and the type of the value, respectively, to be inserted into the table. These can be either classes or fundamental types. Class K must have ● well-defined equality semantics (K::operator==(const K&)). Class V can be of any type. A user-supplied hashing function for type K must be supplied to the constructor when creating a new table.
// Alternative syntax: birthdays[new RWCString("Susan")] = new RWDate(30, "June", 1955); birthdays[new RWCString("Gene")] = new RWDate(5, "Jan", 1981); // Print a birthday: RWCString key("John"); cout << *birthdays[&key] << endl; birthdays.clearAndDestroy(); return 0; } Program output: April 12, 1975 Public Constructors RWTPtrHashDictionary(unsigned (*hashKey)(const K&), size_t buckets = RWDEFAULT_CAPACITY); Constructs an empty hash dictionary.
Public Member Functions void applyToKeyAndValue( void (*applyFun)(K*,V*&,void*),void* d); Applies the user-defined function pointed to by applyFun to every key-value pair in the dictionary. This function must have prototype: void yourFun(K* key, V*& value, void* d); This function will be called for each key value pair in the dictionary, with a pointer to the key as the first argument and a reference to a pointer to the value as the second argument. The key should not be changed or touched.
If the key pointed to by key is in the dictionary, then its associated value is changed to value. Otherwise, a new key value pair is inserted into the dictionary. RWBoolean isEmpty() const; Returns TRUE if the dictionary has no items in it, FALSE otherwise. K* remove(const K* key); Removes the key and value pair where the key is equal to the key pointed to by key. Returns the key or nil if no match was found. Equality is measured by the class-defined equality operator for type K.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashDictionaryIterator Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Public Constructor ● Public Operators ● Public Member Functions Synopsis #include
Once the iterator has advanced beyond the end of the collection it is no longer valid -- continuing to use it will bring undefined results. Persistence None Public Constructor RWTPtrHashDictionaryIterator(RWTPtrHashDictionary& c); Constructs an iterator to be used with the dictionary c. Public Operators RWBoolean operator++(); Advances the iterator to the next key-value pair and returns TRUE. When the end of the collection is reached, returns FALSE and the position of the iterator will be undefined.
iterator is no longer valid.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashSet Alternate template: Standard C++ Library not required RWTPtrHashSet ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructor ● Public Member Functions RWTPtrHashTable Synopsis #include
As with class RWTPtrHashTable, you must supply a hashing function to the constructor. The class T must have: ● well-defined equality semantics (T::operator==(const T&)). Persistence None Example This examples exercises a set of RWCStrings. #include #include #include main() { RWTPtrHashSet set(RWCString::hash); set.insert(new set.insert(new set.insert(new set.
RWTPtrHashSet& difference(const RWTPtrHashSet& h); Computes the disjunction of self and h, modifying self and returning self. RWTPtrHashSet& intersection(const RWTPtrHashSet& h); Computes the intersection of self and h, modifying self and returning self. RWTPtrHashSet& symmetricDifference(const RWTPtrHashSet& h); Computes the symmetric difference between self and h, modifying self and returning self.
find(const T* target) const; Inherited from class RWTPtrHashTable. void insert(T* a); Redefined from class RWTPtrHashTable to allow an object of a given value to be inserted only once. RWBoolean isEmpty() const; Inherited from class RWTPtrHashTable. size_t occurrencesOf(const T* a) const; Inherited from class RWTPtrHashTable. T* remove(const T* a); Inherited from class RWTPtrHashTable. size_t removeAll(const T* a); Inherited from class RWTPtrHashTable.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashTable Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions Synopsis #include
can be changed by calling member function resize(). This is relatively expensive because all of the keys must be rehashed. If you wish for this to be done automatically, then you can subclass from this class and implement your own special insert() and remove() functions which perform a resize() as necessary. Persistence None Example #include #include #include
RWTPtrHashTable(const RWTPtrHashTable& c); Constructs a new hash table as a shallow copy of c. After construction, pointers will be shared between the two collections. The new object will have the same number of buckets as c. Hence, the keys will not be rehashed. Public Operators RWTPtrHashTable& operator=(const RWTPtrHashTable& c); Sets self to a shallow copy of c. Afterwards, pointers will be shared between the two collections and self will have the same number of buckets as c.
Removes all items from the collection. void clearAndDestroy(); Removes all items from the collection and deletes them. RWBoolean contains(const T* p) const; Returns TRUE if the collection contains an item which is equal to the item pointed to by p. Returns FALSE otherwise. Equality is measured by the class-defined equality operator for type T. size_t entries() const; Returns the number of items currently in the collection.
Returns TRUE if the collection has no items in it, FALSE otherwise. size_t occurrencesOf(const T* a) const; Returns the number of objects in the collection which are equal to the object pointed to by a. Equality is measured by the class-defined equality operator for type T. T* remove(const T* a); Removes the object which is equal to the object pointed to by a and returns a pointer to it, or nil if no such object could be found. Equality is measured by the class-defined equality operator for type T.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrHashTableIterator Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Public Constructor ● Public Operators ● Public Member Functions Synopsis #include
it will bring undefined results. Persistence None Public Constructor RWTPtrHashTableIterator(RWTPtrHashTable& c); Constructs an iterator to be used with the table c. Public Operators RWBoolean operator++(); Advances the iterator to the next item and returns TRUE. When the end of the collection is reached, returns FALSE and the position of the iterator will be undefined. T* operator()(); Advances the iterator to the next item and returns a pointer to it.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrOrderedVector Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions ● Related Global Operators Synopsis #include
RWTPtrOrderedVector vec; vec.insert(new vec.insert(new vec.insert(new vec.insert(new vec.insert(new double(22.0)); double(5.3)); double(-102.5)); double(15.0)); double(5.3)); cout << vec.entries() << " entries\n" << endl; for (int i=0; i
T*& operator()(size_t i); T* const& operator()(size_t i) const; Returns a pointer to the ith value in the vector. The first variant can be used as an lvalue, the second cannot. The index i must be between zero and the number of items in the collection less one. No bounds checking is performed. T*& operator[](size_t i); T* const& operator[](size_t i) const; Returns a pointer to the ith value in the vector. The first variant can be used as an lvalue, the second cannot.
Removes all items from the collection. void clearAndDestroy(); Removes all items from the collection and deletes them. RWBoolean contains(const T* a) const; Returns TRUE if the collection contains an item that is equal to the object pointed to by a, FALSE otherwise. A linear search is done. Equality is measured by the class-defined equality operator for type T. T* const * data() const; Returns a pointer to the raw data of the vector. Should be used with care. The contents should not be changed.
T* const& first() const; Returns a pointer to the first item in the vector. RWBoundsError will occur if the vector is empty. An exception of type size_t index(const T* a) const; Performs a linear search, returning the index of the first object that is equal to the object pointed to by a, or RW_NPOS if there is no such object. Equality is measured by the class-defined equality operator for type T. void insert(T* a); Adds the object pointed to by a to the end of the vector.
Returns a pointer to the last item in the collection. If there are no items in the collection then an exception of type RWBoundsError will occur. size_t length() const; Returns the number of items currently in the collection. size_t occurrencesOf(const T* a) const; Performs a linear search, returning the number of objects in the collection that are equal to the object pointed to by a. Equality is measured by the class-defined equality operator for type T.
T* removeAt(size_t i); Removes the object at index i and returns a pointer to it. An exception of type RWBoundsError will be thrown if i is not a valid index. Valid indices are from zero to the number of items in the list less one. T* removeFirst(); Removes the first item in the collection and returns a pointer to it. of type RWBoundsError will be thrown if the list is empty. An exception T* removeLast(); Removes the last item in the collection and returns a pointer to it.
RWvistream& operator>>(RWvistream& strm, RWTPtrOrderedVector& coll); RWFile& operator>>(RWFile& strm, RWTPtrOrderedVector& coll); Restores the contents of the collection coll from the input stream strm.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrSlist Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions ● Related Global Operators Synopsis #include
● well-defined equality semantics (T::operator==(const T&)). Persistence Isomorphic Example In this example, a singly-linked list of RWDates is exercised. #include #include #include main() { RWTPtrSlist dates; dates.insert(new RWDate(2, "June", 52)); dates.insert(new RWDate(30, "March", 46)); dates.insert(new RWDate(1, "April", 90)); // Now look for one of the dates: RWDate key(2, "June", 52); RWDate* d = dates.
Constructs a new singly-linked list as a shallow copy of c. After construction, pointers will be shared between the two collections. Public Operators RWTPtrSlist& operator=(const RWTPtrSlist& c); Sets self to a shallow copy of c. Afterwards, pointers will be shared between the two collections. T*& operator[](size_t i); T* const& operator[](size_t i) const; Returns a pointer to the ith value in the list. The first variant can be used as an lvalue, the second cannot.
RWBoolean contains(const T* a) const; Returns TRUE if the list contains an object that is equal to the object pointed to by a, FALSE otherwise. Equality is measured by the class-defined equality operator for type T. RWBoolean contains(RWBoolean (*testFun)(T*, void*),void* d) const; Returns TRUE if the list contains an item for which the user-defined "tester" function pointed to by testFun returns TRUE . Returns FALSE otherwise.
there is no such object. Equality is measured by the class-defined equality operator for type T. size_t index(RWBoolean (*testFun)(T*, void*),void* d) const; Returns the index of the first object for which the user-defined tester function pointed to by testFun returns TRUE, or RW_NPOS if there is no such object. The tester function must have the prototype: RWBoolean yourTester(T*, void* d); This function will be called for each item in the list, with a pointer to the item as the first argument.
T* remove(const T* a); Removes the first object which is equal to the object pointed to by a and returns a pointer to it, or nil if no such object could be found. Equality is measured by the class-defined equality operator for type T. T* remove(RWBoolean (*testFun)(T*, void*),void* d); Removes the first object for which the user-defined tester function pointed to by testFun returns TRUE and returns a pointer to it, or nil if there is no such object.
Related Global Operators RWvostream& operator<<(RWvostream& strm, const RWTPtrSlist& coll); RWFile& operator<<(RWFile& strm, const RWTPtrSlist& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved. RWvistream& operator>>(RWvistream& strm, RWTPtrSlist& coll); RWFile& operator>>(RWFile& strm, RWTPtrSlist& coll); Restores the contents of the collection coll from the input stream strm.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrSlistIterator Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Public Constructor ● Public Member Operators ● Public Member Functions Synopsis #include
it will bring undefined results. Persistence None Public Constructor RWTPtrSlistIterator(RWTPtrSlist& c); Constructs an iterator to be used with the list c. Public Member Operators RWBoolean operator++(); Advances the iterator to the next item and returns TRUE. When the end of the collection is reached, returns FALSE and the position of the iterator will be undefined. RWBoolean operator+=(size_t n); Advances the iterator n positions and returns TRUE.
Inserts the object pointed to by a into the iterator's associated collection in the position immediately after the iterator's current position which remains unchanged. T* key() const; Returns a pointer to the object at the iterator's current position. The results are undefined if the iterator is no longer valid. T* remove(); Removes and returns the object at the iterator's current position from the iterator's associated collection.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTPtrSortedVector Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructor ● Public Operators ● Public Member Functions ● Related Global Operators Synopsis #include
Stores a pointer to the inserted item into the collection according to an ordering determined by the less-than (<) operator.
September 1, 1991 Public Constructor RWTPtrSortedVector(size_t capac = RWDEFAULT_CAPACITY); Create an empty sorted vector with an initial capacity equal to capac. The vector will be automatically resized should the number of items exceed this amount. RWTPtrSortedVector(const RWTPtrSortedVector& c); Constructs a new ordered vector as a shallow copy of c. After construction, pointers will be shared between the two collections.
void clear(); Removes all items from the collection. void clearAndDestroy(); Removes all items from the collection and deletes them. RWBoolean contains(const T* a) const; Returns TRUE if the collection contains an item that is equal to the object pointed to by a, FALSE otherwise. A binary search is done. Equality is measured by the class-defined equality operator for type T. T* const * data() const; Returns a pointer to the raw data of the vector. The contents should not be changed.
Returns TRUE if there are no items in the collection, FALSE otherwise. T* const& last() const; Returns a pointer to the last item in the collection. If there are no items in the collection then an exception of type RWBoundsError will occur. size_t length() const; Returns the number of items currently in the collection. size_t occurrencesOf(const T* a) const; Performs a binary search, returning the number of items that are equal to the object pointed to by a.
Related Global Operators RWvostream& operator<<(RWvostream& strm, const RWTPtrSortedVector& coll); RWFile& operator<<(RWFile& strm, const RWTPtrSortedVector& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved. RWvistream& operator>>(RWvistream& strm, RWTPtrSortedVector& coll); RWFile& operator>>(RWFile& strm, RWTPtrSortedVector& coll); Restores the contents of the collection coll from the input stream strm.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValDlist Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions ● Related Global Operators Synopsis #include
Parameter T represents the type of object to be inserted into the list, either a class or fundamental type. The class T must have: ● A default constructor; ● well-defined copy semantics (T::T(const T&) or equivalent); ● well-defined assignment semantics (T::operator=(const T&) or equivalent); ● well-defined equality semantics (T::operator==(const T&)). Persistence Isomorphic Example In this example, a doubly-linked list of user type Dog is exercised. #include #include
friend ostream& operator<<(ostream& str, const Dog& dog){ str << dog.name; return str;} }; main() { RWTValDlist terriers; terriers.insert("Cairn Terrier"); terriers.insert("Irish Terrier"); terriers.insert("Schnauzer"); // automatic type conversion cout << "The list " << (terriers.contains("Schnauzer") ? "does ":"does not ") << "contain a Schnauzer\n"; terriers.insertAt( terriers.index("Irish Terrier"), "Fox Terrier" ); while (!terriers.isEmpty()) cout << terriers.
Public Operators RWTValDlist& operator=(const RWTValDlist& list); Sets self to a copy of the list list. Depending on the nature of the copy constructor of T, this could be relatively expensive because every item in the list must be copied. T& operator[](size_t i); Returns a reference to the item at index i. The results can be used as an lvalue. An exception of type RWBoundsError will be thrown if i is not a valid index. Valid indices are from zero to the number of items in the list less one.
RWBoolean contains(const T& a) const; Returns TRUE if the list contains an object that is equal to the object a. Returns FALSE otherwise. Equality is measured by the class-defined equality operator. RWBoolean contains(RWBoolean (*testFun)(const T&, void*),void* d) const; Returns TRUE if the list contains an item for which the user-defined "tester" function pointed to by testFun returns TRUE . Returns FALSE otherwise.
Returns and removes the first item in the list. The behavior is undefined if the list is empty. size_t index(const T& a); Returns the index of the first object that is equal to the object a, or RW_NPOS if there is no such object. Equality is measured by the class-defined equality operator.
For each item in the list this function will be called with the item as the first argument. Client data may be passed through as parameter d. void prepend(const T& a); Adds the item a to the beginning of the list. RWBoolean remove(const T& a); Removes the first object which is equal to the object a and returns TRUE. Returns FALSE if there is no such object. Equality is measured by the class-defined equality operator.
Related Global Operators RWvostream& operator<<(RWvostream& strm, const RWTValDlist& coll); RWFile& operator<<(RWFile& strm, const RWTValDlist& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved. RWvistream& operator>>(RWvistream& strm, RWTValDlist& coll); RWFile& operator>>(RWFile& strm, RWTValDlist& coll); Restores the contents of the collection coll from the input stream strm.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValDlistIterator Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Public Constructor ● Public Member Operators ● Public Member Functions Synopsis #include
it will bring undefined results. Persistence Isomorphic Public Constructor RWTValDlistIterator(RWTValDlist& c); Constructs an iterator to be used with the list c. Public Member Operators RWBoolean operator++(); Advances the iterator to the next item and returns TRUE. When the end of the collection is reached, returns FALSE and the position of the iterator will be undefined. RWBoolean operator--(); Retreats the iterator to the previous item and returns TRUE.
is no such element. Equality is measured by the class-defined equality operator for type T. RWBoolean findNext(RWBoolean (*testFun)(const T&, void*), void*); Advances the iterator to the first element for which the tester function pointed to by testFun returns TRUE and returns TRUE, or FALSE if there is no such element. void insertAfterPoint(const T& a); Inserts the value a into the iterator's associated collection in the position immediately after the iterator's current position.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValHashDictionary Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions Synopsis #include
● well-defined assignment semantics (T::operator=(const T&) or equivalent). In addition, class K must have ● well-defined equality semantics (K::operator==(const K&)). A user-supplied hashing function for type K must be supplied to the constructor when creating a new table. If K is a Rogue Wave class, then this requirement is usually trivial because most Rogue Wave objects know how to return a hashing value.
return 0; } Program output: April 12, 1975 Public Constructors RWTValHashDictionary(unsigned (*hashKey)(const K&), size_t buckets = RWDEFAULT_CAPACITY); Constructs a new hash dictionary. The first argument is a pointer to a user-defined hashing function for items of type K (the key). The table will initally have buckets buckets although this can be changed with member function resize(). RWTValHashDictionary(const RWTValHashDictionary& dict); Copy constructor.
RWBoolean contains(const K& key) const; Returns TRUE if the dictionary contains a key which is equal to key. Returns FALSE otherwise. Equality is measured by the class-defined equality operator for class K. size_t entries() const; Returns the number of key-value pairs currently in the dictionary. RWBoolean find(const K& target, K& retKey) const; Returns TRUE if the dictionary contains a key which is equal to target and puts the matching key into retKey. Returns FALSE otherwise and leaves retKey untouched.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValHashDictionaryIterator Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Public Constructor ● Public Operators ● Public Member Functions Synopsis #include
Once the iterator has advanced beyond the end of the collection it is no longer valid -- continuing to use it will bring undefined results. Persistence None Public Constructor RWTValHashDictionaryIterator(RWTValHashDictionary& c); Constructs an iterator to be used with the dictionary c. Public Operators RWBoolean operator++(); Advances the iterator one position. Returns TRUE if the new position is valid, FALSE otherwise. RWBoolean operator()(); Advances the iterator one position.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValHashSet Alternate template: Standard C++ Library not required RWTValHashSet ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Member Functions RWTValHashTable Synopsis #include
The class T must have: ● well-defined copy semantics (T::T(const T&) or equivalent); ● well-defined assignment semantics (T::operator=(const T&) or equivalent); ● well-defined equality semantics (T::operator==(const T&)). Persistence None Example This examples exercises a set of RWCStrings. #include #include #include main(){ RWTValHashSet set(RWCString::hash); set.insert("one"); set.insert("two"); set.insert("three"); set.
symmetricDifference(const RWTValHashSet& h); Computes the symmetric difference between self and h, modifying self and returning self. RWBoolean isSubsetOf(const RWTValHashSet& h) const; Returns TRUE if self is a subset of h. RWBoolean isProperSubsetOf(const RWTValHashSet& h) const; Returns TRUE if self is a proper subset of h. RWBoolean isEquivalent(const RWTValHashSet& h) const; Returns TRUE if self and h are identical.
remove(const T& val); Inherited from class RWTValHashTable. size_t removeAll(const T& val); Inherited from class RWTValHashTable. void resize(size_t N); Inherited from class RWTValHashTable.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValHashTable Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions Synopsis #include
type. The class T must have: ● well-defined copy semantics (T::T(const T&) or equivalent); ● well-defined assignment semantics (T::operator=(const T&) or equivalent); ● well-defined equality semantics (T::operator==(const T&)). A user-supplied hashing function for type T must be supplied to the constructor when creating a new table. If T is a Rogue Wave class, then this requirement is usually trivial because most Rogue Wave objects know how to return a hashing value.
table.removeAll("Oregon"); cout << "Now the table " << (table.contains("Oregon") ? "does " : "does not ") << "contain Oregon"; return 0; } Program output The table does contain Oregon Now the table does not contain Oregon Public Constructors RWTValHashTable(unsigned (*hashFun)(const T&), size_t buckets = RWDEFAULT_CAPACITY); Constructs a new hash table. The first argument is a pointer to a user-defined hashing function for items of type T.
Returns TRUE if the collection contains an item which is equal to val. Returns FALSE otherwise. Equality is measured by the class-defined equality operator. size_t entries() const; Returns the number of items currently in the collection. RWBoolean find(const T& target, T& k) const; Returns TRUE if the collection contains an item which is equal to target and puts the matching object into k. Returns FALSE otherwise and leaves k untouched. Equality is measured by the class-defined equality operator.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValHashTableIterator Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Public Constructor ● Public Operators ● Public Member Functions Synopsis #include
it will bring undefined results. Persistence None Public Constructor RWTValHashTableIterator(RWTValHashTable& c); Constructs an iterator to be used with the table c. Public Operators RWBoolean operator++(); Advances the iterator one position. Returns TRUE if the new position is valid, FALSE otherwise. RWBoolean operator()(); Advances the iterator one position. Returns TRUE if the new position is valid, FALSE otherwise.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValOrderedVector Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructor ● Public Operators ● Public Member Functions ● Related Global Operators Synopsis #include
The class T must have: ● well-defined copy semantics (T::T(const T&) or equivalent); ● well-defined assignment semantics (T::operator=(const T&) or equivalent); ● well-defined equality semantics (T::operator==(const T&)); ● a default constructor. Note that an ordered vector has a length (the number of items returned by length() or entries()) and a capacity. Necessarily, the capacity is always greater than or equal to the length.
Public Constructor RWTValOrderedVector(size_t capac=RWDEFAULT_CAPACITY); Create an empty ordered vector with capacity capac. Should the number of items exceed this value, the vector will be resized automatically. RWTValOrderedVector(const RWTValOrderedVector& c); Constructs a new ordered vector as a copy of c. The copy constructor of all elements in the vector will be called. The new vector will have the same capacity and number of members as the old vector.
RWBoundsError will be thrown. void clear(); Removes all items from the collection. RWBoolean contains(const T& a) const; Returns TRUE if the collection contains an item that is equal to a. A linear search is done. Equality is measured by the class-defined equality operator. const T* data() const; Returns a pointer to the raw data of the vector. The contents should not be changed. Should be used with care. size_t entries() const; Returns the number of items currently in the collection.
RWBoolean isEmpty() const; Returns TRUE if there are no items in the collection, FALSE otherwise. T& last(); const T& last() const; Returns the last item in the collection. If there are no items in the collection then an exception of type RWBoundsError will occur. size_t length() const; Returns the number of items currently in the collection. size_t occurrencesOf(const T& a) const; Performs a linear search, returning the number of items that are equal to a.
be thrown if the list is empty. void resize(size_t N); Changes the capacity of the collection to N. Note that the number of objects in the collection does not change, just the capacity. Related Global Operators RWvostream& operator<<(RWvostream& strm, const RWTValOrderedVector& coll); RWFile& operator<<(RWFile& strm, const RWTValOrderedVector& coll); Saves the collection coll onto the output stream strm, or a reference to it if it has already been saved.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValSlist Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructors ● Public Operators ● Public Member Functions ● Related Global Operators Synopsis #include
Parameter T represents the type of object to be inserted into the list, either a class or fundamental type. The class T must have: ● A default constructor; ● well-defined copy semantics (T::T(const T&) or equivalent); ● well-defined assignment semantics (T::operator=(const T&) or equivalent); ● well-defined equality semantics (T::operator==(const T&)). Persistence Isomorphic Example In this example, a singly-linked list of RWDates is exercised. #include #include
Public Constructors RWTValSlist(); Construct an empty list. RWTValSlist(const RWTValSlist& list); Construct a copy of the list list. Depending on the nature of the copy constructor of T, this could be relatively expensive because every item in the list must be copied. Public Operators RWTValSlist& operator=(const RWTValSlist& list); Sets self to a copy of the list list.
const T& at(size_t i) const; Returns a copy of the item at index i. The results cannot be used as an lvalue. An exception of type RWBoundsError will be thrown if i is not a valid index. Valid indices are from zero to the number of items in the list less one. void clear(); Removes all items from the list. Their destructors, if any, will be called. RWBoolean contains(const T& a) const; Returns TRUE if the list contains an object that is equal to the object a. Returns FALSE otherwise.
T& first(); const T& first() const; Returns but does not remove the first item in the list. The behavior is undefined if the list is empty. T get(); Returns and removes the first item in the list. The behavior is undefined if the list is empty. size_t index(const T& a); Returns the index of the first object that is equal to the object a, or RW_NPOS if there is no such object. Equality is measured by the class-defined equality operator.
the class-defined equality operator. size_t occurrencesOf(RWBoolean (*testFun)(const T&, void*),void* d) const; Returns the number of objects in the list for which the user-defined "tester" function pointed to by testFun returns TRUE . The tester function must have the prototype: RWBoolean yourTester(const T&, void* d); For each item in the list this function will be called with the item as the first argument. Client data may be passed through as parameter d.
T removeFirst(); Removes and returns the first item in the list. The behavior is undefined if the list is empty. T removeLast(); Removes and returns the last item in the list. The behavior is undefined if the list is empty. This function is relatively slow because removing the last link in a singly-linked list necessitates access to the next-to-the-last link, requiring the whole list to be searched.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValSlistIterator Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Public Constructor ● Public Member Operators ● Public Member Functions Synopsis #include
it will bring undefined results. Persistence None Public Constructor RWTValSlistIterator(RWTValSlist& c); Constructs an iterator to be used with the list c. Public Member Operators RWBoolean operator++(); Advances the iterator one position. Returns TRUE if the new position is valid, FALSE otherwise. RWBoolean operator+=(size_t n); Advances the iterator n positions. Returns TRUE if the new position is valid, FALSE otherwise. RWBoolean operator()(); Advances the iterator one position.
Returns the value at the iterator's current position. The results are undefined if the iterator is no longer valid. RWBoolean remove(); Removes the value from the iterator's associated collection at the current position of the iterator. Returns TRUE if successful, FALSE otherwise. Afterwards, if successful, the iterator will be positioned at the element immediately before the removed element. This function is relatively inefficient for a singly-linked list.
Click on the banner to return to the Class Reference home page. Return to the Appendix home page. ©Copyright 1996 Rogue Wave Software RWTValSortedVector Alternate template: Standard C++ Library not required ● Synopsis ● Please Note! ● Description ● Persistence ● Example ● Public Constructor ● Public Operators ● Public Member Functions ● Related Global Operators Synopsis #include
Stores a copy of the inserted item into the collection according to an ordering determined by the less-than (<) operator. The class T must have: ● well-defined copy semantics (T::T(const T&) or equivalent); ● well-defined assignment semantics (T::operator=(const T&) or equivalent); ● well-defined equality semantics (T::operator==(const T&)); ● well-defined less-than semantics (T::operator<(const T&)); ● a default constructor.
Program output May 14, 1999 June 2, 1999 August 9, 1999 August 10, 1999 September 1, 1999 September 1, 1999 Public Constructor RWTValSortedVector(size_t capac = RWDEFAULT_CAPACITY); Create an empty sorted vector with an initial capacity equal to capac. The vector will be automatically resized should the number of items exceed this amount. Public Operators T& operator()(size_t i); const T& operator()(size_t i) const; Returns the ith value in the vector.
clear(); Removes all items from the collection. RWBoolean contains(const T& a) const; Returns TRUE if the collection contains an item that is equal to a. A binary search is done. Equality is measured by the class-defined equality operator. const T* data() const; Returns a pointer to the raw data of the vector. The contents should not be changed. Should be used with care. size_t entries() const; Returns the number of items currently in the collection.
size_t length() const; Returns the number of items currently in the collection. size_t occurrencesOf(const T& a) const; Performs a binary search, returning the number of items that are equal to a. Equality is measured by the class-defined equality operator. RWBoolean remove(const T& a); Performs a binary search, removing the first object which is equal to the object a and returns TRUE. Returns FALSE if there is no such object. Equality is measured by the class-defined equality operator.
saved. RWvistream& operator>>(RWvistream& strm, RWTValSortedVector& coll); RWFile& operator>>(RWFile& strm, RWTValSortedVector& coll); Restores the contents of the collection coll from the input stream strm.
Click on the banner to return to the user guide home page. Licensing Statement The Rogue Wave single-user license for this product allows a single user on a single platform to link against the product library. A site license allows a specified number of users to link against the library. The fact that both the library and this documentation are easy to copy does not make it legal to do so.