net.markenwerk:commons-datastructures

Some common datastructures for Java

License

License

Categories

Categories

Data Net
GroupId

GroupId

net.markenwerk
ArtifactId

ArtifactId

commons-datastructures
Last Version

Last Version

1.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

net.markenwerk:commons-datastructures
Some common datastructures for Java
Project URL

Project URL

https://github.com/markenwerk/java-commons-datastructures
Project Organization

Project Organization

Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH
Source Code Management

Source Code Management

https://github.com/markenwerk/java-commons-datastructures

Download commons-datastructures

How to add to project

<!-- https://jarcasting.com/artifacts/net.markenwerk/commons-datastructures/ -->
<dependency>
    <groupId>net.markenwerk</groupId>
    <artifactId>commons-datastructures</artifactId>
    <version>1.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.markenwerk/commons-datastructures/
implementation 'net.markenwerk:commons-datastructures:1.3.1'
// https://jarcasting.com/artifacts/net.markenwerk/commons-datastructures/
implementation ("net.markenwerk:commons-datastructures:1.3.1")
'net.markenwerk:commons-datastructures:jar:1.3.1'
<dependency org="net.markenwerk" name="commons-datastructures" rev="1.3.1">
  <artifact name="commons-datastructures" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.markenwerk', module='commons-datastructures', version='1.3.1')
)
libraryDependencies += "net.markenwerk" % "commons-datastructures" % "1.3.1"
[net.markenwerk/commons-datastructures "1.3.1"]

Dependencies

compile (1)

Group / Artifact Type Version
net.markenwerk : commons-interfaces jar 4.0.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Some common datastructures for Java

Build Status Dependency Status Maven Central Java SE 6 MIT License

This is a collection of some common datastructures that describe everyday use cases. It is mainly intended for API providers who don't want to redeclare somewhat trivial datastructures all the time.

Overview

This library is hosted in the Maven Central Repository. You can use it with the following coordinates:

<dependency>
	<groupId>net.markenwerk</groupId>
	<artifactId>commons-datastructures</artifactId>
	<version>1.3.1</version>
</dependency>

Consult the usage description and Javadoc for further information.

Datastructures

Box

This library provides the generic Box, which is an mutable container class that holds a single value.

Foo value = ...

// creates a container that holds value
Box<Foo> box = new Box<>(value);

// returns the contained value
box.getValue();

// update the contained value
box.setValue(new Foo(...));

Wrapper

This library provides the generic Wrapper, which is an immutable container class that holds a single value.

Foo value = ...

// creates a container that holds value
Wrapper<Foo> wrapper = new Wrapper<>(value);

// returns the contained value
wrapper.getValue();

Optional

This library provides the generic Optional, which is an immutable container class that may hold a single value.

Foo value = ...

// creates a container that holds no value
Optional<Foo> emptyOptional = new Optional<>();

// creates a container that holds value
Optional<Foo> optional = new Optional<>(value);

// returns the contained value
optional.getValue();

// returns whether the optional has a value
optional.hasValue();

Pair

This library provides the generic Pair, which is an immutable container class that holds two values of similar type.

Foo first = ...
Foo second = ...

// creates a container that holds first and second
Pair<Foo> pair = new Pair<>(first, second);

// returns the contained values
pair.getFirst();
pair.getSecond();

// creates new pair with one changed value
pair.withFirst(new Foo(...));
pair.withSecond(new Foo(...));

Tuple

This library provides the generic Tuple, which is an immutable container class that holds two values of different type.

Foo first = ...
Bar second = ...

// creates a container that holds first and second
Tuple<Foo, Bar> tuple = new Tuple<>(first, second);

// returns the contained values
tuple.getFirst();
tuple.getSecond();

// creates new tuple with one changed value
tuple.withFirst(new Foo(...));
tuple.withSecond(new Bar(...));

Triple

This library provides the generic Triple, which is an immutable container class that holds three values of different type.

Foo first = ...
Bar second = ...
Baz third = ...

// creates a container that holds first, second and third
Triple<Foo, Bar, Baz> triple = new Triple<>(first, second, third);

// returns the contained values
triple.getFirst();
triple.getSecond();
triple.getThird();

// creates new triple with one changed value
triple.withFirst(new Foo(...));
triple.withSecond(new Bar(...));
triple.withThird(new Baz(...));

Entry

This library provides the generic Entry, which is an immutable container class that a key-value-pair.

Key key = ...
Value value = ...

// creates a container that holds key and value
Entry<Key, Value> entry = new Entry<>(key, value);

// returns the contained values
entry.getKey();
entry.getValue();

Either

This library provides the generic Either, which is one of two distinct immutable container class that hold a single value; Left and Right.

Foo foo = ...
Bar bar = ...

// creates a left container that holds foo
Either<Foo, Bar> left = new Left<>(foo);

// creates a right container that holds bar
Either<Foo, Bar> right = new Right<>(bar);

// returns true
left.isLeft();
right.isRight();

// returns the contained values
left.getLeft();
right.getRight();

// returns false
left.isRight();
right.isLeft();
net.markenwerk

Markenwerk

Versions

Version
1.3.1
1.3.0
1.2.2
1.2.1
1.2.0
1.1.5
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0