Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidje13/multivaluecollections
Java collections for multiple object types in one collection
https://github.com/davidje13/multivaluecollections
java
Last synced: 27 days ago
JSON representation
Java collections for multiple object types in one collection
- Host: GitHub
- URL: https://github.com/davidje13/multivaluecollections
- Owner: davidje13
- License: other
- Created: 2018-08-17T01:30:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-17T01:30:53.000Z (over 6 years ago)
- Last Synced: 2024-10-20T02:38:58.752Z (3 months ago)
- Topics: java
- Language: Java
- Homepage:
- Size: 63.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Multivalue Collections
Java collection classes for situations where multiple types of object need to
live in one collection.Collections are immutable. Populating collections with values is achieved via
builders.## Path
Paths store a node-edge-node-edge-node pattern. They always start and finish on
a node.The types of path supported are:
- `LinkedPath` (backed by a doubly-linked-list)
- `ArrayPath` (backed by an array)The API for both is identical. The common interface is `ImmutablePath`.
### Example
```java
import com.davidje13.path.*;ImmutablePath path = LinkedPath.builder("node 1")
.pushBack("edge 1", "node 2")
.pushBack("edge 2", "node 3")
.build();List nodes = path.getNodesFromHead();
// nodes = ["node 1", "node 2", "node 3"]List seen = new ArrayList();
path.visitFromHead(
(node) -> seen.add(node),
(edge) -> seen.add(edge)
);
// seen = ["node 1", "edge 1", "node 2", "edge 2", "node 3"]
```