https://github.com/raydac/mi-stack
Yet another stack
https://github.com/raydac/mi-stack
stack utility-library
Last synced: 9 months ago
JSON representation
Yet another stack
- Host: GitHub
- URL: https://github.com/raydac/mi-stack
- Owner: raydac
- License: apache-2.0
- Created: 2022-04-24T17:11:46.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-06-13T10:17:30.000Z (about 1 year ago)
- Last Synced: 2025-06-13T11:26:58.310Z (about 1 year ago)
- Topics: stack, utility-library
- Language: Java
- Homepage:
- Size: 202 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.txt
- License: LICENSE
Awesome Lists containing this project
README

[](http://www.apache.org/licenses/LICENSE-2.0)
[](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
[](http://search.maven.org/#artifactdetails|com.igormaznitsa|mi-stack|2.0.0|jar)
[](https://www.arthursacresanimalsanctuary.org/donate)
# Changelog
__2.0.0 (15-jun-2025)__
- improved generics for more flexible object processing
__1.0.3 (18-aug-2024)__
- fix and test improvements
# What is it?
Just abstract stack allows to mark its items by tags and get elements through either stream or iterator with possibility to filter items and stop iterator.
# Implementations
## Thread unsafe
- __MiStackArray__, based on dynamically growing array, also growing can be disabled and in the case it works with internal fixed size array.
- __MiStackArrayList__, based on java.util.ArrayList.
- __MiStackLinked__, it uses own internal implementation of linked list.
- __MiStackLinkedList__, based on java.util.LinkedList.
## Thread safe
- __MiStackConcurrent__, it uses as base _java.util.concurrent.ConcurrentLinkedDeque_.
## Abstract ones
- __AbstractMiStackList__, it allows build MiStack implementation around a _java.util.List_ collection.
- __AbstractMiStackDeque__, it allows build MiStack implementation around a _java.util.Deque_ collection.
# Use with Maven
Just add the snippet into the list of dependencies
```xml
com.igormaznitsa
mi-stack
2.0.0
```
# Example
The example below shows minimal use case with pushing several tagged items on the stack and iteration through them with
predicated streams.
```java
var tagStar = MiStackTagImpl.tagsOf("star");
var tagPlanet = MiStackTagImpl.tagsOf("planet");
var tagPlanetoids = MiStackTagImpl.tagsOf("planetoids");
var tagAsteroid = MiStackTagImpl.tagsOf("asteroid");
var tagSatellite = MiStackTagImpl.tagsOf("satellite");
try (var stack = new MiStackArrayList<>()) {
stack.push(MiStackItemImpl.itemOf("Sun", tagStar));
stack.push(MiStackItemImpl.itemOf("Mercury", tagPlanet));
stack.push(MiStackItemImpl.itemOf("Venus", tagPlanet, tagSatellite));
stack.push(MiStackItemImpl.itemOf("Earth", tagPlanet, tagSatellite));
stack.push(MiStackItemImpl.itemOf("Moon", tagPlanetoids, tagSatellite));
stack.push(MiStackItemImpl.itemOf("Mars", tagPlanet));
stack.push(MiStackItemImpl.itemOf("Phobos", tagAsteroid, tagSatellite));
stack.push(MiStackItemImpl.itemOf("Demos", tagAsteroid, tagSatellite));
stack.push(MiStackItemImpl.itemOf("Jupiter", tagPlanet));
stack.push(MiStackItemImpl.itemOf("Saturn", tagPlanet));
stack.push(MiStackItemImpl.itemOf("Uranus", tagPlanet));
stack.push(MiStackItemImpl.itemOf("Neptune", tagPlanet));
stack.push(MiStackItemImpl.itemOf("Pluto", tagPlanetoids));
assertArrayEquals(new Object[] {"Sun"}, stack.stream(MiStack.allTags(tagStar)).map(MiStackItem::getValue).toArray());
assertArrayEquals(new Object[] {"Pluto", "Moon"},stack.stream(MiStack.allTags(tagPlanetoids)).map(MiStackItem::getValue).toArray());
assertArrayEquals(new Object[] {"Neptune", "Uranus", "Saturn", "Jupiter", "Mars", "Earth", "Venus","Mercury"}, stack.stream(MiStack.allTags(tagPlanet)).map(MiStackItem::getValue).toArray());
assertArrayEquals(new Object[] {"Pluto", "Neptune", "Uranus", "Saturn", "Jupiter", "Mars", "Moon", "Earth", "Venus", "Mercury"},stack.stream(MiStack.anyTag(tagPlanet, tagPlanetoids)).map(MiStackItem::getValue).toArray());
}
```