edu.umd.cfar.lamp.apploader.misc
Class FlattenedList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byedu.umd.cfar.lamp.apploader.misc.FlattenedList
All Implemented Interfaces:
java.util.Collection, java.util.List
Direct Known Subclasses:
DescriberBasedProperties

public class FlattenedList
extends java.util.AbstractList

A list of lists that acts as a single list. Note that this only flattens one layer, not completely. For example, if I pass this a list containing two lists, and one list has a list as an element, that list will be returned as a list. Also, it does expect a list of lists.


Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
FlattenedList(java.util.List inside)
          Create a new list from the given list of lists.
 
Method Summary
 void clear()
          Doesn't clear each list; instead, clears the list of lists.
 java.lang.Object get(int i)
          Finds the ith element in the flattened list.
 java.util.List getInnerList()
          Gets the backing list.
 boolean isEmpty()
          Tests to see that all the component lists are empty.
 java.util.Iterator iterator()
          Iterate through all elements of the lists in order.
 void setInnerList(java.util.List L)
          Set the list backing this flattened list to something else.
 int size()
          Gets the sum of the sizes of the individual lists.
 
Methods inherited from class java.util.AbstractList
add, add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

FlattenedList

public FlattenedList(java.util.List inside)
Create a new list from the given list of lists. Note that this is live, so changes to the member lists will have effects.

Parameters:
inside - The list of lists.
Method Detail

iterator

public java.util.Iterator iterator()
Iterate through all elements of the lists in order.

Returns:
An iterator for all elements

get

public java.lang.Object get(int i)
Finds the ith element in the flattened list.

See Also:
AbstractList.get(int)

size

public int size()
Gets the sum of the sizes of the individual lists.

See Also:
List.size()

isEmpty

public boolean isEmpty()
Tests to see that all the component lists are empty.

See Also:
List.isEmpty()

clear

public void clear()
Doesn't clear each list; instead, clears the list of lists.

See Also:
AbstractList.clear()

getInnerList

public java.util.List getInnerList()
Gets the backing list.

Returns:
Returns the backing list.

setInnerList

public void setInnerList(java.util.List L)
Set the list backing this flattened list to something else.

Parameters:
L - the new backing list