20#define PRINTF(fmt, ...)
29using namespace object;
95 it.getNext()->intoStringBuffer(sb);
109 numAlloc = initSize == 0 ? 1 : initSize;
136 delete array[newPos];
156 array[newPos] = newElement;
173 put(newElement, pos);
189 array[pos] = newElement;
229 "<b>bsearch</b> (<i>key</i>, %s, %d, %d, <i>comparator</i>) "
231 mustExist ?
"true" :
"false", start, end,
size ());
238 result = mustExist ? -1 : start;
240 int low = start, high = end;
244 int index = (low + high) / 2;
247 "searching within %d and %d; compare key with #%d => %d",
248 low, high, index, c);
259 result = c > 0 ? index + 1 : index;
286 return index < vector->numElements - 1;
318 Node *node1 = first, *node2 = otherList->
first;
319 while (node1 != NULL && node2 != NULL ) {
325 return node1 == NULL && node2 == NULL;
331 for (
Node *node = first; node; node = node->
next)
340 delete first->object;
353 newLast->
next = NULL;
354 newLast->
object = element;
357 last->next = newLast;
360 first = last = newLast;
367 Node *beforeCur, *cur;
369 for (beforeCur = NULL, cur = first; cur; beforeCur = cur, cur = cur->
next) {
370 if (cur->
object == beforeThis) {
376 beforeCur->
next = newNode;
390 Node *beforeCur, *cur;
392 for (beforeCur = NULL, cur = first; cur; beforeCur = cur, cur = cur->
next) {
398 if (cur->
next == NULL)
423 object = current->object;
424 current = current->next;
433 return current != NULL;
449 this->tableSize = tableSize;
451 table =
new Node*[tableSize];
452 for (
int i = 0; i < tableSize; i++)
460 for (
int i = 0; i < tableSize; i++) {
503 int h = calcHashValue(
object);
504 for (
Node *node = table[h]; node; node = node->
next) {
505 if (object->
equals(node->object))
515 Node *node = findNode(
object);
520 int h = calcHashValue(
object);
521 node = createNode ();
522 node->
next = table[h];
539 int h = calcHashValue(
object);
540 for (
Node *n = table[h]; n; n = n->
next) {
541 if (object->
equals(n->object))
550 int h = calcHashValue(
object);
553 for (last = NULL, cur = table[h]; cur; last = cur, cur = cur->
next) {
558 table[h] = cur->
next;
602 while (node == NULL) {
603 if (pos >= set->tableSize - 1)
606 node = set->table[pos];
615 result = node->object;
638 HashSet (ownerOfKeys, tableSize)
685 node->object->intoStringBuffer(sb);
755 newBottom->
object = object;
756 newBottom->
prev = NULL;
797 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()