collada.util.IndexedList¶
-
class
collada.util.
IndexedList
(items, attrs)¶ Bases:
list
- Class that combines a list and a dict into a single class
- Written by Hugh Bothwell (http://stackoverflow.com/users/33258/hugh-bothwell)
- Original source available at:
- http://stackoverflow.com/questions/5332841/python-list-dict-property-best-practice/5334686#5334686
- Modifications by Jeff Terrace
- Given an object, obj, that has a property x, this allows you to create an IndexedList like so:
- L = IndexedList([], (‘x’)) o = obj() o.x = ‘test’ L.append(o) L[0] # = o L[‘test’] # = o
-
__init__
(items, attrs)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(items, attrs)Initialize self. append
(obj)Append object to the end of the list. extend
(newList)Extend list by appending elements from the iterable. get
(key[, default])insert
(ind, new_obj)Insert object before index. pop
([ind])Remove and return item at index (default last). remove
(ind_or_obj)Remove first occurrence of value. Attributes
count
Return number of occurrences of value. index
Return first index of value. reverse
Reverse IN PLACE. sort
Sort the list in ascending order and return None. -
append
(obj)¶ Append object to the end of the list.
-
extend
(newList)¶ Extend list by appending elements from the iterable.
-
insert
(ind, new_obj)¶ Insert object before index.
-
clear
()¶ Remove all items from list.
-
copy
()¶ Return a shallow copy of the list.
-
count
()¶ Return number of occurrences of value.
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
pop
(ind=-1)¶ Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
-
reverse
()¶ Reverse IN PLACE.
-
sort
()¶ Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
-
remove
(ind_or_obj)¶ Remove first occurrence of value.
Raises ValueError if the value is not present.