Package opennlp.tools.util
Class CountedSet<E>
- java.lang.Object
-
- 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
Constructors Constructor Description CountedSet()
Creates a new counted set.CountedSet(int size)
Creates a new counted set of the specified initial size.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.
-
-
-
Method Detail
-
add
public boolean add(E o)
-
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 aCountedSet
.- 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 aCountedSet
.- 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 aCountedSet
.- Parameters:
fileName
-countCutoff
-delim
-encoding
-
-
addAll
public boolean addAll(java.util.Collection<? extends E> c)
-
clear
public void clear()
-
contains
public boolean contains(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<E> iterator()
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
size
public int size()
-
toArray
public java.lang.Object[] toArray()
-
-