This module provides collections, iteration support, stacks, collection observation and bit I/O.
Batcher
Iterables and Iterators
Maps
Sets
Stack
Collection Watching
Dependencies | Class Diagrams | Package Diagrams | Javadoc
<dependency>
<groupId>com.telenav.kivakit</groupId>
<artifactId>kivakit-collections</artifactId>
<version>1.5.0</version>
</dependency>
The Batcher class combines an ArrayBlockingQueue with an ExecutorService to create a batch-processor which aggregates elements in batches and processes them with a set of worker threads. A batcher is created like this, passing in the maximum number of batches in the queue and the size of each batch:
Batcher<Record> batcher = new Batcher<>("RecordBatcher", Maximum._16, Count.16_384)
{
protected void onBatch( Batch batch)
{
for (var record : batch)
{
[...]
}
}
};
The batcher lifecycle then looks like this:
batcher.start(Count._8);
[...]
batcher.adder().add(record);
[...]
batcher.close();
Several implementations of the Java Iterable and Iterator interfaces are available:
- DeduplicatingIterable / DeduplicatingIterator - Wraps an Iterable or Iterator an iterates through all elements, keeping a set of elements that have been seen. Elements that have already been seen are skipped.
- FilteredIterable / FilteredIterator - Wraps an Iterable or Iterator, returning only elements that match the given Matcher.
- CompoundIterator - Combines a sequence of iterators into a single iterator
- EmptyIterator - An Iterator with no elements
- SingletonIterator - An Iterator with a single element
The available implementations of the Map interface in kivakit-core-collections extend the abstract base class, BaseMap, from kivakit-core-kernel:
- CacheMap - A most-recently-used (MRU) map which caches elements up to a maximum capacity
- CaseFoldingStringMap - A StringMap implementation which is case-independent
- LinkedMap - A map that uses LinkedHashMap as its implementation
- ReferenceCountMap - A map that counts the number of references to its key type
- TwoWayMap - A map that can also map from value back to key
- MultiMap - A map from a single key to a list of values
- MultiSet - A map from a single key to a set of values
The set package provides several useful implementations of BaseSet as well as a set differencer that determines what changes are required to turn one set into another.
- CompoundSet - A set of sets that logically combines the sets without creating a new set
- ConcurrentHashSet - A hash set implementation that is thread-safe
- IdentitySet - A set based on reference and not the hashCode() / equals() contract
- LogicalSet - An operation applied to two sets that logically combines the sets without actually combining the sets. Implementations include Intersection, Subset, Union and Without
- SetDifferencer - Determines what changes are required to turn one set into another
The Stack class is a subclass of ObjectList which adds push() and pop() methods.
The watcher package contains a BaseCollectionChangeWatcher for observing changes to collections of objects (for example, a set of File objects). This base is extended by PeriodicCollectionChangeWatcher which observes a given collection at a set Frequency. When the collection of objects changes, one or more methods in CollectionChangeListener is called with information about what changed.
com.telenav.kivakit.collections.lexakai
com.telenav.kivakit.collections.map
com.telenav.kivakit.collections.set
com.telenav.kivakit.collections.set.operations
com.telenav.kivakit.collections.watcher
Javadoc coverage for this project is 69.4%.
Copyright © 2011-2021 Telenav, Inc. Distributed under Apache License, Version 2.0
This documentation was generated by Lexakai. UML diagrams courtesy of PlantUML.