milestonexprotectrestpython.xprcollection
Module: xprcollection.py
Revision History
Date | Version | Description |
---|---|---|
2023/07/11 | 1.0.0.0 | Initial Version. |
Collection of objects.
Threadsafety:
This class is fully thread-safe.
Initializes a new instance of the class.
Arguments:
- itemType (type): Type of items this collection will contain.
Adds a new item to the collection.
Arguments:
- item (object): Item that will be added to the collection.
Raises:
- TypeError: Item argument is not of a type specified when the collection was initialized.
Returns the number of items in the collection.
Returns:
The number of items in the collection.
Extends the collection with items from another collection.
Arguments:
- other (object): Collection of items to add to the collection.
Read an item from the collection at the specified index.
Arguments:
- index (int): Index of the collection item to get.
Returns:
The collection item at the specified index.
Inserts a new item in the collection at the specified index.
Arguments:
- index (int): Index at which to insert the new item.
- item (object): Item that will be added to the collection.
Raises:
- TypeError: Item argument is not of a type specified when the collection was initialized.
Returns the number of items in the collection.
Returns:
The number of items in the collection.
Remove and return the last item from the collection.
Returns:
The last item from the collection.
Removes an item from the collection.
Arguments:
- item (object): Item that will be removed from the collection.
Raises:
- TypeError: Item argument is not of a type specified when the collection was initialized.
Sorts the collection items by Name (default).
Use the following guidelines when calling a sort method that uses key=lambda syntax:
# good syntax, as it handles x.Name = None values.
epColl.sort(key=lambda x: x.Name or "", reverse=False)
# bad syntax, as the sort will fail if x.Name = None!
epColl.sort(key=lambda x: x.Name, reverse=False)