You are not logged in Log in Join
You are here: Home » Members » ajung » The Hitchhikers Guide To BTrees » BTreesAPI

Log in
Name

Password

 
 

History for BTreesAPI

??changed:
-
!BTrees, Buckets

  - All mapping types implement a dictionary-like API. That means  
    all known dictionary methods work on BTrees instances:

    - keys() -- return a sequence containing the keys

    - values() -- return a sequence containing the values

    - items() -- return a sequence of tuples (key,value) ordered by key

    - __getitem__(key) -- return the value for key

    - __setitem__(key,value) -- set the value for a given key

    - __delitem__(key)  -- remove the key 

    - __len__() -- returns the number of elements in the !BTree
    
    - has_key(key) - return 1 if key exists, otherwise 0

    - get(key, default) - return the value for key or the default value

    - update(mapping) - insert every (key, value) pair into the !BTree

    - insert(key,value) - insert a (key, value) into the !BTree. 

      The !BTree is not changed when *key* is already in the !BTree.
      In this case *insert()* returns 0. Otherwise *(key,value)* is inserted
      and *insert()* returns 1.

      **Remark: only available for !BTree objects and not for Bucket objects**

  - Additional API unique to BTrees:

    - byValue() -- like items(), returns a sequence of tuples, but 
      returns (value, key) instead of (key, value) in the returned 
      list, and ordered by value.

Sets, !TreeSets

  - The BTrees set datatypes act as a mutable sequence (similiar to
    lists) but with the following differences compared to Python sequences:

    - all elements of a set are unique

    - elements are sorted  

    Sets implement the following functions:

    - __len__() -- returns the  number of items in set

    - insert(item) -- inserts a new item

    - remove(item) -- removes an item

    - index(item) -- returns the position of item in set
   
    - update(sequence) -- inserts every item in sequence to the set

    - __getitem__(index): -- return the key in the given index position

      Used for iteration

      **Remark: only available for Set objects and  not for !TreeSet objects**



  - Additional API unique to BTrees:

    - minKey(min=None)  -- return the minimal item from the set. 
       If *min* is present, then the smallest key that is greater than
       or equal to *min* is returned

    - maxKey(max=None) -- return the maximum item from the set.
      If *max* is present then the largest key that is smaller than or
      equal to *max* is returned.

    - keys(min,max) -- peforms a range search and returns a list
      of items that a larger *min* and smaller than *max*. 
  

<hr solid id=comments_below>


From stevea Thu Feb 12 13:22:00 US/Eastern 2004
From: stevea
Date: 2004/02/12 13:22 EST
Subject: Sets do not have index() method in ZODB 3.3
Message-ID: <[email protected]>

Note that Sets do not have an index() method in ZODB 4 and ZODB 3.3. That method doesn't make sense for sets anyway.