Top Description Inners Fields Constructors Methods
net.sf.ehcache.store

public Class CacheKeySet<E>

extends Object
implements Set<E>
Class Inheritance
All Implemented Interfaces
java.util.Set, java.util.Collection, java.lang.Iterable
Type Parameters
<E>
the type of elements maintained by this set
Imports
java.util.ArrayList, .Collection, .Iterator, .List, .Set

A Set of keys that will encapsulate keys present in a Cache. It will mostly behave as an immutable java.util.Set, but for its size method
Author
Alex Snaps

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
CacheKeySet.KeySetIterator

An iterator that will iterate over all keySets, avoiding duplicate entries

Field Summary

Modifier and TypeField and Description
private static final Iterator<E>
private final Collection<E>[]

Constructor Summary

AccessConstructor and Description
public
CacheKeySet(final Collection<E>...
an array of keySets
keySets
)

Create a new Set for all tiers in the cache.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(final Object
element to be added to this set
o
)

Implements java.util.Set.add.

You can't add to this set, will throw!
public boolean
addAll(final Collection<E>
collection containing elements to be added to this set
c
)

Implements java.util.Set.addAll.

You can't add to this set, will throw!
public void
clear()

Implements java.util.Set.clear.

You can't remove from this set, will throw!
public boolean
contains(final Object
element whose presence in this set is to be tested
o
)

Implements java.util.Set.contains.

Returns true if this set contains the specified element.
public boolean
containsAll(final Collection<?>
collection to be checked for containment in this set
c
)

Implements java.util.Set.containsAll.

Returns true if this set contains all of the elements of the specified collection.
public boolean
isEmpty()

Implements java.util.Set.isEmpty.

Returns true if this set contains no elements.
public Iterator<E>
iterator()

Implements java.util.Set.iterator.

Returns an iterator over the elements in this set.
public boolean
remove(final Object
object to be removed from this set, if present
o
)

Implements java.util.Set.remove.

You can't remove from this set, will throw!
public boolean
removeAll(final Collection<?>
collection containing elements to be removed from this set
c
)

Implements java.util.Set.removeAll.

You can't remove from this set, will throw!
public boolean
retainAll(final Collection<?>
collection containing elements to be retained in this set
c
)

Implements java.util.Set.retainAll.

You can't remove from this set, will throw!
public int

Returns:

the sum of all keySet sizes
size
()

Implements java.util.Set.size.

Sums the size of all sets wrapped by this one, so this will not account for duplicated keys.
public Object[]
toArray()

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set.
public <T> T[]
toArray(final T[]
the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
a
)

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTY_ITERATORback to summary
private static final Iterator<E> EMPTY_ITERATOR
keySetsback to summary
private final Collection<E>[] keySets

Constructor Detail

CacheKeySetback to summary
public CacheKeySet(final Collection<E>... keySets)

Create a new Set for all tiers in the cache. Generally, you'd pass the authority's keySet, and higher layer pinned keySets

Parameters
keySets:Collection<E>[]

an array of keySets

Method Detail

addback to summary
public boolean add(final Object o)

Implements java.util.Set.add.

You can't add to this set, will throw!

Parameters
o:Object

Doc from java.util.Set.add.

element to be added to this set

Returns:boolean

Doc from java.util.Set.add.

true if this set did not already contain the specified element

Exceptions
UnsupportedOperationException:

Doc from java.util.Set.add.

if the add operation is not supported by this set

addAllback to summary
public boolean addAll(final Collection<E> c)

Implements java.util.Set.addAll.

You can't add to this set, will throw!

Parameters
c:Collection<E>

Doc from java.util.Set.addAll.

collection containing elements to be added to this set

Returns:boolean

Doc from java.util.Set.addAll.

true if this set changed as a result of the call

Exceptions
UnsupportedOperationException:

Doc from java.util.Set.addAll.

if the addAll operation is not supported by this set

clearback to summary
public void clear()

Implements java.util.Set.clear.

You can't remove from this set, will throw!

Exceptions
UnsupportedOperationException:

Doc from java.util.Set.clear.

if the clear method is not supported by this set

containsback to summary
public boolean contains(final Object o)

Implements java.util.Set.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

