groovy.lang
Class SpreadList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended bygroovy.lang.SpreadList
All Implemented Interfaces:
Collection, List

public class SpreadList
extends AbstractList

Spreads a list as individual objects to support the spread operator (*) for lists. For examples,

     def fn(a, b, c, d) { return a + b + c + d }
     println fn(1, 2, 3, 4)
 
     def x = [10, 100]
     def y = [1, *x, 1000, *[10000, 100000]]
     assert y == [1, 10, 100, 1000, 10000, 100000]
 

Version:
$Revision: 1.6 $
Author:
James Strachan, Pilho Kim

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SpreadList(Object[] contents)
          Generator.
 
Method Summary
 boolean equals(Object that)
          Compares this with another object.
 boolean equals(SpreadList that)
          Compares this with another spreadlist.
 Object get(int index)
          Returns the object in this of the indicated position.
 int hashCode()
          Returns the hash code of this.
 int size()
          Returns the size of this.
 List subList(int fromIndex, int toIndex)
          Returns a sublist of this from fromIndex to toIndex.
 String toString()
          Returns the string expression of this.
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
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, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

SpreadList

public SpreadList(Object[] contents)
Generator.

Parameters:
contents - an array of objects to be converted to a SpreadList
Method Detail

get

public Object get(int index)
Returns the object in this of the indicated position.

Parameters:
index - the indicated position in this

size

public int size()
Returns the size of this.


equals

public boolean equals(Object that)
Compares this with another object.

Parameters:
that - another object to be compared with this
Returns:
Returns true if this equals to that, false otherwise

equals

public boolean equals(SpreadList that)
Compares this with another spreadlist.

Parameters:
that - another spreadlist to be compared with this
Returns:
Returns true if this equals to that, false otherwise

hashCode

public int hashCode()
Returns the hash code of this.

Returns:
Returns the hash code of this

subList

public List subList(int fromIndex,
                    int toIndex)
Returns a sublist of this from fromIndex to toIndex.

Parameters:
fromIndex - the first index in this to be taken
toIndex - the last index in this to be taken
Returns:
Returns the sublist of thin in the given scope

toString

public String toString()
Returns the string expression of this.

Returns:
Returns the string expression of this


Copyright © 2003-2007 The Codehaus. All Rights Reserved.