mondrian.calc.impl
Class ListTupleList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<List<Member>>
          extended by mondrian.calc.impl.AbstractTupleList
              extended by mondrian.calc.impl.AbstractEndToEndTupleList
                  extended by mondrian.calc.impl.ListTupleList
All Implemented Interfaces:
Cloneable, Iterable<List<Member>>, Collection<List<Member>>, List<List<Member>>, RandomAccess, TupleIterable, TupleList

public class ListTupleList
extends AbstractEndToEndTupleList

Implementation of TupleList that stores tuples end-to-end in a backing list.

 l1: {A,B,C},{D,E,F}
 l2: {a,b},{c,d},{e,f}

 externally looks like:
  [] <- {A,B,C,a,b}
  [] <- {A,B,C,c,d}
  [] <- {A,B,C,e,f}
  [] <- {D,E,F,a,b}
  [] <- {D,E,F,c,d}
  [] <- {D,E,F,e,d}

 but internally is:
  A,B,C,a,b,A,B,C,c,d,A,B,C,e,f,D,E,F,a,b,D,E,F,c,d,D,E,F,e,d
 

Author:
jhyde

Nested Class Summary
 
Nested classes/interfaces inherited from class mondrian.calc.impl.AbstractTupleList
AbstractTupleList.AbstractTupleListIterator
 
Nested classes/interfaces inherited from interface mondrian.calc.TupleList
TupleList.PositionCallback
 
Field Summary
 
Fields inherited from class mondrian.calc.impl.AbstractTupleList
arity, mutable
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ListTupleList(int arity, List<Member> list)
          Creates a ListTupleList.
 
Method Summary
 void add(int index, List<Member> element)
           
 void addTuple(Member... members)
           
protected  List<Member> backingList()
           
 void clear()
           
 TupleList cloneList(int capacity)
          Creates a copy of this list that has the same type and has a given capacity.
 List<Member> get(int index)
           
 Member get(int slice, int index)
          Returns a particular column of a particular row.
 List<Member> remove(int index)
           
protected  void removeRange(int fromIndex, int toIndex)
           
 int size()
           
 List<Member> slice(int column)
          Returns a list of the members at a given column.
 TupleIterator tupleIteratorInternal()
           
 
Methods inherited from class mondrian.calc.impl.AbstractEndToEndTupleList
addAll, addAll, project, set, subList, withPositionCallback
 
Methods inherited from class mondrian.calc.impl.AbstractTupleList
addCurrent, fix, getArity, iterator, tupleCursor, tupleIterator
 
Methods inherited from class java.util.AbstractList
add, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, 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
add, contains, containsAll, equals, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

ListTupleList

public ListTupleList(int arity,
                     List<Member> list)
Creates a ListTupleList.

Parameters:
arity - Arity
list - Backing list
Method Detail

backingList

protected List<Member> backingList()
Specified by:
backingList in class AbstractEndToEndTupleList

get

public Member get(int slice,
                  int index)
Description copied from interface: TupleList
Returns a particular column of a particular row.

Note that list.get(row, column) is equivalent to list.slice(column).get(row) and list.get(row).get(column) but is more efficient for most implementations of TupleList.

Specified by:
get in interface TupleList
Overrides:
get in class AbstractTupleList
Parameters:
slice - Column ordinal
index - Row ordinal
Returns:
Member at given row and column

get

public List<Member> get(int index)
Specified by:
get in interface List<List<Member>>
Specified by:
get in class AbstractList<List<Member>>

add

public void add(int index,
                List<Member> element)
Specified by:
add in interface List<List<Member>>
Overrides:
add in class AbstractList<List<Member>>

addTuple

public void addTuple(Member... members)

clear

public void clear()
Specified by:
clear in interface Collection<List<Member>>
Specified by:
clear in interface List<List<Member>>
Overrides:
clear in class AbstractList<List<Member>>

remove

public List<Member> remove(int index)
Specified by:
remove in interface List<List<Member>>
Overrides:
remove in class AbstractList<List<Member>>

removeRange

protected void removeRange(int fromIndex,
                           int toIndex)
Overrides:
removeRange in class AbstractList<List<Member>>

size

public int size()
Specified by:
size in interface Collection<List<Member>>
Specified by:
size in interface List<List<Member>>
Specified by:
size in class AbstractCollection<List<Member>>

slice

public List<Member> slice(int column)
Description copied from interface: TupleList
Returns a list of the members at a given column.

The list is modifiable if and only if this TupleList is modifiable. Adding an element to a slice will create a tuple whose members in other columns are null. Removing an element from a slicer will remove a tuple.

Parameters:
column - Ordinal of the member in each tuple to project
Returns:
List of members

cloneList

public TupleList cloneList(int capacity)
Description copied from interface: TupleList
Creates a copy of this list that has the same type and has a given capacity.

If capacity is negative, populates the list. A deep copy is made, so that it the contents of the list are not affected to changes to any backing collections.

Parameters:
capacity - Capacity
Returns:
Copy of list, empty if capacity is non-negative

tupleIteratorInternal

public TupleIterator tupleIteratorInternal()
Specified by:
tupleIteratorInternal in class AbstractTupleList

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads