CMS 3D CMS Logo

Public Member Functions | Public Attributes

python::seqvaluedict::seqdict Class Reference

List of all members.

Public Member Functions

def __add__
def __cmp__
def __delitem__
def __delslice__
def __getitem__
def __getslice__
def __init__
def __len__
def __radd__
def __repr__
def __setitem__
def __setslice__
def append
def check
def clear
def copy
def count
def extend
def filter
def get
def has_key
def index
def insert
def items
def keys
def map
def pop
def push
def reduce
def remove
def reverse
def slice
def sort
def split
def swap
def update
def values

Public Attributes

 dict
 list

Detailed Description

Definition at line 7 of file seqvaluedict.py.


Constructor & Destructor Documentation

def python::seqvaluedict::seqdict::__init__ (   self,
  List = [],
  Dict = {} 
)

Definition at line 8 of file seqvaluedict.py.

00008                                  {}):
00009     if type(List)==type({}):
00010       self.list = List.keys()
00011       self.dict = List.copy()
00012     elif List and not Dict:
00013       self.list=[]
00014       self.dict={}
00015       for i,j in List:
00016         self.list.append(i)
00017         self.dict[i]=j
00018     elif type(List)==type(Dict)==type([]):
00019       self.list = List
00020       self.dict = {}
00021       for key,value in map(None,List,Dict):
00022         self.dict[key] = value
00023     else:
00024       self.list,self.dict = List[:],Dict.copy()
00025       

Member Function Documentation

def python::seqvaluedict::seqdict::__add__ (   self,
  other 
)

Definition at line 96 of file seqvaluedict.py.

00097                          :
00098     newdict = self.__class__()
00099     for key,value in self.items()+other.items():
00100       newdict.append(key,value)
    return newdict    
def python::seqvaluedict::seqdict::__cmp__ (   self,
  other 
)

Definition at line 44 of file seqvaluedict.py.

00045                          :
    return cmp(self.dict,other.dict) or cmp(self.list,other.list)
def python::seqvaluedict::seqdict::__delitem__ (   self,
  key 
)

Definition at line 57 of file seqvaluedict.py.

00058                             :
00059     del self.dict[key]
    self.list.remove(key)      
def python::seqvaluedict::seqdict::__delslice__ (   self,
  start,
  stop 
)

Definition at line 91 of file seqvaluedict.py.

00092                                      :
00093       start = max(start, 0); stop = max(stop, 0)
00094       for key in self.list[start:stop]:
00095         del self.dict[key]
      del self.list[start:stop]
def python::seqvaluedict::seqdict::__getitem__ (   self,
  key 
)

Definition at line 46 of file seqvaluedict.py.

00047                            :
00048     if type(key)==type([]):
00049       newdict={}
00050       for i in key:
00051         newdict[i]=self.dict[i]
00052       return self.__class__(key,newdict)
    return self.dict[key]
def python::seqvaluedict::seqdict::__getslice__ (   self,
  start,
  stop 
)

Definition at line 60 of file seqvaluedict.py.

00061                                    :
00062     start = max(start,0); stop = max(stop,0)
00063     newdict = self.__class__()
00064     for key in self.list[start:stop]:
00065       newdict.dict[key]=self.dict[key]
00066     newdict.list[:]=self.list[start:stop]
    return newdict
def python::seqvaluedict::seqdict::__len__ (   self)

Definition at line 131 of file seqvaluedict.py.

00131 :return len(self.list)
def python::seqvaluedict::seqdict::__radd__ (   self,
  other 
)

Definition at line 101 of file seqvaluedict.py.

00102                           :
00103     newdict = self.__class__()
00104     for key,value in other.items()+self.items():
00105       newdict.append(key,value)
    return newdict   
def python::seqvaluedict::seqdict::__repr__ (   self)

Definition at line 173 of file seqvaluedict.py.

00173                     :return 'seqdict(\n%s,\n%s)'%(self.list,self.dict)
00174 
00175 
def python::seqvaluedict::seqdict::__setitem__ (   self,
  key,
  value 
)

Definition at line 53 of file seqvaluedict.py.

00054                                  :
00055     if not self.dict.has_key(key):
00056       self.list.append(key)
    self.dict[key]=value
def python::seqvaluedict::seqdict::__setslice__ (   self,
  start,
  stop,
  newdict 
)

Definition at line 67 of file seqvaluedict.py.

00068                                            :
00069     start = max(start,0); stop = max(stop,0)
00070     delindexes = []
00071     for key in newdict.keys():
00072       if self.dict.has_key(key):
00073         index = self.list.index(key)
00074         delindexes.append(index)
00075         if index < start:
00076           start = start - 1
00077           stop  = stop  - 1
00078         elif index >= stop:
00079           pass
00080         else:
00081           stop  = stop - 1
00082     delindexes.sort()
00083     delindexes.reverse()
00084     for index in delindexes:
00085       key = self.list[index]
00086       del   self.dict[key]
00087       del  self.list[index]
00088     for key in self.list[start:stop]:
00089       del self.dict[key]
00090     self.list[start:stop] = newdict.list[:]
    self.update(newdict.dict)
def python::seqvaluedict::seqdict::append (   self,
  key,
  value 
)

Definition at line 26 of file seqvaluedict.py.

00027                             :
00028     if self.dict.has_key(key):
00029       self.list.remove(key)
00030     self.list.append(key)
    self.dict[key]=value
def python::seqvaluedict::seqdict::check (   self)

Definition at line 31 of file seqvaluedict.py.

