opennlp.tools.util
Class CountedSet<E>

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

public class CountedSet<E>
extends Object
implements 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(Collection<? extends E> c)
           
 void clear()
           
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 int getCount(E o)
          Return the count of the specified object.
 boolean isEmpty()
           
 Iterator<E> iterator()
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(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.
 Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 void write(String fileName, int countCutoff)
          Deprecated. 
 void write(String fileName, int countCutoff, String delim)
          Deprecated. 
 void write(String fileName, int countCutoff, String delim, String encoding)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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 Collection<E>
Specified by:
add in interface 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(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(String fileName,
                             int countCutoff,
                             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(String fileName,
                             int countCutoff,
                             String delim,
                             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(Collection<? extends E> c)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface Set<E>

clear

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

contains

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

containsAll

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

isEmpty

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

iterator

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

remove

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

removeAll

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

retainAll

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

size

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

toArray

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

toArray

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


Copyright © 2010. All Rights Reserved.