Parameters
o:Object

element whose presence in this set is to be tested

Returns:boolean

true if this set contains the specified element

containsAllback to summary
public boolean containsAll(final Collection<?> c)

Implements java.util.Set.containsAll.

Doc from java.util.Set.containsAll.

Returns true if this set contains all of the elements of the specified collection. If the specified collection is also a set, this method returns true if it is a subset of this set.

Parameters
c:Collection<?>

collection to be checked for containment in this set

Returns:boolean

true if this set contains all of the elements of the specified collection

isEmptyback to summary
public boolean isEmpty()

Implements java.util.Set.isEmpty.

Doc from java.util.Set.isEmpty.

Returns true if this set contains no elements.

Returns:boolean

true if this set contains no elements

iteratorback to summary
public Iterator<E> iterator()

Implements java.util.Set.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Returns:Iterator<E>

an iterator over the elements in this set

removeback to summary
public boolean remove(final Object o)

Implements java.util.Set.remove.

You can't remove from this set, will throw!

Parameters
o:Object

Doc from java.util.Set.remove.

object to be removed from this set, if present

Returns:boolean

Doc from java.util.Set.remove.

true if this set contained the specified element

Exceptions
UnsupportedOperationException:

Doc from java.util.Set.remove.

if the remove operation is not supported by this set

removeAllback to summary
public boolean removeAll(final Collection<?> c)

Implements java.util.Set.removeAll.

You can't remove from this set, will throw!

Parameters
c:Collection<?>

Doc from java.util.Set.removeAll.

collection containing elements to be removed from this set

Returns:boolean

Doc from java.util.Set.removeAll.

true if this set changed as a result of the call

Exceptions
UnsupportedOperationException:

Doc from java.util.Set.removeAll.

if the removeAll operation is not supported by this set

retainAllback to summary
public boolean retainAll(final Collection<?> c)

Implements java.util.Set.retainAll.

You can't remove from this set, will throw!

Parameters
c:Collection<?>

Doc from java.util.Set.retainAll.

collection containing elements to be retained in this set

Returns:boolean

Doc from java.util.Set.retainAll.

true if this set changed as a result of the call

Exceptions
UnsupportedOperationException:

Doc from java.util.Set.retainAll.

if the retainAll operation is not supported by this set

sizeback to summary
public int size()

Implements java.util.Set.size.

Sums the size of all sets wrapped by this one, so this will not account for duplicated keys. Like for in-memory pinned keys, that might also present in lower tiers: e.g. DiskStore when its capacity isn't reached.

Returns:int

the sum of all keySet sizes

toArrayback to summary
public Object[] toArray()

Implements java.util.Set.toArray.

Doc from java.util.Set.toArray.

Returns an array containing all of the elements in this set. If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

The returned array will be "safe" in that no references to it are maintained by this set. (In other words, this method must allocate a new array even if this set is backed by an array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Returns:Object[]

an array containing all the elements in this set

toArrayback to summary
public <T> T[] toArray(final T[] a)

Implements java.util.Set.toArray.

Doc from java.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set.

If this set fits in the specified array with room to spare (i.e., the array has more elements than this set), the element in the array immediately following the end of the set is set to null. (This is useful in determining the length of this set only if the caller knows that this set does not contain any null elements.)

If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose x is a set known to contain only strings. The following code can be used to dump the set into a newly allocated array of String:

    String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Parameters
<T>

Doc from java.util.Collection.toArray. the component type of the array to contain the collection

a:T[]

the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.

Returns:T[]

an array containing all the elements in this set

net.sf.ehcache.store back to summary

private final Class CacheKeySet.KeySetIterator

extends Object
implements Iterator<E>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

An iterator that will iterate over all keySets, avoiding duplicate entries

Field Summary

Modifier and TypeField and Description
private E
private Iterator<E>
private int
private E

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public E
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private E current
currentIteratorback to summary
private Iterator<E> currentIterator
indexback to summary
private int index
nextback to summary
private E next

Constructor Detail

KeySetIteratorback to summary
private KeySetIterator()

Method Detail

advanceback to summary
private void advance()
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

nextback to summary
public E next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:E

the next element in the iteration

removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.