Package org.plumelib.util
package org.plumelib.util
Plume-lib Util: Utility libraries for Java
Note that HashMap
Util defines other classes in the org.plumelib.util
package.
Collections and iterators
ArraysPlume
- Utilities for manipulating arrays and collections. This complements java.util.Arrays and java.util.Collections.
CollectionsPlume
- Utilities for manipulating collections, iterators, lists, maps, and sets.
CombinationIterator
- Given a set of collections, return all combinations that take one element from each collection.
LimitedSizeSet
- Stores up to some maximum number of unique values, at which point its rep is nulled, in order to save space.
LimitedSizeIntSet
- Stores up to some maximum number of unique integer values, at which point its rep is
nulled, in order to save space. More efficient than
LimitedSizeSet<Integer>
. LimitedSizeLongSet
- Stores up to some maximum number of unique long values, at which point its rep is nulled,
in order to save space. More efficient than
LimitedSizeSet<Long>
. OrderedPairIterator
- Given two sequences/iterators/whatever, OrderedPairIterator returns a new sequence/iterator/whatever that pairs the matching elements of the inputs, according to their respective sort orders. (This operation is sometimes called "zipping".)
Hasher
- See HashMap Util.
WeakHasherMap
- See HashMap Util.
WeakIdentityHashMap
- See HashMap Util.
Text processing
EntryReader
- Class that reads "entries" from a file. In the simplest case, entries can be lines. It supports: include files, comments, and multi-line entries (paragraphs). The syntax of each of these is customizable.
FileIOException
- Extends IOException by also reporting a file name and line number at which the exception occurred.
FilesPlume
- Utility methods that create and manipulate files, directories, streams, readers, and writers.
FileWriterWithName
- Just like
FileWriter
, but adds agetFileName()
method and overridestoString()
to give the file name. RegexUtil
- Utility methods for regular expressions, most notably for testing whether a string is a regular expression.
StringsPlume
- Utility methods that manipulate Strings: replacement; prefixing and indentation; splitting and joining; quoting and escaping; whitespace; comparisons; StringTokenizer; debugging variants of toString; diagnostic output; miscellaneous.
Math
MathPlume
- Mathematical utilities.
FuzzyFloat
- Routines for doing approximate ('fuzzy') floating point comparisons. Those are comparisons that only require the floating point numbers to be relatively close to one another to be equal, rather than exactly equal.
Random selection
RandomSelector
- Selects k elements uniformly at random from an arbitrary iterator, using O(k) space.
MultiRandSelector
- Like RandomSelector, performs a uniform random selection over an iterator. However, the objects in the iteration may be partitioned so that the random selection chooses the same number from each group.
Determinism and immutability
DeterministicObject
- A version of
Object
with a deterministichashCode()
method. Instantiate this instead ofObject
to remove a source of nondeterminism from your programs. ClassDeterministic
- Deterministic versions of
java.lang.Class
methods, which return arrays in sorted order. UniqueId
- An interface for objects that have a unique ID. If you are tempted to print the value of
System.identityHashCode()
, consider using this instead. UniqueIdMap
- Provides a unique ID (like the
UniqueId
class) for classes that you cannot modify. ImmutableTypes
- Indicates which types in the JDK are immutable.
Utility interfaces
Partitioner
- A Partitioner accepts Objects and assigns them to an equivalence class.
JVM runtime system
DumpHeap
- Dumps the heap into a
.hprof
file. SystemPlume
- Utility methods relating to the JVM runtime system: sleep and garbage collection.
Miscellaneous
GraphPlume
- Graph utility methods. This class does not model a graph: all methods are static.
Intern
- Utilities for interning objects. Interning is also known as canonicalization or
hash-consing: it returns a single representative object that
.equals()
the object, and the client discards the argument and uses the result instead. IPair
- Immutable pair class: type-safely holds two objects of possibly-different types.
MPair
- Mutable pair class: type-safely holds two objects of possibly-different types.
WeakIdentityPair
- Immutable pair class with weakly-held values. Differs from
IPair
in the following ways: cannot hold null, holds its elements with weak pointers, clients must use getter methods rather than accessing the fields, and itsequals()
method uses object equality to compare its elements. UtilPlume
- Utility methods that do not belong elsewhere in the plume package: BitSet; File; directories; file names; reading and writing; hashing; ProcessBuilder; properties; Stream; Throwable.
-
ClassDescriptionAbstractMostlySingletonSet<T extends @Signed Object>Base class for arbitrary-size sets that is very efficient (more efficient than HashSet) for 0 and 1 elements.The possible states of this set.A map backed by two arrays.A set backed by an array.Utilities for manipulating arrays.ArraysPlume.ComparableArrayComparatorLengthFirst<T extends Comparable<T>>Compare two arrays first by length (a shorter array is considered less), and if of equal length compare lexically (element-by-element).ArraysPlume.ComparableArrayComparatorLexical<T extends Comparable<T>>Compare two arrays lexically (element-by-element).Compare two arrays lexically (element-by-element).Compare two arrays first by length (a shorter array is considered less), and if of equal length compare lexically (element-by-element).Compare two arrays lexically (element-by-element).Compare two arrays first by length (a shorter array is considered less), and if of equal length compare lexically (element-by-element).Compare two arrays lexically (element-by-element).Compare two arrays first by length (a shorter array is considered less), and if of equal length compare lexically (element-by-element).Compare two arrays lexically (element-by-element).Compare two arrays lexically (element-by-element).Deterministic versions of
java.lang.Class
methods, which return arrays in sorted order.Utility functions for Collections, ArrayList, Iterator, and Map.Converts an Enumeration into an Iterator.CollectionsPlume.FilteredIterator<T extends @Nullable Object>An iterator that only returns elements that match the given predicate.Converts an Iterator into an Enumeration.An Iterator that returns the elements in each of its argument Iterators, in turn.An Iterator that returns first the elements returned by its first argument, then the elements returned by its second argument.Returns an iterator just like its argument, except that the first and last elements are removed.Represents a replacement of one range of a collection by another collection.Given a set of collections, yield each combination that takes one element from each collection.DeepCopyable<T>An interface for types that implement theDeepCopyable.deepCopy()
method.This is a deterministic version of theObject
class.Defines a static methodDumpHeap.dumpHeap(java.lang.String)
that dumps the heap to an .hprof file.Class that reads records or "entries" from a file.Descriptor for an entry (record, paragraph, etc.).This class extends IOException by also reporting a file name and line number at which the exception occurred.Utility methods that create and manipulate files, directories, streams, readers, and writers.A FilenameFilter that accepts files whose name matches the given wildcard.Just likeFileWriter
, but adds aFileWriterWithName.getFileName()
method and overrides#toString()
to give the file name.Deprecated.Routines for doing approximate ('fuzzy') floating-point comparisons.Graph utility methods.IdentityArraySet<E extends @UnknownSignedness Object>A set backed by an array.An arbitrary-size set that is very efficient (more efficient than HashSet) for 0 and 1 elements.Records all the immutable types in the JDK, and can be queried.Utilities for interning objects.IPair<V1,V2> Immutable pair class.LimitedSizeIntSet stores up to some maximum number of unique values.LimitedSizeLongSet stores up to some maximum number of unique values.LimitedSizeSet<T extends @Nullable Object>LimitedSizeSet stores up to some maximum number of unique values.Mathematical utilities.A set that is more efficient than HashSet for 0 and 1 elements.MPair<V1,V2> Mutable pair class.MultiRandSelector<T extends @Nullable Object>Performs uniform random selection over an iterator, where the objects in the iterator may be partitioned so that the random selection chooses the same number from each group.OrderedPairIterator<T extends @Nullable Object>Given two sorted iterators, this class returns a new iterator that pairs equal elements of the inputs, according to the sort order or the given comparator.A Partitioner accepts Objects and assigns them to an equivalence class.RandomSelector selects k elements uniformly at random from an arbitrary iterator, using O(k) space.Utility methods for regular expressions, most notably for testing whether a string is a regular expression.A checked version ofPatternSyntaxException
.Utility functions that manipulate Strings: replacement; prefixing and indentation; splitting and joining; quoting and escaping; whitespace; comparisons; StringTokenizer; debugging variants of toString; diagnostic output; miscellaneous.Deprecated.useComparator.nullsFirst(Comparator.naturalOrder())
Orders Objects according to theirtoString()
representation.Utility methods relating to the JVM runtime system: sleep and garbage collection.A comparator that orders values based on the lexicographic ordering of their toString().An interface for objects that have a unique ID (unique identifier).UniqueIdMap<E>Provides a unique ID for classes that you cannot modify.A wrapper around anIdentityHashMap
that makes it unmodifiable.Utility methods that do not belong elsewhere in the plume package: BitSet; hashing; ProcessBuilder; properties; Throwable.Deprecated.Deprecated.Deprecated.Immutable pair class with weakly-held values.
java.util.function.Predicate