CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
DictTypes.SortedKeysDict Class Reference
Inheritance diagram for DictTypes.SortedKeysDict:
DictTypes.SortedAndFixedKeysDict

Public Member Functions

def __delitem__ (self, key)
 
def __init__ (self, args, kw)
 
def __iter__ (self)
 
def __repr__ (self)
 
def __setitem__ (self, key, value)
 
def items (self)
 
def iteritems (self)
 
def iterkeys (self)
 
def itervalues (self)
 
def keys (self)
 
def values (self)
 

Public Attributes

 list
 

Detailed Description

a dict preserving order of keys

Definition at line 3 of file DictTypes.py.

Constructor & Destructor Documentation

def DictTypes.SortedKeysDict.__init__ (   self,
  args,
  kw 
)

Definition at line 6 of file DictTypes.py.

6  def __init__(self,*args,**kw):
7  dict.__init__(self,*args,**kw)
8  self.list = list()
9  if len(args) == 1:
10  if not hasattr(args[0],'iterkeys'):
11  s = set()
12  #must protect against adding the same key multiple times
13  for x,y in iter(args[0]):
14  if x not in s:
15  self.list.append(x)
16  s.add(x)
17  else:
18  self.list = list(args[0].iterkeys())
19  return
20  self.list = list(six.iterkeys(super(SortedKeysDict,self)))
21 
def __init__(self, args, kw)
Definition: DictTypes.py:6

Member Function Documentation

def DictTypes.SortedKeysDict.__delitem__ (   self,
  key 
)

Definition at line 34 of file DictTypes.py.

34  def __delitem__(self, key):
35  dict.__delitem__(self, key)
36  self.list.remove(key)
def __delitem__(self, key)
Definition: DictTypes.py:34
def DictTypes.SortedKeysDict.__iter__ (   self)

Definition at line 25 of file DictTypes.py.

References DictTypes.SortedKeysDict.list.

25  def __iter__(self):
26  for key in self.list:
27  yield key
def DictTypes.SortedKeysDict.__repr__ (   self)

Definition at line 22 of file DictTypes.py.

References join().

22  def __repr__(self):
23  meat = ', '.join([ '%s: %s' % (repr(key), repr(val)) for key,val in six.iteritems(self) ])
24  return '{' + meat + '}'
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def DictTypes.SortedKeysDict.__setitem__ (   self,
  key,
  value 
)

Definition at line 28 of file DictTypes.py.

References DictTypes.SortedKeysDict.list.

28  def __setitem__(self, key, value):
29  dict.__setitem__(self, key, value)
30  if not hasattr(self,'list'):
31  self.list = list()
32  if not key in self.list:
33  self.list.append(key)
def __setitem__(self, key, value)
Definition: DictTypes.py:28
def DictTypes.SortedKeysDict.items (   self)

Definition at line 37 of file DictTypes.py.

References DictTypes.SortedKeysDict.list.

Referenced by crabConfigParser.CrabConfigParser.getSectionLines(), and python.rootplot.core.Options.kwarg_list().

37  def items(self):
38  return [(key, dict.__getitem__(self, key)) for key in self.list]
def DictTypes.SortedKeysDict.iteritems (   self)

Definition at line 39 of file DictTypes.py.

References DictTypes.SortedKeysDict.list.

39  def iteritems(self):
40  for key in self.list:
41  yield key, dict.__getitem__(self, key)
def DictTypes.SortedKeysDict.iterkeys (   self)

Definition at line 42 of file DictTypes.py.

References DictTypes.SortedKeysDict.list.

42  def iterkeys(self):
43  for key in self.list:
44  yield key
def DictTypes.SortedKeysDict.itervalues (   self)

Definition at line 45 of file DictTypes.py.

References DictTypes.SortedKeysDict.list.

45  def itervalues(self):
46  for key in self.list:
47  yield dict.__getitem__(self,key)
def DictTypes.SortedKeysDict.keys (   self)
def DictTypes.SortedKeysDict.values (   self)

Definition at line 50 of file DictTypes.py.

References DictTypes.SortedKeysDict.list.

50  def values(self):
51  return [ dict.__getitem__(self, key) for key in self.list]
52 
53 

Member Data Documentation

DictTypes.SortedKeysDict.list