Package MolKit :: Module listSet :: Class ListSet
[hide private]
[frames] | no frames]

Class ListSet

source code

UserList.UserList --+
                    |
                   ListSet
Known Subclasses:
tree.TreeNodeSet

Class to represent Sets of objects stored in a list. There is an
implicit order amongst the objects and there can be duplicate objects.

__getattr__, __setattr__ and __delattr__ have been modified to operate on
the list of objects rather than the TreeNodeSet itself, i.e. if atm is an
instance of a ListSet a.xxx will not return the member xxx of the object
atm but rather a list of the members xxx from each object in the set atm.
xxx can be a member of a function that requires no argument.

Example:

  if atm is an instance of a ListSet:
  atm.name            return the name attribute of each Atom in atm
  atm.newprop = 7.2   creates a newprop attribute for each Atom in atm
                      with an initial value of 7.2
  atm.newIndex = range(len(atm)) create a newIndex attribute for each Atom
                      in atm with values 0 for the first atom, 1 for the
                      second, etc...
  del atm.newIndex
  
This class also implement  boolean operations on ListSets. These operation
overload some operators.

A uniq() method returns a list with the double removed.
A makeUnique() method removes duplicates from list (in place).



Instance Methods [hide private]
  __init__(self, data=None, elementType=None, stringRepr=None, comments="", keywords=[])
  setStringRepr(self, string)
set the string representation of this set
  getStringRepr(self)
return the string representation of this set
  copy(self)
return a copy of the set
  __str__(self)
add here because __str__ is missing in UserList which creates a pb in jpython
  __delattr__(self, member)
  __iter__(self, *cfg, **kw)
  __getattr__(self, member)
Extract the specified member from each objects in the set and returns them as a list
  getAll(self, member)
  setAll(self, member, value)
  __setattr__(self, member, value)
Set or create member in each object in this set.
  append(self, item)
  insert(self, i, item)
  pop(self, i=-1)
  remove(self, item)
  __getslice__(self, i, j)
  __delslice__(self, i, j)
  __mul__(self, n)
  __imul__(self, n)
  extend(self, right)
  __iadd__(self, right)
See add: overloads += operator
  __add__(self, right)
See add: overloads + operator
  union(self, right)
Union: returns a Set holding objects appearing in either list
  __or__(self, right)
See union: overloads | operator
  xor(self, right)
XOR operation: Returns a set made of the elements appearing in first or second set but not in both
  __xor__(self, right)
See union: overloads ^ operator
  inter(self, right)
Intersection: returns a Set holding objects appearing in both sets
  __and__(self, right)
See inter: overloads & operator
  subtract(self, right)
Returns a set made of the elements of the first set not appearing in the second set
  __sub__(self, right)
See subtract: overloads - operator
  makeUniq(self)
removes duplicates from set (in place)
  uniq(self)

Inherited from UserList.UserList: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getitem__, __gt__, __le__, __len__, __lt__, __ne__, __radd__, __repr__, __rmul__, __setitem__, __setslice__, count, index, reverse, sort


Method Details [hide private]

__init__(self, data=None, elementType=None, stringRepr=None, comments="", keywords=[])
(Constructor)

source code 
None
Overrides: UserList.UserList.__init__

setStringRepr(self, string)

source code 
set the string representation of this set

getStringRepr(self)

source code 
return the string representation of this set

copy(self)

source code 
return a copy of the set

__str__(self)
(Informal representation operator)

source code 
add here because __str__ is missing in UserList which creates a pb in jpython

__delattr__(self, member)

source code 
None

__iter__(self, *cfg, **kw)

source code 
None

__getattr__(self, member)
(Qualification operator)

source code 
Extract the specified member from each objects in the set and returns them as a list

getAll(self, member)

source code 
None

setAll(self, member, value)

source code 
None

__setattr__(self, member, value)

source code 
Set or create member in each object in this set. If value is a sequence it has to be of the same length as the set. else the new member in each object in the set is set to 'value'

append(self, item)

source code 
None
Overrides: UserList.UserList.append

insert(self, i, item)

source code 
None
Overrides: UserList.UserList.insert

pop(self, i=-1)

source code 
None
Overrides: UserList.UserList.pop

remove(self, item)

source code 
None
Overrides: UserList.UserList.remove

__getslice__(self, i, j)
(Slicling operator)

source code 
None
Overrides: UserList.UserList.__getslice__

__delslice__(self, i, j)
(Slice deletion operator)

source code 
None
Overrides: UserList.UserList.__delslice__

__mul__(self, n)

source code 
None
Overrides: UserList.UserList.__mul__

__imul__(self, n)

source code 
None
Overrides: UserList.UserList.__imul__

extend(self, right)

source code 
None
Overrides: UserList.UserList.extend

__iadd__(self, right)

source code 
See add: overloads += operator
Overrides: UserList.UserList.__iadd__

__add__(self, right)
(Addition operator)

source code 
See add: overloads + operator
Overrides: UserList.UserList.__add__

union(self, right)

source code 
Union: returns a Set holding objects appearing in either list

__or__(self, right)
(Or operator)

source code 
See union: overloads | operator

xor(self, right)

source code 
XOR operation: Returns a set made of the elements appearing in first or second set but not in both

__xor__(self, right)

source code 
See union: overloads ^ operator

inter(self, right)

source code 
Intersection: returns a Set holding objects appearing in both sets

__and__(self, right)
(And operator)

source code 
See inter: overloads & operator

subtract(self, right)

source code 
Returns a set made of the elements of the first set not appearing in the second set

__sub__(self, right)
(Subtraction operator)

source code 
See subtract: overloads - operator

makeUniq(self)

source code 
removes duplicates from set (in place)

uniq(self)

source code 
None