edu.ucla.structure
Class MappedList

Object
  extended by MappedList
All Implemented Interfaces:
Cloneable, Iterable, Collection, List

public class MappedList
extends Object
implements List, Cloneable

A List of unique values which can be indexed as a list and the index can be efficiently determined( O(1) time).


Constructor Summary
MappedList()
          Creates an empty MappedList.
MappedList(Collection c)
          Creates a mapped list containing the elements of collection in the order provided by the collections iterator.
MappedList(int initialCapacity)
          Creates an empty MappedList with specified capacity.
MappedList(int[] values)
          Creates a MappedList containing Integers corresponding to the ints in values.
MappedList(MappedList toCopy)
           
 
Method Summary
 void add(int index, Object element)
          Not supported.
 boolean add(Object o)
          Appends the specified element to the end of this list.
 boolean addAll(Collection c)
          Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.
 boolean addAll(int index, Collection c)
          Not supported.
 void clear()
          Removes all of the elements from this list.
 void clear(int i)
          sets the value at location i to null
 Object clone()
           
 boolean contains(Object o)
          Returns true if this list contains the specified element.
 boolean containsAll(Collection c)
          Returns true if this list contains all of the elements of the specified collection.
 boolean equals(Object o)
          Compares the specified object with this list for equality.
 Object get(int index)
          Returns the element at the specified position in this list.
 int grep(Filter filter, Collection results)
           
 int grep(Matcher matcher, boolean invert, Collection results)
           
 int grep(Pattern pattern, boolean invert, Collection results)
           
 int hashCode()
          Returns the hash code value for this list.
 int indexOf(Object o)
          Returns the index in this list of the first occurence of the specified element or -1 if this list does not contain this element.
 boolean isEmpty()
          Returns true if this list contains no elements.
 Iterator iterator()
          Returns an iterator over the elements in this list in proper sequence.
 int lastIndexOf(Object o)
          Returns the index in this list of the last occurrence of the specifed element, or -1 if this list does not contain this element.
 ListIterator listIterator()
          Returns a list iterator of the elements in this list (in proper sequence).
 ListIterator listIterator(int index)
          Returns a list iterator of the elements in this list (in proper sequence) starting at the specified position in this list.
 Object remove(int index)
           
 boolean remove(Object o)
          Not supported.
 boolean removeAll(Collection c)
          Not supported.
 boolean retainAll(Collection c)
          Not supported.
 Object set(int index, Object element)
          Replaces the element at the specified position in this list with the specified element.
 int size()
          Returns the number of elements in this list.
 List subList(int fromIndex, int toIndex)
          Not supported.
 void swap(int i, int j)
          Swaps the elements at i and j
 Object[] toArray()
          Returns an array containing all of the elements in this list proper sequence.
 Object[] toArray(Object[] a)
          Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array.
 String toString()
           
 
Methods inherited from class Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MappedList

public MappedList()
Creates an empty MappedList.


MappedList

public MappedList(MappedList toCopy)
Since:
101702

MappedList

public MappedList(int initialCapacity)
Creates an empty MappedList with specified capacity.


MappedList

public MappedList(int[] values)
Creates a MappedList containing Integers corresponding to the ints in values.


MappedList

public MappedList(Collection c)
Creates a mapped list containing the elements of collection in the order provided by the collections iterator.

Method Detail

grep

public int grep(Filter filter,
                Collection results)
Parameters:
results - accumulate matches
Returns:
count matched
Since:
20070419

grep

public int grep(Pattern pattern,
                boolean invert,
                Collection results)
Parameters:
invert - invert the sense of the grep, i.e. add non-matches
results - accumulate matches
Returns:
count matched
Since:
20070329

grep

public int grep(Matcher matcher,
                boolean invert,
                Collection results)
Parameters:
invert - invert the sense of the grep, i.e. add non-matches
results - accumulate matches
Returns:
count matched
Since:
20070329

clone

public Object clone()
Overrides:
clone in class Object
Since:
101702

add

public void add(int index,
                Object element)
Not supported. Throws UnsupportedOperationException.

Specified by:
add in interface List

add

public boolean add(Object o)
Appends the specified element to the end of this list. If o already appears in the list it is not appended.

Specified by:
add in interface Collection
Specified by:
add in interface List

addAll

public boolean addAll(Collection c)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator. If any of the elements are already contained in the list they are not added again.

Specified by:
addAll in interface Collection
Specified by:
addAll in interface List

addAll

public boolean addAll(int index,
                      Collection c)
Not supported. Throws UnsupportedOperationException

Specified by:
addAll in interface List

clear

public void clear()
Removes all of the elements from this list.

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

contains

public boolean contains(Object o)
Returns true if this list contains the specified element.

Specified by:
contains in interface Collection
Specified by:
contains in interface List

containsAll

public boolean containsAll(Collection c)
Returns true if this list contains all of the elements of the specified collection.

Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List

equals

public boolean equals(Object o)
Compares the specified object with this list for equality.

Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class Object

get

public Object get(int index)
Returns the element at the specified position in this list.

Specified by:
get in interface List

hashCode

public int hashCode()
Returns the hash code value for this list.

Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class Object

indexOf

public int indexOf(Object o)
Returns the index in this list of the first occurence of the specified element or -1 if this list does not contain this element.

Specified by:
indexOf in interface List

isEmpty

public boolean isEmpty()
Returns true if this list contains no elements.

Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List

iterator

public Iterator iterator()
Returns an iterator over the elements in this list in proper sequence.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List

lastIndexOf

public int lastIndexOf(Object o)
Returns the index in this list of the last occurrence of the specifed element, or -1 if this list does not contain this element.

Specified by:
lastIndexOf in interface List

listIterator

public ListIterator listIterator()
Returns a list iterator of the elements in this list (in proper sequence).

Specified by:
listIterator in interface List

listIterator

public ListIterator listIterator(int index)
Returns a list iterator of the elements in this list (in proper sequence) starting at the specified position in this list.

Specified by:
listIterator in interface List

remove

public Object remove(int index)
Specified by:
remove in interface List
Since:
101502

remove

public boolean remove(Object o)
Not supported. Throws UnsupportedOperationException.

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

removeAll

public boolean removeAll(Collection c)
Not supported. Throws UnsupportedOperationException.

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

retainAll

public boolean retainAll(Collection c)
Not supported. Throws UnsupportedOperationException.

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

set

public Object set(int index,
                  Object element)
Replaces the element at the specified position in this list with the specified element. If the array already contains element an IllegalARgumentException is thrown.

Specified by:
set in interface List

size

public int size()
Returns the number of elements in this list.

Specified by:
size in interface Collection
Specified by:
size in interface List

subList

public List subList(int fromIndex,
                    int toIndex)
Not supported. Throws UnsupportedOperationException.

Specified by:
subList in interface List

toArray

public Object[] toArray()
Returns an array containing all of the elements in this list proper sequence.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

toArray

public Object[] toArray(Object[] a)
Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array.

Specified by:
toArray in interface Collection
Specified by:
toArray in interface List

swap

public void swap(int i,
                 int j)
Swaps the elements at i and j


clear

public void clear(int i)
sets the value at location i to null


toString

public String toString()
Overrides:
toString in class Object


Copyright 2010 UCLA Automated Reasoning Group