org.hibernate.search.elasticsearch.util.impl

## Class Window<E>

- java.lang.Object
- - org.hibernate.search.elasticsearch.util.impl.Window<E>

-     public class Window<E>
      extends Object

  A fixed-size, random-access collection that removes the first element when it becomes full.

  The indices accepted by this container are within a bounded range. This range may start at any positive integer value, i.e. the container may not allow access to element at index `0`, but only indices `102-134` for instance. The range will advance automatically as the window gets full and more elements are added.

  Author:
    Yoann Rodiere

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Window(int initialIndex, int capacity)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(E element)` Add an element, removing the first element if it's necessary in order to respect the size limit.
    `int` | `capacity()`
    `void` | `clear()`
    `E` | `get(int externalIndex)`
    `boolean` | `isEmpty()`
    `int` | `size()`
    `int` | `start()`

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

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

- - ### Constructor Detail

    - #### Window

          public Window(int initialIndex,
                        int capacity)

      Parameters:
        `initialIndex` - The index of the first added element.
        `capacity` - The number of elements that can be added before the first element gets automatically erased.

  - ### Method Detail

    - #### start

          public int start()

    - #### size

          public int size()

      Returns:
        The number of elements in this element container.

    - #### isEmpty

          public boolean isEmpty()

    - #### capacity

          public int capacity()

      Returns:
        The maximum number of element that can fit this window.

    - #### get

          public E get(int externalIndex)

    - #### add

          public boolean add(E element)

      Add an element, removing the first element if it's necessary in order to respect the size limit.
      Parameters:
        `element` - The element to add.
      Returns:
        `true` to indicate the element has been added.

    - #### clear

          public void clear()

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved