Asterisk - The Open Source Telephony Project  18.5.0
Public Member Functions
OrderedDict Class Reference
Inheritance diagram for OrderedDict:
Inheritance graph
[legend]
Collaboration diagram for OrderedDict:
Collaboration graph
[legend]

Public Member Functions

def __delitem__ (self, key, dict_delitem=dict.__delitem__)
 
def __eq__ (self, other)
 
def __init__ (self, args, kwds)
 
def __iter__ (self)
 
def __ne__ (self, other)
 
def __reduce__ (self)
 
def __repr__ (self, _repr_running={})
 
def __reversed__ (self)
 
def __setitem__ (self, key, value, dict_setitem=dict.__setitem__)
 
def clear (self)
 
def copy (self)
 
def fromkeys (cls, iterable, value=None)
 
def items (self)
 
def iteritems (self)
 
def iterkeys (self)
 
def itervalues (self)
 
def keys (self)
 
def pop (self, key, default=__marker)
 
def popitem (self, last=True)
 
def setdefault (self, key, default=None)
 
def update (args, kwds)
 
def values (self)
 
def viewitems (self)
 
def viewkeys (self)
 
def viewvalues (self)
 

Detailed Description

Definition at line 18 of file astdicts.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  args,
  kwds 
)
Initialize an ordered dictionary.  Signature is the same as for
regular dictionaries, but keyword arguments are not recommended
because their insertion order is arbitrary.

Definition at line 30 of file astdicts.py.

References OrderedDict.__map, OrderedDict.__root, OrderedDict.__update, and len().

30  def __init__(self, *args, **kwds):
31  '''Initialize an ordered dictionary. Signature is the same as for
32  regular dictionaries, but keyword arguments are not recommended
33  because their insertion order is arbitrary.
34 
35  '''
36  if len(args) > 1:
37  raise TypeError('expected at most 1 arguments, got %d' % len(args))
38  try:
39  self.__root
40  except AttributeError:
41  self.__root = root = [] # sentinel node
42  root[:] = [root, root, None]
43  self.__map = {}
44  self.__update(*args, **kwds)
45 
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

Member Function Documentation

◆ __delitem__()

def __delitem__ (   self,
  key,
  dict_delitem = dict.__delitem__ 
)

Definition at line 56 of file astdicts.py.

References OrderedDict.__map, and OrderedDict.pop().

56  def __delitem__(self, key, dict_delitem=dict.__delitem__):
57  'od.__delitem__(y) <==> del od[y]'
58  # Deleting an existing item uses self.__map to find the link which is
59  # then removed by updating the links in the predecessor and successor nodes.
60  dict_delitem(self, key)
61  link_prev, link_next, key = self.__map.pop(key)
62  link_prev[1] = link_next
63  link_next[0] = link_prev
64 

◆ __eq__()

def __eq__ (   self,
  other 
)
od.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
while comparison to a regular mapping is order-insensitive.

Definition at line 237 of file astdicts.py.

References playtones_def.items, playtones_state.items, ewscal_pvt.items, OrderedDict.items(), notify_option.items, resource_list.items, featuregroup.items, test_config.items, and len().

237  def __eq__(self, other):
238  '''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive
239  while comparison to a regular mapping is order-insensitive.
240 
241  '''
242  if isinstance(other, OrderedDict):
243  return len(self)==len(other) and self.items() == other.items()
244  return dict.__eq__(self, other)
245 
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

◆ __iter__()

def __iter__ (   self)

Definition at line 65 of file astdicts.py.

References OrderedDict.__root.

65  def __iter__(self):
66  'od.__iter__() <==> iter(od)'
67  root = self.__root
68  curr = root[1]
69  while curr is not root:
70  yield curr[2]
71  curr = curr[1]
72 

◆ __ne__()

def __ne__ (   self,
  other 
)

Definition at line 246 of file astdicts.py.

246  def __ne__(self, other):
247  return not self == other
248 

◆ __reduce__()

def __reduce__ (   self)

Definition at line 212 of file astdicts.py.

References OrderedDict.copy().

212  def __reduce__(self):
213  'Return state information for pickling'
214  items = [[k, self[k]] for k in self]
215  inst_dict = vars(self).copy()
216  for k in vars(OrderedDict()):
217  inst_dict.pop(k, None)
218  if inst_dict:
219  return (self.__class__, (items,), inst_dict)
220  return self.__class__, (items,)
221 
static int copy(char *infile, char *outfile)
Utility function to copy a file.

◆ __repr__()

def __repr__ (   self,
  _repr_running = {} 
)

Definition at line 199 of file astdicts.py.

References id, playtones_def.items, playtones_state.items, ewscal_pvt.items, OrderedDict.items(), notify_option.items, resource_list.items, featuregroup.items, and test_config.items.

199  def __repr__(self, _repr_running={}):
200  'od.__repr__() <==> repr(od)'
201  call_key = id(self), _get_ident()
202  if call_key in _repr_running:
203  return '...'
204  _repr_running[call_key] = 1
205  try:
206  if not self:
207  return '%s()' % (self.__class__.__name__,)
208  return '%s(%r)' % (self.__class__.__name__, self.items())
209  finally:
210  del _repr_running[call_key]
211 
enum queue_result id
Definition: app_queue.c:1507

◆ __reversed__()

def __reversed__ (   self)

Definition at line 73 of file astdicts.py.

References OrderedDict.__root.

73  def __reversed__(self):
74  'od.__reversed__() <==> reversed(od)'
75  root = self.__root
76  curr = root[0]
77  while curr is not root:
78  yield curr[2]
79  curr = curr[0]
80 

◆ __setitem__()

def __setitem__ (   self,
  key,
  value,
  dict_setitem = dict.__setitem__ 
)

Definition at line 46 of file astdicts.py.

References OrderedDict.__map, and OrderedDict.__root.

Referenced by MultiOrderedDict.insert().

46  def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
47  'od.__setitem__(i, y) <==> od[i]=y'
48  # Setting a new item creates a new link which goes at the end of the linked
49  # list, and the inherited dictionary is updated with the new key/value pair.
50  if key not in self:
51  root = self.__root
52  last = root[0]
53  last[1] = root[0] = self.__map[key] = [last, root, key]
54  dict_setitem(self, key, value)
55 

◆ clear()

def clear (   self)

Definition at line 81 of file astdicts.py.

References OrderedDict.__map, OrderedDict.__root, and OrderedDict.itervalues().

81  def clear(self):
82  'od.clear() -> None. Remove all items from od.'
83  try:
84  for node in self.__map.itervalues():
85  del node[:]
86  root = self.__root
87  root[:] = [root, root, None]
88  self.__map.clear()
89  except AttributeError:
90  pass
91  dict.clear(self)
92 

◆ copy()

def copy (   self)

Definition at line 222 of file astdicts.py.

Referenced by OrderedDict.__reduce__().

222  def copy(self):
223  'od.copy() -> a shallow copy of od'
224  return self.__class__(self)
225 
static int copy(char *infile, char *outfile)
Utility function to copy a file.

◆ fromkeys()

def fromkeys (   cls,
  iterable,
  value = None 
)
OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
and values equal to v (which defaults to None).

Definition at line 227 of file astdicts.py.

227  def fromkeys(cls, iterable, value=None):
228  '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
229  and values equal to v (which defaults to None).
230 
231  '''
232  d = cls()
233  for key in iterable:
234  d[key] = value
235  return d
236 

◆ items()

def items (   self)

Definition at line 126 of file astdicts.py.

Referenced by OrderedDict.__eq__(), and OrderedDict.__repr__().

126  def items(self):
127  'od.items() -> list of (key, value) pairs in od'
128  return [(key, self[key]) for key in self]
129 

◆ iteritems()

def iteritems (   self)

Definition at line 139 of file astdicts.py.

Referenced by MultiOrderedDict.copy().

139  def iteritems(self):
140  'od.iteritems -> an iterator over the (key, value) items in od'
141  for k in self:
142  yield (k, self[k])
143 

◆ iterkeys()

def iterkeys (   self)

Definition at line 130 of file astdicts.py.

130  def iterkeys(self):
131  'od.iterkeys() -> an iterator over the keys in od'
132  return iter(self)
133 

◆ itervalues()

def itervalues (   self)

Definition at line 134 of file astdicts.py.

Referenced by OrderedDict.clear().

134  def itervalues(self):
135  'od.itervalues -> an iterator over the values in od'
136  for k in self:
137  yield self[k]
138 

◆ keys()

def keys (   self)

Definition at line 118 of file astdicts.py.

118  def keys(self):
119  'od.keys() -> list of keys in od'
120  return list(self)
121 
static struct keys keys

◆ pop()

def pop (   self,
  key,
  default = __marker 
)
od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.

Definition at line 179 of file astdicts.py.

References OrderedDict.__marker.

Referenced by OrderedDict.__delitem__().

179  def pop(self, key, default=__marker):
180  '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
181  If key is not found, d is returned if given, otherwise KeyError is raised.
182 
183  '''
184  if key in self:
185  result = self[key]
186  del self[key]
187  return result
188  if default is self.__marker:
189  raise KeyError(key)
190  return default
191 

