quick start:g++ [flags ...] file ... #include <Queue.h> Queue(); boolean assign(const Queue<TObject>& copy_queue); boolean add(TObject* item); TObject* remove(TObject* item = (TObject*)NULL); const TObject* peek() const; boolean clear();
description:// declare a character queue and add two characters into it // Queue<Char> queue; Char item0(L'a'); Char item1(L'b'); queue.add(&item0); queue.add(&item1); // remove the top item from the queue // Char* item2 = new Char(); queue.remove(item2); if(!item2->eq(item0)) { // error }
static const String CLASS_NAME = L"Queue";
static const String DEF_PARAM = L"values";
static const long REMOVE_ALL = -1;
static const long REMOVE_TO_MARK = -2;
static const long ERR = 40600;
static const long ERR_EMPTY = 40601;
DoubleLinkedList<TObject> queue_d;
ALLOCATION alloc_d;
static Integral::DEBUG debug_level_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
static boolean setDebug(Integral::DEBUG debug_level);
~Queue();
Queue(ALLOCATION alloc = DEF_ALLOCATION);
Queue(const Queue<TObject>& copy_queue);
boolean assign(const Queue<TObject>& copy_queue);
Queue<TObject>& operator=(const Queue<TObject>& arg);
boolean eq(const Queue<TObject>& compare_queue) const;
long sofSize() const;
boolean read(Sof& sof_a, long tag_a);
boolean write(Sof& sof_a, long tag_a) const;
boolean read(Sof& sof_a, long tag_a, const String& name_a);
boolean write(Sof& sof_a, long tag_a, const String& name_a) 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);
boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE);
boolean ne(const Queue<TObject>& compare_queue) const;
boolean add(TObject* item);
boolean add(Queue<TObject>& item_queue);
boolean add(TObject** item_list, long num_items);
const TObject* peek() const;
TObject* peek();
TObject* remove(TObject* item = (TObject*)NULL);
long remove(Queue& items, long num_items);
boolean removeAll(Queue<TObject>& item_queue);
boolean removeToMark(Queue<TObject>& item_queue);
boolean setMark();
boolean clearMark();
boolean markIsSet() const;
const TObject* getMark() const;
TObject* getMark();
boolean isMarkedElement() const;
boolean isEmpty() const;
long length() const;
boolean find(TObject* value);
boolean contains(TObject* value) const;
boolean apply(boolean (TObject::*method)());
boolean apply(boolean (TObject::*method)(), Queue<TObject>& arg);
boolean sort(Integral::ORDER sort_order = Integral::ASCENDING, SORT_ALGO sort_algo = DEF_SORT_ALGO);
boolean reverse();
ALLOCATION getAllocationMode() const;
boolean setAllocationMode(ALLOCATION alloc);
#include <Char.h> #include <Queue.h> int main () { // local variables // Queue<Long> q; Long j; // add 10 items to the queue // for (long i = 0; i < 10; i++) { j = i * 3; q.add(&j); } // see what is on the queue // q.debug(L"after add"); // pull things off the queue and print them in order // while (q.remove(&j) != (Long*)NULL) { j.debug(L"pulled off queue"); } // exit gracefully // Integral::exit(); }
#include <Char.h> #include <Queue.h> int main () { // local variables (note that the queue is set to reference mode) // Queue<Long> q(USER); Long* j; // add 10 items to the queue // for (long i = 0; i < 10; i++) { j = new Long(i * 3); q.add(j); } // see what is on the queue // q.debug(L"after add"); // pull things off the queue and print them in order // while ((j = q.remove()) != (Long*)NULL) { j->debug(L"pulled off queue"); delete j; } // exit gracefully // Integral::exit(); }
#include <Char.h> #include <Queue.h> int main () { // prepare items for the queue // Char** items = new Char*[5]; for (long i = 0; i < 5; i++) { items[i] = new Char((unichar)((long)(L'a') + i)); } // declare a queue and add items into it // Queue<Char> char_queue; char_queue.add(items, 5); // copy the queue // Queue<Char> copy_char_queue(char_queue); // see if these Queues are equivalent // if(!char_queue.eq(copy_char_queue)) { // exit with error // Integral::exit(); } // clean up the memory used // for (long i = 0; i < 5; i++) { delete items[i]; } delete [] items; // exit gracefully // Integral::exit(); }