Parsing Engine

danbikel.util
Interface FixedSizeList

All Superinterfaces:
Collection, Iterable, List
All Known Subinterfaces:
WordList
All Known Implementing Classes:
AbstractFixedSizeList, FixedSizeArrayList, FixedSizeSingletonList

public interface FixedSizeList
extends List

Specifies methods for a list of a fixed size. As a consequence of having fixed size, several of the optional operations from List are overridden here to document explicitly that they should not be supported. Another consequence is that all implementors should have at least one argument in their constructors that is an int, to specify the fixed size of the list to be created, and all elements are initially null unless otherwise set via a constructor. A final consequence is that the shift(Object) method may be efficiently implemented for lists of fixed size, by employing a circular buffer (indeed, this was one of the prime motivations for the creation of this interface).


Method Summary
 void add(int index, Object element)
          Implementors should simply throw an UnsupportedOperationException.
 boolean add(Object o)
          A synonym for shift(Object).
 boolean addAll(Collection c)
          Sets the first n elements of this list to be the elements of the specified collection, where n is the minimum of the size of the collection and the (fixed) size of this list.
 boolean addAll(int index, Collection c)
          Implementors should simply throw an UnsupportedOperationException.
 void clear()
          Sets all elements of this list to null.
 Object remove(int index)
          Implementors should simply throw an UnsupportedOperationException.
 boolean remove(Object o)
          Implementors should simply throw an UnsupportedOperationException.
 boolean removeAll(Collection c)
          Implementors should simply throw an UnsupportedOperationException.
 boolean retainAll(Collection c)
          Implementors should simply throw an UnsupportedOperationException.
 boolean shift(Object obj)
          Shifts the specified object to the beginning of the list, that is, causes the specified object to be the value at index 0, causes the object at index size() - 1 to be removed and causes the index of all other objects to be increased by 1.
 
Methods inherited from interface java.util.List
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, set, size, subList, toArray, toArray
 

Method Detail

add

void add(int index,
         Object element)
Implementors should simply throw an UnsupportedOperationException.

Specified by:
add in interface List

add

boolean add(Object o)
A synonym for shift(Object).

Specified by:
add in interface Collection
Specified by:
add in interface List
Parameters:
o - the object to be shifted into the first position of this list
Returns:
true (as per the general contract of the Collection.add method)

addAll

boolean addAll(Collection c)
Sets the first n elements of this list to be the elements of the specified collection, where n is the minimum of the size of the collection and the (fixed) size of this list.

Specified by:
addAll in interface Collection
Specified by:
addAll in interface List
Parameters:
c - the collection whose elements are to become the elements of this list
Returns:
true if this list was modified as a result of the call

addAll

boolean addAll(int index,
               Collection c)
Implementors should simply throw an UnsupportedOperationException.

Specified by:
addAll in interface List

clear

void clear()
Sets all elements of this list to null.

Specified by:
clear in interface Collection
Specified by:
clear in interface List

remove

Object remove(int index)
Implementors should simply throw an UnsupportedOperationException.

Specified by:
remove in interface List

remove

boolean remove(Object o)
Implementors should simply throw an UnsupportedOperationException.

Specified by:
remove in interface Collection
Specified by:
remove in interface List

removeAll

boolean removeAll(Collection c)
Implementors should simply throw an UnsupportedOperationException.

Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface List

retainAll

boolean retainAll(Collection c)
Implementors should simply throw an UnsupportedOperationException.

Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface List

shift

boolean shift(Object obj)
Shifts the specified object to the beginning of the list, that is, causes the specified object to be the value at index 0, causes the object at index size() - 1 to be removed and causes the index of all other objects to be increased by 1.

Implementation advice: This method may be implemented to take constant (that is, O(1)) time if the employed data struture is a circular buffer.

Parameters:
obj - the object to be shifted into this list
Returns:
true (as per the general contract of the Collection.add method)

Parsing Engine

Author: Dan Bikel.