◆ popitem()

def popitem (   self,
  last = True 
)
od.popitem() -> (k, v), return and remove a (key, value) pair.
Pairs are returned in LIFO order if last is true or FIFO order if false.

Definition at line 93 of file astdicts.py.

References OrderedDict.__map, and OrderedDict.__root.

93  def popitem(self, last=True):
94  '''od.popitem() -> (k, v), return and remove a (key, value) pair.
95  Pairs are returned in LIFO order if last is true or FIFO order if false.
96 
97  '''
98  if not self:
99  raise KeyError('dictionary is empty')
100  root = self.__root
101  if last:
102  link = root[0]
103  link_prev = link[0]
104  link_prev[1] = root
105  root[0] = link_prev
106  else:
107  link = root[1]
108  link_next = link[1]
109  root[1] = link_next
110  link_next[0] = root
111  key = link[2]
112  del self.__map[key]
113  value = dict.pop(self, key)
114  return key, value
115 

◆ setdefault()

def setdefault (   self,
  key,
  default = None 
)

Definition at line 192 of file astdicts.py.

192  def setdefault(self, key, default=None):
193  'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od'
194  if key in self:
195  return self[key]
196  self[key] = default
197  return default
198 

◆ update()

def update (   args,
  kwds 
)
od.update(E, **F) -> None.  Update od from dict/iterable E and F.

If E is a dict instance, does:           for k in E: od[k] = E[k]
If E has a .keys() method, does:         for k in E.keys(): od[k] = E[k]
Or if E is an iterable of items, does:   for k, v in E: od[k] = v
In either case, this is followed by:     for k, v in F.items(): od[k] = v

Definition at line 144 of file astdicts.py.

References len().

144  def update(*args, **kwds):
145  '''od.update(E, **F) -> None. Update od from dict/iterable E and F.
146 
147  If E is a dict instance, does: for k in E: od[k] = E[k]
148  If E has a .keys() method, does: for k in E.keys(): od[k] = E[k]
149  Or if E is an iterable of items, does: for k, v in E: od[k] = v
150  In either case, this is followed by: for k, v in F.items(): od[k] = v
151 
152  '''
153  if len(args) > 2:
154  raise TypeError('update() takes at most 2 positional '
155  'arguments (%d given)' % (len(args),))
156  elif not args:
157  raise TypeError('update() takes at least 1 argument (0 given)')
158  self = args[0]
159  # Make progressively weaker assumptions about "other"
160  other = ()
161  if len(args) == 2:
162  other = args[1]
163  if isinstance(other, dict):
164  for key in other:
165  self[key] = other[key]
166  elif hasattr(other, 'keys'):
167  for key in other.keys():
168  self[key] = other[key]
169  else:
170  for key, value in other:
171  self[key] = value
172  for key, value in kwds.items():
173  self[key] = value
174 
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Definition: codec_g726.c:367
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

◆ values()

def values (   self)

Definition at line 122 of file astdicts.py.

122  def values(self):
123  'od.values() -> list of values in od'
124  return [self[key] for key in self]
125 

◆ viewitems()

def viewitems (   self)

Definition at line 259 of file astdicts.py.

259  def viewitems(self):
260  "od.viewitems() -> a set-like object providing a view on od's items"
261  return ItemsView(self)
262 

◆ viewkeys()

def viewkeys (   self)

Definition at line 251 of file astdicts.py.

251  def viewkeys(self):
252  "od.viewkeys() -> a set-like object providing a view on od's keys"
253  return KeysView(self)
254 

◆ viewvalues()

def viewvalues (   self)

Definition at line 255 of file astdicts.py.

255  def viewvalues(self):
256  "od.viewvalues() -> an object providing a view on od's values"
257  return ValuesView(self)
258 

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