Top Description Fields Constructors Methods
org.apache.poi.util

public Class IntMapper<T>

extends Object
implements Duplicatable, Iterable<T>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable, org.apache.poi.common.Duplicatable
Imports
java.util.ArrayList, .HashMap, .Iterator, .List, .Map, .Spliterator, org.apache.poi.common.Duplicatable

A List of objects that are indexed AND keyed by an int; also allows for getting the index of a value in the list

I am happy is someone wants to re-implement this without using the internal list and hashmap. If so could you please make sure that you can add elements half way into the list and have the value-key mappings update

Field Summary

Modifier and TypeField and Description
private static final int
private final List<T>
private final Map<T, Integer>

Constructor Summary

AccessConstructor and Description
public
IntMapper()

create an IntMapper of default size

public
IntMapper(final int initialCapacity)

public
IntMapper(IntMapper<T> other)

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true (as per the general contract of the Collection.add method).
add
(final T
element to be appended to this list.
value
)

Appends the specified element to the end of this list

public IntMapper<T>
public T
get(int index)

public List<T>
public int
getIndex(T o)

public Iterator<T>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public int
size()

public Spliterator<T>
spliterator()

Overrides default java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_default_sizeback to summary
private static final int _default_size
elementsback to summary
private final List<T> elements
valueKeyMapback to summary
private final Map<T, Integer> valueKeyMap

Constructor Detail

IntMapperback to summary
public IntMapper()

create an IntMapper of default size

IntMapperback to summary
public IntMapper(final int initialCapacity)
IntMapperback to summary
public IntMapper(IntMapper<T> other)

Method Detail

addback to summary
public boolean add(final T value)

Appends the specified element to the end of this list

Parameters
value:T

element to be appended to this list.

Returns:boolean

true (as per the general contract of the Collection.add method).

copyback to summary
public IntMapper<T> copy()

Implements org.apache.poi.common.Duplicatable.copy.

Returns:IntMapper<T>

Doc from org.apache.poi.common.Duplicatable.copy.

a deep copy of the implementing class / instance

Annotations
@Override
getback to summary
public T get(int index)
getElementsback to summary
public List<T> getElements()
getIndexback to summary
public int getIndex(T o)
iteratorback to summary
public Iterator<T> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<T>

an Iterator.

sizeback to summary
public int size()
spliteratorback to summary
public Spliterator<T> spliterator()

Overrides default java.lang.Iterable.spliterator.

Doc from java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.

Returns:Spliterator<T>

a Spliterator over the elements described by this Iterable.

Since
POI 5.2.0