21#define PRINTF(fmt, ...)
30using namespace object;
96 it.getNext()->intoStringBuffer(sb);
110 numAlloc = initSize == 0 ? 1 : initSize;
137 delete array[newPos];
146 perror(
"realloc failed");
159 array[newPos] = newElement;
176 put(newElement, pos);
185 perror(
"realloc failed");
194 array[pos] = newElement;
234 "<b>bsearch</b> (<i>key</i>, %s, %d, %d, <i>comparator</i>) "
236 mustExist ?
"true" :
"false", start, end,
size ());
243 result = mustExist ? -1 : start;
245 int low = start, high = end;
249 int index = (low + high) / 2;
252 "searching within %d and %d; compare key with #%d => %d",
253 low, high, index, c);
264 result = c > 0 ? index + 1 : index;
291 return index < vector->numElements - 1;
323 Node *node1 = first, *node2 = otherList->
first;
324 while (node1 != NULL && node2 != NULL ) {
330 return node1 == NULL && node2 == NULL;
336 for (
Node *node = first; node; node = node->
next)
345 delete first->object;
358 newLast->
next = NULL;
359 newLast->
object = element;
362 last->next = newLast;
365 first = last = newLast;
372 Node *beforeCur, *cur;
374 for (beforeCur = NULL, cur = first; cur; beforeCur = cur, cur = cur->
next) {
375 if (cur->
object == beforeThis) {
381 beforeCur->
next = newNode;
395 Node *beforeCur, *cur;
397 for (beforeCur = NULL, cur = first; cur; beforeCur = cur, cur = cur->
next) {
403 if (cur->
next == NULL)
428 object = current->object;
429 current = current->next;
438 return current != NULL;
454 this->tableSize = tableSize;
456 table =
new Node*[tableSize];
457 for (
int i = 0; i < tableSize; i++)
465 for (
int i = 0; i < tableSize; i++) {
508 int h = calcHashValue(
object);
509 for (
Node *node = table[h]; node; node = node->
next) {
510 if (object->
equals(node->object))
520 Node *node = findNode(
object);
525 int h = calcHashValue(
object);
526 node = createNode ();
527 node->
next = table[h];
544 int h = calcHashValue(
object);
545 for (
Node *n = table[h]; n; n = n->
next) {
546 if (object->
equals(n->object))
555 int h = calcHashValue(
object);
558 for (last = NULL, cur = table[h]; cur; last = cur, cur = cur->
next) {
563 table[h] = cur->
next;
607 while (node == NULL) {
608 if (pos >= set->tableSize - 1)
611 node = set->table[pos];
620 result = node->object;
643 HashSet (ownerOfKeys, tableSize)
690 node->object->intoStringBuffer(sb);
760 newBottom->
object = object;
761 newBottom->
prev = NULL;
802 return current != NULL;
The base class for all iterators, as created by container::untyped::Collection::createIterator.
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
HashSetIterator(HashSet *set)
Node * insertNode(object::Object *object)
void put(object::Object *object)
bool remove(object::Object *key)
HashSet(bool ownerOfObjects, int tableSize=251)
bool contains(object::Object *key) const
virtual Node * createNode()
virtual void clearNode(Node *node)
AbstractIterator * createIterator()
Node * findNode(object::Object *object) const
object::Object * get(object::Object *key) const
void clearNode(Node *node)
HashTable(bool ownerOfKeys, bool ownerOfValues, int tableSize=251)
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
void put(object::Object *key, object::Object *value)
This is a small wrapper for AbstractIterator, which may be used directly, not as a pointer,...
Collection0::AbstractIterator * impl
Iterator & operator=(const Iterator &it2)
bool remove0(object::Object *element, bool compare, bool doNotDeleteAtAll)
bool equals(Object *other)
Returns, whether two objects are equal.
void append(object::Object *element)
AbstractIterator * createIterator()
bool insertBefore(object::Object *beforeThis, object::Object *neew)
List(bool ownerOfObjects)
int hashValue()
Return a hash value for the object.
void push(object::Object *object)
void pushUnder(object::Object *object)
AbstractIterator * createIterator()
Stack(bool ownerOfObjects)
void sort(object::Comparator *comparator=&object::standardComparator)
Sort the elements in the vector.
Vector(int initSize, bool ownerOfObjects)
void put(object::Object *newElement, int newPos=-1)
int bsearch(Object *key, bool mustExist, int start, int end, object::Comparator *comparator=&object::standardComparator)
Use binary search to find an element in a sorted vector.
AbstractIterator * createIterator()
void insert(object::Object *newElement, int pos)
A class for fast concatenation of a large number of strings.
void append(const char *str)
Append a NUL-terminated string to the buffer, with copying.
Used for other orders as the one defined by Comparable.
static int compareFun(const void *p1, const void *p2)
This static method may be used as compare function for qsort(3) and bsearch(3), for an array of Objec...
static Comparator * compareFunComparator
virtual int compare(Object *o1, Object *o2)=0
Compare two objects o1 and o2.
This is the base class for many other classes, which defines very common virtual methods.
virtual void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
const char * toString()
Use object::Object::intoStringBuffer to return a textual representation of the object.
virtual int hashValue()
Return a hash value for the object.
virtual bool equals(Object *other)
Returns, whether two objects are equal.
#define DBG_OBJ_CREATE(klass)
#define DBG_OBJ_MSG_END()
#define DBG_OBJ_MSGF(aspect, prio, fmt,...)
#define DBG_OBJ_MSG(aspect, prio, msg)
#define DBG_OBJ_MSG_START()