From: Dejan L. <dlo...@us...> - 2004-06-14 11:44:34
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21007/src/core Modified Files: PriorityQueue.cpp Queue.cpp Log Message: Added GetMaxSize and SetMaxSize, also GetFirst now return void *data instead of QueueNode Index: Queue.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/Queue.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Queue.cpp 13 Jun 2004 13:50:10 -0000 1.1 --- Queue.cpp 14 Jun 2004 11:44:18 -0000 1.2 *************** *** 58,62 **** bool Queue::Enqueue(void *data) { ! if(_mutex) _mutex->Lock(); // Allocate space for new element QueueNode* new_element = (QueueNode*)malloc(sizeof(QueueNode)); --- 58,63 ---- bool Queue::Enqueue(void *data) { ! if ((_max_size!=0) && (_max_size<_count+1)) return false; ! if (_mutex) _mutex->Lock(); // Allocate space for new element QueueNode* new_element = (QueueNode*)malloc(sizeof(QueueNode)); *************** *** 114,117 **** --- 115,131 ---- //--------------------------------------------------------------------------- + int Queue::Contains(void* data) const + { + int count=0; + QueueNode* node=_head; + while (node) + { + if ( node->data == data ) count++; + node=node->next; + } + return count; + } + + //--------------------------------------------------------------------------- void *Queue::Dequeue() { Index: PriorityQueue.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/PriorityQueue.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PriorityQueue.cpp 10 Jun 2004 22:10:35 -0000 1.2 --- PriorityQueue.cpp 14 Jun 2004 11:44:18 -0000 1.3 *************** *** 58,61 **** --- 58,62 ---- bool PriorityQueue::Enqueue(void *data, unsigned char priority ) { + if ((_max_size!=0) && (_max_size<_count+1)) return false; if(_mutex) _mutex->Lock(); // Allocate space for new element *************** *** 164,167 **** --- 165,180 ---- //--------------------------------------------------------------------------- + int PriorityQueue::Contains(void* data) const + { + int count=0; + QueueNode* node=_head; + while (node) + { + if ( node->data == data ) count++; + node=node->next; + } + return count; + } + //--------------------------------------------------------------------------- void *PriorityQueue::Dequeue() |