test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
diclist.diclist Class Reference
Inheritance diagram for diclist.diclist:

Public Member Functions

def __getitem__
 
def __init__
 
def __setitem__
 
def add
 

Public Attributes

 dico
 

Detailed Description

list with an internal dictionary for indexing, 
allowing to keep dictionary elements ordered. 
keys can be everything except an integer.

Definition at line 4 of file diclist.py.

Constructor & Destructor Documentation

def diclist.diclist.__init__ (   self)

Definition at line 10 of file diclist.py.

10 
11  def __init__(self):
12  super( diclist, self).__init__()
13  # internal dictionary, will contain key -> index in list
14  self.dico = {}

Member Function Documentation

def diclist.diclist.__getitem__ (   self,
  index 
)
index can be a dictionary key, or an integer specifying 
the rank of the value to be accessed

Definition at line 23 of file diclist.py.

References diclist.diclist.dico.

23 
24  def __getitem__(self, index):
25  '''index can be a dictionary key, or an integer specifying
26  the rank of the value to be accessed
27  '''
28  try:
29  # if index is an integer (the rank), use the list.
30  return super(diclist, self).__getitem__(index)
31  except TypeError, ValueError:
32  # else it's the dictionary key.
33  # use the internal dictionary to get the index,
34  # and return the corresponding value from the list
35  return super(diclist, self).__getitem__( self.dico[index] )
def __getitem__
Definition: diclist.py:23
def diclist.diclist.__setitem__ (   self,
  index,
  value 
)
These functions are quite risky...

Definition at line 36 of file diclist.py.

References diclist.diclist.dico.

36 
37  def __setitem__(self, index, value):
38  '''These functions are quite risky...'''
39  try:
40  return super(diclist, self).__setitem__(index, value)
41  except TypeError as ValueError:
42  return super(diclist, self).__setitem__( self.dico[index], value )
43 
44 
45 
def __setitem__
Definition: diclist.py:36
def diclist.diclist.add (   self,
  key,
  value 
)

Definition at line 15 of file diclist.py.

References cond::utilities::JsonPrinter.append(), reco::ClusterCompatibility.append(), PhysicsTools::SourceVariableSet.append(), ecaldqm::Dependency.append(), cms::Digest.append(), L1GtVhdlTemplateFile.append(), NoProxyException< DataT >.append(), NoRecordException< TrackerDigiGeometryRecord >.append(), NoRecordException< MuonGeometryRecord >.append(), NoProxyException< RPCGeometry >.append(), cms::Exception.append(), NoProxyException< GEMGeometry >.append(), Vispa.Views.PropertyView.PropertyView.append(), psClasses.BuildTreeNodeList.append(), svgfig.SVG.append(), psClasses.queueNode.append(), Json::Value.append(), Mixins._ValidatingListBase.append(), plotting.PlotGroup.append(), plotting.PlotFolder.append(), plotting.Plotter.append(), and diclist.diclist.dico.

Referenced by counter.Counter.register().

15 
16  def add( self, key, value ):
17  if isinstance(key, (int, long)):
18  raise ValueError("key cannot be an integer")
19  if key in self.dico:
20  raise ValueError("key '{key}' already exists".format(key=key) )
21  self.dico[key] = len(self)
22  self.append(value)

Member Data Documentation

diclist.diclist.dico

Definition at line 13 of file diclist.py.

Referenced by diclist.diclist.__getitem__(), diclist.diclist.__setitem__(), diclist.diclist.add(), and counter.Counter.inc().