    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class collections.LinkedBuffer

    java.lang.Object
       |
       +----collections.UpdatableImpl
               |
               +----collections.UpdatableBagImpl
                       |
                       +----collections.LinkedBuffer

public class LinkedBuffer
extends UpdatableBagImpl
implements UpdatableBag

Linked Buffer implementation of Bags. The Bag consists of any number of buffers holding elements, arranged in a list. Each buffer holds an array of elements. The size of each buffer is the value of chunkSize that was current during the operation that caused the Bag to grow. The chunkSize() may be adjusted at any time. (It is not considered a version change.)

All but the final buffer is always kept full. When a buffer has no elements, it is released (so is available for garbage collection).

LinkedBuffers are good choices for collections in which you merely put a lot of things in, and then look at them via enumerations, but don't often look for particular elements.

##

chunkSize_
  The chunk size to use for making next buffer
defaultChunkSize
  The default chunk size to use for buffers
lastCount_
  The number of elements of the tail node actually used.
tail_
  The last node of the circular list of chunks.

##

LinkedBuffer()
  Make an empty buffer.
LinkedBuffer(Predicate)
  Make an empty buffer, using the supplied element screener.
LinkedBuffer(Predicate, int, CLCell, int, int)
  Special version of constructor needed by clone()

##

add(Object)
  Implements collections.UpdatableBag.add.
addIfAbsent(Object)
  Implements collections.UpdatableBag.addIfAbsent.
checkImplementation()
  Implements collections.ImplementationCheckable.checkImplementation.
chunkSize()
  Report the chunk size used when adding new buffers to the list
chunkSize(int)
  Set the chunk size to be used when adding new buffers to the list during future add() operations.
clear()
  Implements collections.UpdatableCollection.clear.
clone()
  Make an independent copy.
elements()
  Implements collections.Collection.elements.
exclude(Object)
  Implements collections.UpdatableCollection.exclude.
includes(Object)
  Implements collections.Collection.includes.
occurrencesOf(Object)
  Implements collections.Collection.occurrencesOf.
removeOneOf(Object)
  Implements collections.UpdatableCollection.removeOneOf.
replaceAllOf(Object, Object)
  Implements collections.UpdatableCollection.replaceAllOf.
replaceOneOf(Object, Object)
  Implements collections.UpdatableCollection.replaceOneOf Time complexity: O(n).
take()
  Implements collections.UpdatableCollection.take.

##

defaultChunkSize

     public static final int defaultChunkSize

  The default chunk size to use for buffers

tail_

     protected CLCell tail_

  The last node of the circular list of chunks. Null if empty.

lastCount_

     protected int lastCount_

  The number of elements of the tail node actually used. (all others are kept full).

chunkSize_

     protected int chunkSize_

  The chunk size to use for making next buffer

##

LinkedBuffer

     public LinkedBuffer()

  Make an empty buffer.

LinkedBuffer

     public LinkedBuffer(Predicate s)

  Make an empty buffer, using the supplied element screener.

LinkedBuffer

     protected LinkedBuffer(Predicate s,
                            int n,
                            CLCell t,
                            int lc,
                            int cs)

  Special version of constructor needed by clone()

##

clone

     protected Object clone() throws CloneNotSupportedException

  Make an independent copy. Does not clone elements.

  Overrides:
    clone in class Object

chunkSize

     public synchronized int chunkSize()

  Report the chunk size used when adding new buffers to the list

chunkSize

     public synchronized void chunkSize(int newChunkSize) throws IllegalArgumentException

  Set the chunk size to be used when adding new buffers to the list during future add() operations. Any value greater than 0 is OK. (A value of 1 makes this a into very slow simulation of a linked list!)

includes

     public synchronized boolean includes(Object element)

  Implements collections.Collection.includes. Time complexity: O(n).

  Overrides:
    includes in class UpdatableImpl
  See Also:
    includes

occurrencesOf

     public synchronized int occurrencesOf(Object element)

  Implements collections.Collection.occurrencesOf. Time complexity: O(n).

  Overrides:
    occurrencesOf in class UpdatableImpl
  See Also:
    occurrencesOf

elements

     public synchronized CollectionEnumeration elements()

  Implements collections.Collection.elements. Time complexity: O(1).

  Overrides:
    elements in class UpdatableImpl
  See Also:
    elements

clear

     public synchronized void clear()

  Implements collections.UpdatableCollection.clear. Time complexity: O(1).

  Overrides:
    clear in class UpdatableImpl
  See Also:
    clear

exclude

     public synchronized void exclude(Object element)

  Implements collections.UpdatableCollection.exclude. Time complexity: O(n).

  Overrides:
    exclude in class UpdatableImpl
  See Also:
    exclude

removeOneOf

     public synchronized void removeOneOf(Object element)

  Implements collections.UpdatableCollection.removeOneOf. Time complexity: O(n).

  Overrides:
    removeOneOf in class UpdatableImpl
  See Also:
    removeOneOf

replaceOneOf

     public synchronized void replaceOneOf(Object oldElement,
                                           Object newElement) throws IllegalElementException

  Implements collections.UpdatableCollection.replaceOneOf Time complexity: O(n).

  Overrides:
    replaceOneOf in class UpdatableImpl
  See Also:
    replaceOneOf

replaceAllOf

     public synchronized void replaceAllOf(Object oldElement,
                                           Object newElement) throws IllegalElementException

  Implements collections.UpdatableCollection.replaceAllOf. Time complexity: O(n).

  Overrides:
    replaceAllOf in class UpdatableImpl
  See Also:
    replaceAllOf

take

     public synchronized Object take() throws NoSuchElementException

  Implements collections.UpdatableCollection.take. Time complexity: O(1). Takes the least element.

  Overrides:
    take in class UpdatableImpl
  See Also:
    take

addIfAbsent

     public synchronized void addIfAbsent(Object element) throws IllegalElementException

  Implements collections.UpdatableBag.addIfAbsent. Time complexity: O(n).

  Overrides:
    addIfAbsent in class UpdatableBagImpl
  See Also:
    addIfAbsent

add

     public synchronized void add(Object element) throws IllegalElementException

  Implements collections.UpdatableBag.add. Time complexity: O(1).

  Overrides:
    add in class UpdatableBagImpl
  See Also:
    add

checkImplementation

     public void checkImplementation() throws ImplementationError

  Implements collections.ImplementationCheckable.checkImplementation.

  Overrides:
    checkImplementation in class UpdatableImpl
  See Also:
    checkImplementation

    All Packages  Class Hierarchy  This Package  Previous  Next  Index