コード例 #1
0
ファイル: Ttree.cs プロジェクト: kjk/tenderbase
 /// <summary> Add new member to collection</summary>
 /// <param name="obj">new member
 /// </param>
 /// <returns> <code>true</code> if object is successfully added in the index,
 /// <code>false</code> if collection was declared as unique and there is already member with such value
 /// of the key in the collection.
 /// </returns>
 public virtual bool Add(IPersistent obj)
 {
     TtreePage newRoot;
     if (root == null)
     {
         newRoot = new TtreePage(obj);
     }
     else
     {
         TtreePage.PageReference ref_Renamed = new TtreePage.PageReference(root);
         if (root.Insert(comparator, obj, unique, ref_Renamed) == TtreePage.NOT_UNIQUE)
         {
             return false;
         }
         newRoot = ref_Renamed.pg;
     }
     root = newRoot;
     nMembers += 1;
     Modify();
     return true;
 }
コード例 #2
0
ファイル: Ttree.cs プロジェクト: kjk/tenderbase
 /// <summary> Remove member from collection</summary>
 /// <param name="obj">member to be removed
 /// </param>
 /// <exception cref="StorageError(StorageError.KEY_NOT_FOUND)">exception if there is no such key in the collection
 /// </exception>
 public virtual void Remove(IPersistent obj)
 {
     if (root == null)
     {
         throw new StorageError(StorageError.KEY_NOT_FOUND);
     }
     TtreePage.PageReference ref_Renamed = new TtreePage.PageReference(root);
     if (root.Remove(comparator, obj, ref_Renamed) == TtreePage.NOT_FOUND)
     {
         throw new StorageError(StorageError.KEY_NOT_FOUND);
     }
     root = ref_Renamed.pg;
     nMembers -= 1;
     Modify();
 }