public class

BakedArrayList

extends ArrayList<E>
java.lang.Object
   ↳ java.util.AbstractCollection<E>
     ↳ java.util.AbstractList<E>
       ↳ java.util.ArrayList<E>
         ↳ sun.swing.BakedArrayList

Class Overview

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.

Summary

[Expand]
Inherited Fields
From class java.util.AbstractList
Public Constructors
BakedArrayList(int size)
BakedArrayList(List data)
Public Methods
void cacheHashCode()
Caches the hash code.
boolean equals(Object o)
Compares the specified object with this list for equality.
int hashCode()
Returns the hash code value for this list.
[Expand]
Inherited Methods
From class java.util.ArrayList
From class java.util.AbstractList
From class java.util.AbstractCollection
From class java.lang.Object
From interface java.lang.Iterable
From interface java.util.Collection
From interface java.util.List

Public Constructors

public BakedArrayList (int size)

public BakedArrayList (List data)

Public Methods

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.

public boolean equals (Object o)

Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order.

This implementation first checks if the specified object is this list. If so, it returns true; if not, it checks if the specified object is a list. If not, it returns false; if so, it iterates over both lists, comparing corresponding pairs of elements. If any comparison returns false, this method returns false. If either iterator runs out of elements before the other it returns false (as the lists are of unequal length); otherwise it returns true when the iterations complete.

Parameters
o the object to be compared for equality with this list
Returns
  • true if the specified object is equal to this list

public int hashCode ()

Returns the hash code value for this list.

This implementation uses exactly the code that is used to define the list hash function in the documentation for the hashCode() method.

Returns
  • the hash code value for this list