opennlp.tools.util
Class CountedSet<E>

java.lang.Object
  extended by opennlp.tools.util.CountedSet<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

public class CountedSet<E>
extends java.lang.Object
implements java.util.Set<E>

Set which counts the number of times a values are added to it. This value can be accessed with the #getCount method.


Constructor Summary
CountedSet()
          Creates a new counted set.
CountedSet(int size)
          Creates a new counted set of the specified initial size.
 
Method Summary
 boolean add(E o)
           
 boolean addAll(java.util.Collection<? extends E> c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 int getCount(E o)
          Return the count of the specified object.
 boolean isEmpty()
           
 java.util.Iterator<E> iterator()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 void setCount(E o, int c)
          Assigns the specified object the specified count in the set.
 int size()
           
 void subtract(E o)
          Reduces the count associated with this object by 1.
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 void write(java.lang.String fileName, int countCutoff)
          Deprecated. 
 void write(java.lang.String fileName, int countCutoff, java.lang.String delim)
          Deprecated. 
 void write(java.lang.String fileName, int countCutoff, java.lang.String delim, java.lang.String encoding)
          Deprecated. 
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode
 

Constructor Detail

CountedSet

public CountedSet()
Creates a new counted set.


CountedSet

public CountedSet(int size)
Creates a new counted set of the specified initial size.

Parameters:
size - The initial size of this set.
Method Detail

add

public boolean add(E o)
Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.Set<E>

subtract

public void subtract(E o)
Reduces the count associated with this object by 1. If this causes the count to become 0, then the object is removed form the set.

Parameters:
o - The object whose count is being reduced.

setCount

public void setCount(E o,
                     int c)
Assigns the specified object the specified count in the set.

Parameters:
o - The object to be added or updated in the set.
c - The count of the specified object.

getCount

public int getCount(E o)
Return the count of the specified object.

Parameters:
o - the object whose count needs to be determined.
Returns:
the count of the specified object.

write

@Deprecated
public void write(java.lang.String fileName,
                             int countCutoff)
Deprecated. 

This methods is deprecated use opennlp.toolsdictionary.serialization package for writing a CountedSet.

Parameters:
fileName -
countCutoff -

write

@Deprecated
public void write(java.lang.String fileName,
                             int countCutoff,
                             java.lang.String delim)
Deprecated. 

This methods is deprecated use opennlp.toolsdictionary.serialization package for writing a CountedSet.

Parameters:
fileName -
countCutoff -
delim -

write

@Deprecated
public void write(java.lang.String fileName,
                             int countCutoff,
                             java.lang.String delim,
                             java.lang.String encoding)
Deprecated. 

This methods is deprecated use opennlp.toolsdictionary.serialization package for writing a CountedSet.

Parameters:
fileName -
countCutoff -
delim -
encoding -

addAll

public boolean addAll(java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.Collection<E>
Specified by:
addAll in interface java.util.Set<E>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E>
Specified by:
clear in interface java.util.Set<E>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<E>
Specified by:
contains in interface java.util.Set<E>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<E>
Specified by:
containsAll in interface java.util.Set<E>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<E>
Specified by:
isEmpty in interface java.util.Set<E>

iterator

public java.util.Iterator<E> iterator()
Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in interface java.util.Set<E>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<E>
Specified by:
remove in interface java.util.Set<E>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<E>
Specified by:
removeAll in interface java.util.Set<E>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<E>
Specified by:
retainAll in interface java.util.Set<E>

size

public int size()
Specified by:
size in interface java.util.Collection<E>
Specified by:
size in interface java.util.Set<E>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.Set<E>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<E>
Specified by:
toArray in interface java.util.Set<E>


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.