public class ObjectList extends ListBase implements java.lang.Iterable<java.lang.Object>
A list of item type object.
Uses the property and function naming conventions of the JavaScript Array object.
| Modifier and Type | Field and Description |
|---|---|
static ObjectList |
empty |
| Constructor and Description |
|---|
ObjectList()
See ObjectList(int).
|
ObjectList(int capacity)
Construct a new list with
ObjectList.length of zero and optional initial capacity. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.Object item)
Add
item to the end of this list. |
void |
addAll(ObjectList list)
Add all the items of
list to the end of this list. |
ObjectList |
addThis(java.lang.Object item)
Add
item to the end of this list. |
ObjectList |
copy()
Return a shallow copy of this list.
|
java.lang.Object |
first()
Return the first item in this list.
|
static ObjectList |
from(java.util.List<java.lang.Object> list) |
java.lang.Object |
get(int index)
Return the item in this list at the specified
index. |
boolean |
includes(java.lang.Object item)
Return
true if this list contains item. |
int |
indexOf(java.lang.Object item)
See indexOf(Object, int).
|
int |
indexOf(java.lang.Object item,
int start)
Return first index in this list of
item, or -1 if not found. |
void |
insertAll(int index,
ObjectList list)
Insert all items of
list into this list, before the item (if any) at index. |
void |
insertAt(int index,
java.lang.Object item)
Insert
item into this list, before the item (if any) at index. |
java.util.Iterator<java.lang.Object> |
iterator() |
java.lang.Object |
last()
Return the last item in this list.
|
int |
lastIndexOf(java.lang.Object item)
|
int |
lastIndexOf(java.lang.Object item,
int start)
Return last index in this list of
item, or -1 if not found. |
void |
set(int index,
java.lang.Object item)
Set the item in this list at the specified
index. |
static ObjectList |
share(ListBase list)
|
java.lang.Object |
single()
Return a single item from this list.
|
ObjectList |
slice(int start)
See slice(int, int).
|
ObjectList |
slice(int start,
int end)
Return a slice of this list from index
start (inclusive) to index end (exclusive). |
java.util.List<java.lang.Object> |
toGeneric() |
clear, getComparer, getDataType, getEquality, getUntypedList, isEmpty, length, removeAt, removeFirst, removeLast, removeRange, reverse, shareWith, sort, sortWith, toDynamic, toString, validatecloneMutable, equals, getTypeCode, hashCodepublic static final ObjectList empty
public ObjectList()
public ObjectList(int capacity)
Construct a new list with ObjectList.length of zero and optional initial capacity.
A list can expand in length beyond its initial capacity, but best performance
will be obtained if the initial capacity is close to the list's maximum length.
capacity - Optional initial capacity.public void add(java.lang.Object item)
Add item to the end of this list.
item - Item to be added.public void addAll(ObjectList list)
Add all the items of list to the end of this list.
list - Items to be added.public ObjectList addThis(java.lang.Object item)
Add item to the end of this list.
item - Item to be added.public ObjectList copy()
Return a shallow copy of this list.
public java.lang.Object first()
Return the first item in this list.
EmptyListException if the list is empty.
public static ObjectList from(java.util.List<java.lang.Object> list)
public java.lang.Object get(int index)
Return the item in this list at the specified index.
ListIndexException if index is out of range (0 to ObjectList.length - 1).
index - Zero-based index.public boolean includes(java.lang.Object item)
Return true if this list contains item.
item - Item for comparison. Comparison uses the ObjectList.equality property, which would usually be expected to match the == operator for item type object.true if this list contains item.public int indexOf(java.lang.Object item)
item - Item parameter.public int indexOf(java.lang.Object item,
int start)
Return first index in this list of item, or -1 if not found.
item - Item for comparison. Comparison uses the ObjectList.equality property, which would usually be expected to match the == operator for item type object.start - Zero-based starting index (search moves forwards from this index).item, or -1 if not found.public void insertAll(int index,
ObjectList list)
Insert all items of list into this list, before the item (if any) at index.
ListIndexException if index is out of range (0 to ObjectList.length).
index - Zero-based index.list - List of items to be inserted.public void insertAt(int index,
java.lang.Object item)
Insert item into this list, before the item (if any) at index.
ListIndexException if index is out of range (0 to ObjectList.length).
index - Zero-based index.item - Item to be added.public java.util.Iterator<java.lang.Object> iterator()
iterator in interface java.lang.Iterable<java.lang.Object>public java.lang.Object last()
Return the last item in this list.
EmptyListException if the list is empty.
public int lastIndexOf(java.lang.Object item)
item - Item parameter.public int lastIndexOf(java.lang.Object item,
int start)
Return last index in this list of item, or -1 if not found.
item - Item for comparison. Comparison uses the ObjectList.equality property, which would usually be expected to match the == operator for item type object.start - Zero-based starting index (search moves backwards from this index).item, or -1 if not found.public void set(int index,
java.lang.Object item)
Set the item in this list at the specified index.
index - Zero-based index.item - Item value.public static ObjectList share(ListBase list)
Return a new ObjectList that shares the ListBase.untypedList as the list parameter.
To ensure type safety, items in list that do not have the item type object will be removed.
list - List whose items will be shared by the resulting list.object, sharing the same items as list.public java.lang.Object single()
Return a single item from this list.
EmptyListException if the list has no items, NotUniqueException if the list has multiple items.
public ObjectList slice(int start)
start - Start parameter.public ObjectList slice(int start, int end)
Return a slice of this list from index start (inclusive) to index end (exclusive).
start - Zero-based starting index (inclusive), or negative for starting index relative to the end of this list.end - Zero-based ending index (exclusive), or negative for ending index relative to the end of this list.start (inclusive) to index end (exclusive).public java.util.List<java.lang.Object> toGeneric()