Back to index

python-biopython  1.60
Public Member Functions | Private Attributes
Bio.Pathway.Rep.HashSet.HashSet Class Reference

List of all members.

Public Member Functions

def __init__
def __contains__
def __eq__
def __len__
def __ne__
def __repr__
def __str__
def add
def contains
def remove
def list
def empty
def union
def intersection
def difference
def cartesian

Private Attributes

 _elements

Detailed Description

A set abstraction supporting the basic set operations.

This implementation requires that all elements are hashable,
which implies that elements must not mutate while contained.

Definition at line 12 of file HashSet.py.


Constructor & Destructor Documentation

def Bio.Pathway.Rep.HashSet.HashSet.__init__ (   self,
  elements = [] 
)
Initializes a new HashSet.

Definition at line 18 of file HashSet.py.

00018 
00019     def __init__(self, elements = []):
00020         """Initializes a new HashSet."""
00021         self._elements = {}
00022         for e in elements:
00023             self._elements[e] = 1
            

Member Function Documentation

def Bio.Pathway.Rep.HashSet.HashSet.__contains__ (   self,
  element 
)
Returns true iff this set contains element.

Definition at line 24 of file HashSet.py.

00024 
00025     def __contains__(self, element):
00026         """Returns true iff this set contains element."""
00027         return element in self._elements
    

Here is the caller graph for this function:

def Bio.Pathway.Rep.HashSet.HashSet.__eq__ (   self,
  set 
)
Returns true iff x == y for all elements in self, set.

Definition at line 28 of file HashSet.py.

00028 
00029     def __eq__(self, set):
00030         """Returns true iff x == y for all elements in self, set."""
00031         if not isinstance(set, HashSet):
00032             return 0
00033         for x in self.list():
00034             if not (x in set): return 0
00035         for x in set.list():
00036             if not (x in self): return 0
00037         return 1

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the number of elements in this set.

Definition at line 38 of file HashSet.py.

00038 
00039     def __len__(self):
00040         """Returns the number of elements in this set."""
00041         return len(self._elements)

def Bio.Pathway.Rep.HashSet.HashSet.__ne__ (   self,
  set 
)
Returns true iff this set is not equal to set.

Definition at line 42 of file HashSet.py.

00042 
00043     def __ne__(self, set):
00044         """Returns true iff this set is not equal to set.""" 
00045         return not self.__eq__(set)

Here is the call graph for this function:

Returns a debugging string representation of this set.

Definition at line 46 of file HashSet.py.

00046 
00047     def __repr__(self):
00048         """Returns a debugging string representation of this set."""
00049         return "HashSet(" + repr(self.list()) + ")"

Here is the call graph for this function:

Returns a string representation of this set.

Definition at line 50 of file HashSet.py.

00050 
00051     def __str__(self):
00052         """Returns a string representation of this set."""
00053         return "{" + ",".join(map(str, self.list())) + "}" 

Here is the call graph for this function:

def Bio.Pathway.Rep.HashSet.HashSet.add (   self,
  element 
)
Adds element to this set.

Definition at line 56 of file HashSet.py.

00056 
00057     def add(self, element):
00058         """Adds element to this set."""
00059         self._elements[element] = 1

Here is the caller graph for this function:

Returns the Cartesian product of this set and s.

Definition at line 95 of file HashSet.py.

00095 
00096     def cartesian(self,s):
00097         """Returns the Cartesian product of this set and s."""
00098         p = []
00099         for i in self.list():
00100             for j in s.list():
00101                 p.append((i,j))
00102         return HashSet(p)
00103     
00104 
00105 

Here is the call graph for this function:

def Bio.Pathway.Rep.HashSet.HashSet.contains (   self,
  element 
)
Returns true iff this set contains element.

Definition at line 60 of file HashSet.py.

00060 
00061     def contains(self, element):
00062         """Returns true iff this set contains element."""
00063         return self.__contains__(element)

Here is the call graph for this function:

Returns the difference of this set and s.

Definition at line 91 of file HashSet.py.

00091 
00092     def difference(self, s):
00093         """Returns the difference of this set and s."""
00094         return HashSet(filter(lambda e,s=s: e not in s, self.list()))

Here is the call graph for this function:

Returns true iff this set is empty.

Definition at line 77 of file HashSet.py.

00077 
00078     def empty(self):
00079         """Returns true iff this set is empty."""
00080         return len(self._elements) == 0

Returns the intersection of this set and s.

Definition at line 87 of file HashSet.py.

00087 
00088     def intersection(self, s):
00089         """Returns the intersection of this set and s."""
00090         return HashSet(filter(lambda e,s=s: e in s, self.list()))

Here is the call graph for this function:

Returns the elements of this set in a list.

Definition at line 71 of file HashSet.py.

00071 
00072     def list(self):
00073         """Returns the elements of this set in a list."""
00074         return self._elements.keys()

Here is the caller graph for this function:

def Bio.Pathway.Rep.HashSet.HashSet.remove (   self,
  element 
)
Removes element from this set.

Definition at line 64 of file HashSet.py.

00064 
00065     def remove(self, element):
00066         """Removes element from this set."""
00067         try:
00068             del self._elements[element]
00069         except KeyError:
00070             pass

def Bio.Pathway.Rep.HashSet.HashSet.union (   self,
  s 
)
Returns the union of this set and s.

Definition at line 83 of file HashSet.py.

00083 
00084     def union(self, s):
00085         """Returns the union of this set and s."""
00086         return HashSet(self.list() + s.list())

Here is the call graph for this function:


Member Data Documentation

Definition at line 20 of file HashSet.py.


The documentation for this class was generated from the following file: