|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.mortbay.util.LazyList
Lazy List creation. A List helper class that attempts to avoid unneccessary List creation. If a method needs to create a List to return, but it is expected that this will either be empty or frequently contain a single item, then using LazyList will avoid additional object creations by using Collections.EMPTY_LIST or Collections.singletonList where possible.
Object lazylist =null; while(loopCondition) { Object item = getItem(); if (item.isToBeAdded()) lazylist = LazyList.add(lazylist,item); } return LazyList.getList(lazylist);An ArrayList of default size is used as the initial LazyList.
List
,
Serialized FormMethod Summary | |
static java.lang.Object |
add(java.lang.Object list,
java.util.Collection collection)
Add the contents of a Collection to a LazyList |
static java.lang.Object |
add(java.lang.Object list,
int initialSize,
java.lang.Object item)
Add an item to a LazyList |
static java.lang.Object |
add(java.lang.Object list,
java.lang.Object item)
Add an item to a LazyList |
static java.lang.Object |
clone(java.lang.Object list)
|
static boolean |
contains(java.lang.Object list,
java.lang.Object item)
|
static java.lang.Object |
get(java.lang.Object list,
int i)
Get item from the list |
static java.util.List |
getList(java.lang.Object list)
Get the real List from a LazyList. |
static java.util.List |
getList(java.lang.Object list,
boolean nullForEmpty)
Get the real List from a LazyList. |
static java.util.Iterator |
iterator(java.lang.Object list)
|
static java.util.ListIterator |
listIterator(java.lang.Object list)
|
static java.lang.Object |
remove(java.lang.Object list,
java.lang.Object o)
|
static int |
size(java.lang.Object list)
The size of a lazy List |
static java.lang.String |
toString(java.lang.Object list)
|
static java.lang.String[] |
toStringArray(java.lang.Object list)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static java.lang.Object add(java.lang.Object list, java.lang.Object item)
list
- The list to add to or null if none yet created.item
- The item to add.
public static java.lang.Object add(java.lang.Object list, java.util.Collection collection)
list
- The list to add to or null if none yet created.collection
- The Collection whose contents should be added.
public static java.lang.Object add(java.lang.Object list, int initialSize, java.lang.Object item)
list
- The list to add to or null if none yet created.initialSize
- A size to use when creating the real listitem
- The item to add.
public static java.lang.Object remove(java.lang.Object list, java.lang.Object o)
public static java.util.List getList(java.lang.Object list)
list
- A LazyList returned from LazyList.add(Object)
public static java.util.List getList(java.lang.Object list, boolean nullForEmpty)
list
- A LazyList returned from LazyList.add(Object) or nullnullForEmpty
- If true, null is returned instead of an
empty list.
public static java.lang.String[] toStringArray(java.lang.Object list)
public static int size(java.lang.Object list)
list
- A LazyList returned from LazyList.add(Object) or null
public static java.lang.Object get(java.lang.Object list, int i)
list
- A LazyList returned from LazyList.add(Object) or nulli
- int index
public static boolean contains(java.lang.Object list, java.lang.Object item)
public static java.lang.Object clone(java.lang.Object list)
public static java.lang.String toString(java.lang.Object list)
public static java.util.Iterator iterator(java.lang.Object list)
public static java.util.ListIterator listIterator(java.lang.Object list)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |