Package dns :: Module set :: Class Set
[show private | hide private]
[frames | no frames]

Type Set

object --+
         |
        Set

Known Subclasses:
Rdataset

A simple set class.

Sets are not in Python until 2.3, and rdata are not immutable so we cannot use sets.Set anyway. This class implements subset of the 2.3 Set interface using a list as the container.
Method Summary
  __init__(self, items)
Initialize the set.
  __add__(self, other)
  __and__(self, other)
  __copy__(self)
Make a (shallow) copy of the set.
  __delitem__(self, i)
  __delslice__(self, i, j)
  __eq__(self, other)
  __getitem__(self, i)
  __getslice__(self, i, j)
  __iadd__(self, other)
  __iand__(self, other)
  __ior__(self, other)
  __isub__(self, other)
  __iter__(self)
  __len__(self)
  __ne__(self, other)
  __or__(self, other)
  __repr__(self)
  __sub__(self, other)
  add(self, item)
Add an item to the set.
  clear(self)
Make the set empty.
  copy(self)
Make a (shallow) copy of the set.
the same type as self difference(self, other)
Return a new set which self - other, i.e.
  difference_update(self, other)
Update the set, removing any elements from other which are in the set.
  discard(self, item)
Remove an item from the set if present.
the same type as self intersection(self, other)
Return a new set which is the intersection of self and other.
  intersection_update(self, other)
Update the set, removing any elements from other which are not in both sets.
bool issubset(self, other)
Is self a subset of other?
bool issuperset(self, other)
Is self a superset of other?
  remove(self, item)
Remove an item from the set.
the same type as self union(self, other)
Return a new set which is the union of self and other.
  union_update(self, other)
Update the set, adding any elements from other which are not already in the set.
  update(self, other)
Update the set, adding any elements from other which are not already in the set.
  _clone(self)
Make a (shallow) copy of the set.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Instance Variable Summary
list items: A list of the items which are in the set

Class Variable Summary
list __slots__ = ['items']

Method Details

__init__(self, items=None)
(Constructor)

Initialize the set.
Parameters:
items - the initial set of items
           (type=any iterable or None)
Overrides:
__builtin__.object.__init__

__copy__(self)

Make a (shallow) copy of the set.

add(self, item)

Add an item to the set.

clear(self)

Make the set empty.

copy(self)

Make a (shallow) copy of the set.

difference(self, other)

Return a new set which self - other, i.e. the items in self which are not also in other.
Parameters:
other - the other set
           (type=Set object)
Returns:
the same type as self

difference_update(self, other)

Update the set, removing any elements from other which are in the set.
Parameters:
other - the collection of items with which to update the set
           (type=Set object)

discard(self, item)

Remove an item from the set if present.

intersection(self, other)

Return a new set which is the intersection of self and other.
Parameters:
other - the other set
           (type=Set object)
Returns:
the same type as self

intersection_update(self, other)

Update the set, removing any elements from other which are not in both sets.
Parameters:
other - the collection of items with which to update the set
           (type=Set object)

issubset(self, other)

Is self a subset of other?
Returns:
bool

issuperset(self, other)

Is self a superset of other?
Returns:
bool

remove(self, item)

Remove an item from the set.

union(self, other)

Return a new set which is the union of self and other.
Parameters:
other - the other set
           (type=Set object)
Returns:
the same type as self

union_update(self, other)

Update the set, adding any elements from other which are not already in the set.
Parameters:
other - the collection of items with which to update the set
           (type=Set object)

update(self, other)

Update the set, adding any elements from other which are not already in the set.
Parameters:
other - the collection of items with which to update the set
           (type=any iterable type)

_clone(self)

Make a (shallow) copy of the set.

There is a 'clone protocol' that subclasses of this class should use. To make a copy, first call your super's _clone() method, and use the object returned as the new instance. Then make shallow copies of the attributes defined in the subclass.

This protocol allows us to write the set algorithms that return new instances (e.g. union) once, and keep using them in subclasses.

Instance Variable Details

items

A list of the items which are in the set
Type:
list
Value:
<member 'items' of 'Set' objects>                                      

Class Variable Details

__slots__

Type:
list
Value:
['items']                                                              

Generated by Epydoc 2.1 on Sun Nov 25 17:43:04 2007 http://epydoc.sf.net