Logo Search packages:      
Sourcecode: pwlib version File versions

BOOL PAbstractDictionary::AbstractSetAt ( const PObject key,
PObject obj 
) [virtual]

Add a new object to the collection. If the objects value is already in the dictionary then the object is overrides the previous value. If the AllowDeleteObjects option is set then the old object is also deleted.

The object is placed in the an ordinal position dependent on the keys hash function. Subsequent searches use the has function to speed access to the data item.

TRUE if the object was successfully added.
obj  Key for position in dictionary to add object. New object to put into the dictionary.

Definition at line 1724 of file collect.cxx.

References PObject::Clone().

Referenced by Insert(), InsertAt(), RemoveAt(), SetAt(), and SetDataAt().

  if (obj == NULL) {
    obj = hashTable->RemoveElement(key);
    if (obj != NULL) {
      if (reference->deleteObjects)
        delete obj;
  else {
    Element * element = hashTable->GetElementAt(key);
    if (element == NULL) {
      hashTable->AppendElement(key.Clone(), obj);
    else {
      if ((reference->deleteObjects) && (hashTable->lastElement->data != obj)) 
      delete hashTable->lastElement->data;
      hashTable->lastElement->data = obj;
  return TRUE;

Generated by  Doxygen 1.6.0   Back to index