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 a getFileName() method and overrides toString() 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 deterministic hashCode() method. Instantiate this instead of Object 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 its equals() 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.