public class FinalSet<T extends Comparable<?>> extends AbstractList<T> implements Set<T>
FinalSet<String> f=new FinalSet("a","b","c");
// equivalently:
// FinalSet<String> f=new FinalSet(new String[]{"a","b","c"});
// FinalSet<String> f=new FinalSet(SHALLNOTBECLONED,ISSORTED,"a","b","c");
System.out.println(f.get(1));
--> b
| Modifier and Type | Field and Description |
|---|---|
T[] |
data
Holds the data, must be sorted
|
modCount| Constructor and Description |
|---|
FinalSet(boolean clone,
T... a)
Constructs a FinalSet from an array, clones the array if indicated.
|
FinalSet(T... a)
Constructs a FinalSet from an array that does not need to be cloned
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(T x)
Tells whether x is in the container
|
T |
get(int i)
Returns the element at position i
|
int |
indexOf(T x)
Returns the position in the array or -1
|
static void |
main(String[] args)
Test routine
|
int |
size()
Returns the number of elements in this FinalSet
|
Spliterator<T> |
spliterator() |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitadd, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, toArray, toArrayparallelStream, removeIf, streampublic T extends Comparable<?>[] data
public FinalSet(boolean clone,
T... a)
public FinalSet(T... a)
public boolean contains(T x)
public int indexOf(T x)
public T get(int i)
get in interface List<T extends Comparable<?>>get in class AbstractList<T extends Comparable<?>>public int size()
size in interface Collection<T extends Comparable<?>>size in interface List<T extends Comparable<?>>size in interface Set<T extends Comparable<?>>size in class AbstractCollection<T extends Comparable<?>>public Spliterator<T> spliterator()
spliterator in interface Iterable<T extends Comparable<?>>spliterator in interface Collection<T extends Comparable<?>>spliterator in interface List<T extends Comparable<?>>spliterator in interface Set<T extends Comparable<?>>public static void main(String[] args)
Copyright © 2018. All rights reserved.