Package fuzz :: Module iset :: Class IndexedSet
[hide private]
[frames] | no frames]

Class IndexedSet

source code

object --+    
         |    
       set --+
             |
            IndexedSet
Known Subclasses:

Indexed set class.

Instance Methods [hide private]
new empty set object
__init__(self, index, iterable=set([]))
Constructor.
source code
object
__getitem__(self, key)
Return a set item indexed by key.
source code
 
__setitem__(self, key, item)
Assign an item by key.
source code
bool
__contains__(self, key)
Return whether an item is a member of the set, by key or by object.
source code
 
update(self, iterable)
Update the set by adding all items in an iterable to it.
source code
 
add(self, item)
Add an item to the set, verifying that it has the required index attribute and that no other item in the set has the same index.
source code
 
remove(self, key)
Remove an item from the set by key or by object.
source code
list
keys(self)
Return a list of keys in the set.
source code
bool
has_key(self, key)
Return whether this set contains an item with a given index.
source code

Inherited from set: __and__, __cmp__, __eq__, __ge__, __getattribute__, __gt__, __iand__, __ior__, __isub__, __iter__, __ixor__, __le__, __len__, __lt__, __ne__, __new__, __or__, __rand__, __reduce__, __repr__, __ror__, __rsub__, __rxor__, __sizeof__, __sub__, __xor__, clear, copy, difference, difference_update, discard, intersection, intersection_update, isdisjoint, issubset, issuperset, pop, symmetric_difference, symmetric_difference_update, union

Inherited from object: __delattr__, __format__, __reduce_ex__, __setattr__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from set: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, index, iterable=set([]))
(Constructor)

source code 

Constructor.

Parameters:
  • index (str) - The attribute by which to index items.
  • iterable (iterable) - The iterable to intialize the set with.
Returns: new empty set object
Overrides: object.__init__

__getitem__(self, key)
(Indexing operator)

source code 

Return a set item indexed by key.

Parameters:
  • key (object) - The index of the item to get.
Returns: object
The matching item.

__setitem__(self, key, item)
(Index assignment operator)

source code 

Assign an item by key. Normally, new items are added via add() and existing items modified via object reference; this is included for completeness.

Parameters:
  • key (object) - The index of the item to assign.
  • item (object) - The item to assign.

__contains__(self, key)
(In operator)

source code 

Return whether an item is a member of the set, by key or by object.

Parameters:
  • key (object) - The index or object to test for.
Returns: bool
True if member, false otherwise.
Overrides: set.__contains__

update(self, iterable)

source code 

Update the set by adding all items in an iterable to it.

Parameters:
  • iterable (iterable) - The iterable containing the items to add.
Overrides: set.update

add(self, item)

source code 

Add an item to the set, verifying that it has the required index attribute and that no other item in the set has the same index.

Parameters:
  • item (object) - The item to add.
Overrides: set.add

remove(self, key)

source code 

Remove an item from the set by key or by object.

Parameters:
  • key (object) - The index or object to remove.
Overrides: set.remove

keys(self)

source code 

Return a list of keys in the set.

Returns: list
List of keys in the set.

has_key(self, key)

source code 

Return whether this set contains an item with a given index.

Parameters:
  • key (object) - The index to test for.
Returns: bool
True if a matching key exists, false otherwise.