org.eclipse.net4j.util.ref

## Class Interner<E>

- java.lang.Object
- - org.eclipse.net4j.util.ref.Interner<E>

-     public class Interner<E>
      extends java.lang.Object

  Since:
    3.3
  Author:
    Ed Merks

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `Interner.Entry<E>` A weak reference holder that caches the hash code of the referent and is chained in the `entries` to handle collisions.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Interner()`
    `Interner(int minimumCapacity)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addEntry(Interner.Entry<E> entry)` Adds a new entry, `ensures` the capacity is sufficient and increases the `size`.
    `protected Interner.Entry<E>` | `createEntry(E object, int hashCode)`
    `protected boolean` | `equals(E object, E otherObject)` Returns true if the two objects are to be considered equal.
    `protected Interner.Entry<E>` | `getEntry(int hashCode)` Gets the first entry in the table with exactly the given hash code.
    `void` | `grow(int minimumCapacity)` Ensures that the set has at least the specifies capacity.
    `protected int` | `hashCode(E object)`
    `E` | `intern(E object)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Interner

          public Interner()

    - #### Interner

          public Interner(int minimumCapacity)

  - ### Method Detail

    - #### grow

          public void grow(int minimumCapacity)

      Ensures that the set has at least the specifies capacity. Higher capacity ensures fewer collisions hence faster lookup. Does nothing if the specified capacity is smaller than the current capacity.

    - #### intern

          public E intern(E object)

    - #### getEntry

          protected Interner.Entry<E> getEntry(int hashCode)

      Gets the first entry in the table with exactly the given hash code. It's very useful to call `Interner.Entry.getNextEntry()` to yield the next entry with exactly this same hash code.

    - #### hashCode

          protected int hashCode(E object)

    - #### equals

          protected boolean equals(E object,
                                   E otherObject)

      Returns true if the two objects are to be considered equal. The first object will always be the one passed in as an argument to `intern(Object)`.

    - #### createEntry

          protected Interner.Entry<E> createEntry(E object,
                                                  int hashCode)

    - #### addEntry

          protected void addEntry(Interner.Entry<E> entry)

      Adds a new entry, `ensures` the capacity is sufficient and increases the `size`.

Copyright (c) 2014 Eike Stepper (Berlin, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html