00032                  :
00033     if len(self.dict)==len(self.list):
00034       l1=self.list[:];l1.sort()
00035       l2=self.dict.keys();l2.sort()
00036       return l1==l2
    return -1
def python::seqvaluedict::seqdict::clear (   self)

Definition at line 37 of file seqvaluedict.py.

00038                  :
    self.list=[];self.dict={}
def python::seqvaluedict::seqdict::copy (   self)

Definition at line 39 of file seqvaluedict.py.

00040                 :
00041     if self.__class__ is seqdict:
00042       return self.__class__(self.list,self.dict)
00043     import copy
    return copy.copy(self)
def python::seqvaluedict::seqdict::count (   self,
  value 
)

Definition at line 106 of file seqvaluedict.py.

00107                        :
00108     vallist = self.dict.values()
    return vallist.count(value)
def python::seqvaluedict::seqdict::extend (   self,
  other 
)

Definition at line 109 of file seqvaluedict.py.

00110                         :
    self.update(other)
def python::seqvaluedict::seqdict::filter (   self,
  function 
)

Definition at line 111 of file seqvaluedict.py.

00112                            :
00113     liste=filter(function,self.list)
00114     dict = {}
00115     for i in liste:
00116       dict[i]=self.dict[i]
    return self.__class__(liste,dict)
def python::seqvaluedict::seqdict::get (   self,
  key,
  failobj = None 
)

Definition at line 117 of file seqvaluedict.py.

00118                                   :
        return self.dict.get(key, failobj)
def python::seqvaluedict::seqdict::has_key (   self,
  key 
)

Definition at line 122 of file seqvaluedict.py.

00122 :return self.dict.has_key(key)
def python::seqvaluedict::seqdict::index (   self,
  key 
)

Definition at line 119 of file seqvaluedict.py.

00119 :return self.list.index(key)
def python::seqvaluedict::seqdict::insert (   self,
  i,
  x 
)

Definition at line 120 of file seqvaluedict.py.

00120 :self.__setslice__(i,i,x)
def python::seqvaluedict::seqdict::items (   self)

Definition at line 121 of file seqvaluedict.py.

00121 :return map(None,self.list,self.values())
def python::seqvaluedict::seqdict::keys (   self)

Definition at line 123 of file seqvaluedict.py.

00123 :return self.list
def python::seqvaluedict::seqdict::map (   self,
  function 
)

Definition at line 124 of file seqvaluedict.py.

00125                         :
    return self.__class__(map(function,self.items()))
def python::seqvaluedict::seqdict::pop (   self,
  key = None 
)

Definition at line 132 of file seqvaluedict.py.

00133                         :
00134     if key==None:
00135       pos = -1
00136       key = self.list[pos]
00137     else:
00138       pos = self.list.index(key)
00139     tmp = self.dict[key]
00140     del self.dict[key]
    return {self.list.pop(pos):tmp}
def python::seqvaluedict::seqdict::push (   self,
  key,
  value 
)

Definition at line 141 of file seqvaluedict.py.

00142                           :
    self.append(key,value)
def python::seqvaluedict::seqdict::reduce (   self,
  function,
  start = None 
)

Definition at line 143 of file seqvaluedict.py.

00144                                       :
    return reduce(function,self.items(),start)
def python::seqvaluedict::seqdict::remove (   self,
  key 
)

Definition at line 145 of file seqvaluedict.py.

00146                       :
00147     del self.dict[key]
    self.list.remove(key)
def python::seqvaluedict::seqdict::reverse (   self)

Definition at line 148 of file seqvaluedict.py.

00148 :self.list.reverse()
def python::seqvaluedict::seqdict::slice (   self,
  From,
  To = None,
  Step = 1 
)

Definition at line 165 of file seqvaluedict.py.

00166                                      :
00167     From       = self.list.index(From)
00168     if To:To   = self.list.index(To)
00169     else :
00170       To = From + 1
00171     List = range(From,To,Step)
00172     def getitem(pos,self=self):return self.list[pos]
    return self.__getitem__(map(getitem,List))
def python::seqvaluedict::seqdict::sort (   self,
  args 
)

Definition at line 149 of file seqvaluedict.py.

00149 :apply(self.list.sort,args)
def python::seqvaluedict::seqdict::split (   self,
  function,
  Ignore = None 
)

Definition at line 150 of file seqvaluedict.py.

00151                                       :
00152     splitdict = seqdict() #self.__class__()
00153     for key in self.list:
00154       skey = function(key)
00155       if skey != Ignore:
00156         if not splitdict.has_key(skey):
00157           splitdict[skey] = self.__class__()
00158         splitdict[skey][key] = self.dict[key]
    return splitdict
def python::seqvaluedict::seqdict::swap (   self)

Definition at line 159 of file seqvaluedict.py.

00160                 :
00161     tmp = self.__class__(map(lambda (x,y):(y,x),self.items()))
    self.list,self.dict = tmp.list,tmp.dict
def python::seqvaluedict::seqdict::update (   self,
  newdict 
)

Definition at line 162 of file seqvaluedict.py.

00163                           :
00164     for key,value in newdict.items():
      self.__setitem__(key,value)
def python::seqvaluedict::seqdict::values (   self)

Definition at line 126 of file seqvaluedict.py.

00127                   :
00128     nlist = []
00129     for key in self.list:
00130       nlist.append(self.dict[key])
    return nlist

Member Data Documentation

Definition at line 8 of file seqvaluedict.py.

Definition at line 8 of file seqvaluedict.py.