Top Description Inners Fields Constructors Methods
com.amazon.ion.impl

public Class _Private_RecyclingQueue<T>

extends Object
Class Inheritance
Type Parameters
<T>
the type of elements stored.
Imports
java.util.ArrayList, .Iterator, .List

A queue whose elements are recycled. This queue will be extended and iterated frequently.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
_Private_RecyclingQueue.ElementFactory<
the type of element.
T
>

Factory for new queue elements.

private class
public static interface

Field Summary

Modifier and TypeField and Description
private int
private final _Private_RecyclingQueue.ElementFactory<T>
private final List<T>
private final _Private_RecyclingQueue<T>.ElementIterator
private T

Constructor Summary

AccessConstructor and Description
public
_Private_RecyclingQueue(int
the initial capacity of the underlying collection.
initialCapacity
,
_Private_RecyclingQueue.ElementFactory<T>
the factory used to create a new element on push() when the queue has not previously grown to the new depth.
elementFactory
)

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Reset the index and make the queue reusable.

public T
get(int index)

public boolean

Returns:

true if the queue is empty; otherwise, false.
isEmpty
()

public Iterator<T>
public int

Returns:

the element at the top of the queue after the push. This element must be initialized by the caller.
push
(_Private_RecyclingQueue.Recycler<T> recycler)

Pushes an element onto the top of the queue, instantiating a new element only if the queue has not previously grown to the new depth.

public void
remove()

Reclaim the current element.

public int

Returns:

the number of elements within the queue.
size
()

public void
truncate(int index)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentIndexback to summary
private int currentIndex
elementFactoryback to summary
private final _Private_RecyclingQueue.ElementFactory<T> elementFactory
elementsback to summary
private final List<T> elements
iteratorback to summary
private final _Private_RecyclingQueue<T>.ElementIterator iterator
topback to summary
private T top

Constructor Detail

_Private_RecyclingQueueback to summary
public _Private_RecyclingQueue(int initialCapacity, _Private_RecyclingQueue.ElementFactory<T> elementFactory)
Parameters
initialCapacity:int

the initial capacity of the underlying collection.

elementFactory:_Private_RecyclingQueue.ElementFactory<T>

the factory used to create a new element on push() when the queue has not previously grown to the new depth.

Method Detail

clearback to summary
public void clear()

Reset the index and make the queue reusable.

getback to summary
public T get(int index)
isEmptyback to summary
public boolean isEmpty()
Returns:boolean

true if the queue is empty; otherwise, false.

iterateback to summary
public Iterator<T> iterate()
pushback to summary
public int push(_Private_RecyclingQueue.Recycler<T> recycler)

Pushes an element onto the top of the queue, instantiating a new element only if the queue has not previously grown to the new depth.

Returns:int

the element at the top of the queue after the push. This element must be initialized by the caller.

removeback to summary
public void remove()

Reclaim the current element.

sizeback to summary
public int size()
Returns:int

the number of elements within the queue.

truncateback to summary
public void truncate(int index)
com.amazon.ion.impl back to summary

public Interface _Private_RecyclingQueue.ElementFactory<T>

Type Parameters
<T>
the type of element.

Factory for new queue elements.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

a new instance.
newElement
()

Method Detail

newElementback to summary
public T newElement()
Returns:T

a new instance.

com.amazon.ion.impl back to summary

private Class _Private_RecyclingQueue.ElementIterator

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

Iterator for the queue.

Field Summary

Modifier and TypeField and Description
pack-priv int
i

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public T
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iback to summary
pack-priv int i

Constructor Detail

ElementIteratorback to summary
private ElementIterator()

Method Detail

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

Annotations
@Override
nextback to summary
public T next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:T

the next element in the iteration

Annotations
@Override
com.amazon.ion.impl back to summary

public Interface _Private_RecyclingQueue.Recycler<T>

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public void
recycle(T t)

Re-initialize an element

Method Detail

recycleback to summary
public void recycle(T t)

Re-initialize an element