Package buildbot :: Package util :: Module collections :: Class KeyedSets
[frames] | no frames]

Class KeyedSets

source code

This is a collection of named sets. In principal, it contains an empty set for every name, and you can add things to sets, discard things from sets, and so on.

>>> ks = KeyedSets()
>>> ks['tim']                   # get a named set
set([])
>>> ks.add('tim', 'friendly')   # add an element to a set
>>> ks.add('tim', 'dexterous')
>>> ks['tim']
set(['friendly', 'dexterous'])
>>> 'tim' in ks                 # membership testing
True
>>> 'ron' in ks
False
>>> ks.discard('tim', 'friendly')# discard set element
>>> ks.pop('tim')               # return set and reset to empty
set(['dexterous'])
>>> ks['tim']
set([])

This class is careful to conserve memory space - empty sets do not occupy any space.

Instance Methods
 
__init__(self) source code
 
add(self, key, value) source code
 
discard(self, key, value) source code
 
__contains__(self, key) source code
 
__getitem__(self, key) source code
 
pop(self, key) source code