Warning
This class is an implementation detail and is only public so that it can be used by two packages. You should NOT consider this public API.
WARNING 2: This is not a general purpose List implementation! It has a specific use and will not work correctly if you use it outside of its use.
A specialized ArrayList that caches its hashCode as well as overriding equals to avoid creating an Iterator. This class is useful in scenarios where the list won't change and you want to avoid the overhead of hashCode iterating through the elements invoking hashCode. This also assumes you'll only ever compare a BakedArrayList to another BakedArrayList.
| Modifier and Type | Field and Description |
|---|---|
| private int | _hashCode
The cached hashCode. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | equals(Object o)
Overrides java. Implements java. Compares the specified object with this list for equality. |
| public int | hashCode()
Overrides java. Implements java. Returns the hash code value for this list. |
| _hashCode | back to summary |
|---|---|
| private int _hashCode The cached hashCode. | |
| BakedArrayList | back to summary |
|---|---|
| public BakedArrayList(int size) | |
| BakedArrayList | back to summary |
|---|---|
| public BakedArrayList(List<? extends E> data) | |
| cacheHashCode | back to summary |
|---|---|
| public void cacheHashCode() Caches the hash code. It is assumed you won't modify the list, or that if you do you'll call cacheHashCode again. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Implements java. Doc from java. Compares the specified object with this list for equality. Returns
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this list. The hash code of a list is defined to be the result of the following calculation:
This ensures that list1.equals(list2) implies that
list1.hashCode()==list2.hashCode() for any two lists,
list1 and list2, as required by the general
contract of Object#hashCode.
| |