quick start:g++ [flags ...] file ... #include <Set.h> Set(ALLOCATION alloc_d = DEF_ALLOCATION); boolean insert(TObject* item); boolean remove(); boolean contains(TObject* item); const TObject* getPrev() const;
description:// declare a character set and add two characters into it // Set<Char> set; Char item0(L'a'); Char item1(L'b'); set.insert(&item0); set.insert(&item1); // insert item0 again // set.insert(&item0); // the length should still be 2, since two items are identical // if (set.length() != 2) { // error }
static const String CLASS_NAME = L"Set";
static const long ERR = 42200;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
setDebug is inherited from the DoubleLinkedList class
boolean debug(const unichar* message) const;
~Set();
Set(ALLOCATION alloc = DEF_ALLOCATION);
Set(const Set<TObject>& copy_list);
boolean assign(const Set<TObject>& arg);
Set<TObject>& operator=(const Set<TObject>& arg);
equality methods are inherited from the DoubleLinkedList class
sofSize is inherited from the DoubleLinkedList class
boolean read(Sof& sof, long tag);
boolean write(Sof& sof, long tag) const;
boolean read(Sof& sof, long tag, const String& name);
boolean write(Sof& sof, long tag, const String& name) const;
boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param_a = true, boolean nested_a = false);
boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;
static void* operator new(size_t size);
static void* operator new[](size_t size);
static void operator delete(void* ptr);
static void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
clear is inherited from the DoubleLinkedList class
const TObject& operator() (long index) const;
const TObject* getFirst() const;
const TObject* getLast() const;
const TObject* getNext() const;
const TObject* getPrev() const;
const TObject* getMark() const;
const TObject* getCurr() const;
boolean insert(TObject* item);
boolean find(const TObject* item);
boolean contains(const TObject* item) const;
boolean sort(Integral::ORDER sort_order = Integral::ASCENDING, SORT_ALGO = DEF_SORT_ALGO);
boolean reverse();
boolean swap(long i, long j);
boolean insertFirst(TObject* item);
boolean insertFirst(Set& item_list);
boolean insertLast(TObject* item);
boolean insertLast(Set<TObject>& item_list);
boolean apply(boolean (TObject::*method)());
boolean apply(boolean (TObject::*method)(), Set<TObject>& arg);
friend class SetDiagnose;examples:
#include <Set.h> #include <Char.h> int main() { // local variables // Set<Long> d; Long j; // add 10 unique items to the Set // for (long i = 0; i< 10; i++) { j = i * 3; d.insert(&j); } // see what is on the Set // d.debug(L"after insertion"); // get the elements and print them // d.gotoFirst(); Long* l = d.getFirst(); l->debug(L"item from the List"); while((l=d.getNext())!=NULL) { d.gotoNext(); l->debug(L"item from the List"); } // exit gracefully // Integral::exit(); }
#include <Set.h> #include <Char.h> int main() { // local variables // Set<long> d(USER); Long* j; // add 10 unique items to the Set // for (long i = 0; i< 10; i++) { j = new Long(i * 3); d.insert(j); } // see what is on the Set // d.debug(L"after insertion"); // get the elements and print them // d.gotoFirst(); Long* l = d.getFirst(); l->debug(L"item from the List"); delete l; while((l=d.getNext())!=NULL) { d.gotoNext(); l->debug(L"item from the List"); delete l; } // exit gracefully // Integral::exit(); }