public class SortedRenderableList extends java.lang.Object implements java.util.Collection<IsRenderable>
SortedSet<IsRenderable>
,
except I do no checks to ensure elements are
distinct according to compareTo(...) with respect to zOrder. In fact, most
elements will have the same zOrder=0, in which case they are sorted
according to the original order they were added to the list (stable sort).
Unlike List<IsRenderable>
, order is not guaranteed.
The zOrder is read from render properties if the IsRenderable is an instance
of HasRenderProps. Otherwise, a zOrder can be specified in
add(IsRenderable,int)
, or is assumed to be 0.
Modifier and Type | Field and Description |
---|---|
static int |
defaultCapacity |
static int |
defaultIncrement |
Constructor and Description |
---|
SortedRenderableList()
Constructs an empty list with an initial capacity of ten.
|
SortedRenderableList(java.util.Collection<? extends IsRenderable> c)
Constructs a set containing the elements of the specified
collection.
|
SortedRenderableList(int initialCapacity)
Constructs an empty list with the specified initial capacity.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(IsRenderable e)
Adds an element to this set, sorted ascending by the zOrder parameter
if exists (otherwise assumed zOrder = 0).
|
boolean |
add(IsRenderable e,
int zOrder)
Adds an element to this set, sorted ascending by the zOrder parameter
if exists.
|
boolean |
addAll(java.util.Collection<? extends IsRenderable> c)
Adds all elements in
c to this set. |
void |
clear()
Clears all elements from this set
|
boolean |
contains(java.lang.Object o)
Determines whether the set contains a specified object
|
boolean |
containsAll(java.util.Collection<?> c)
Returns true if this set contains all elements in the
supplied collection
|
IsRenderable |
first()
Gets the first element in the set
|
IsRenderable |
get(int index) |
boolean |
isEmpty()
Returns true if set is empty
|
java.util.Iterator<IsRenderable> |
iterator()
Returns an iterator for looping through elements
|
IsRenderable |
last()
Gets the last element in the set
|
int |
numSelectionQueriesNeeded()
Returns the maximum number of selection queries required for all
renderables in this list.
|
IsRenderable |
remove(int idx) |
boolean |
remove(java.lang.Object o)
Removes an element from this set
|
boolean |
removeAll(java.util.Collection<?> c)
Removes all elements in this set that are found in
c . |
boolean |
retainAll(java.util.Collection<?> c)
Retains only the elements that are also found in the collection
c , essentially performing an intersection. |
void |
setIncrement(int inc)
Sets the size to grow the array when we read capacity
|
int |
size()
Returns the number of elements in the set
|
IsRenderable[] |
toArray()
Returns a copy of the IsRenderable array
|
<T> T[] |
toArray(T[] a)
Fills an array with the current sorted IsRenderables.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static int defaultCapacity
public static int defaultIncrement
public SortedRenderableList(int initialCapacity)
initialCapacity
- the initial capacity of the listpublic SortedRenderableList()
public SortedRenderableList(java.util.Collection<? extends IsRenderable> c)
c
- the collection whose elements are to be placed into this listjava.lang.NullPointerException
- if the specified collection is nullpublic int numSelectionQueriesNeeded()
public void setIncrement(int inc)
public int size()
size
in interface java.util.Collection<IsRenderable>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<IsRenderable>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<IsRenderable>
public java.util.Iterator<IsRenderable> iterator()
iterator
in interface java.lang.Iterable<IsRenderable>
iterator
in interface java.util.Collection<IsRenderable>
public IsRenderable[] toArray()
toArray
in interface java.util.Collection<IsRenderable>
public <T> T[] toArray(T[] a)
a
' is too small.toArray
in interface java.util.Collection<IsRenderable>
public boolean add(IsRenderable e)
add
in interface java.util.Collection<IsRenderable>
public boolean add(IsRenderable e, int zOrder)
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<IsRenderable>
public IsRenderable remove(int idx)
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<IsRenderable>
public boolean addAll(java.util.Collection<? extends IsRenderable> c)
c
to this set. Always returns true;addAll
in interface java.util.Collection<IsRenderable>
public boolean retainAll(java.util.Collection<?> c)
c
, essentially performing an intersection. Returns true
if the collection is modifiedretainAll
in interface java.util.Collection<IsRenderable>
public boolean removeAll(java.util.Collection<?> c)
c
. Returns true if the set is modified.removeAll
in interface java.util.Collection<IsRenderable>
public void clear()
clear
in interface java.util.Collection<IsRenderable>
public IsRenderable first()
public IsRenderable last()
public IsRenderable get(int index)