Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saksmt/util-collections
Util collections for JVM
https://github.com/saksmt/util-collections
Last synced: about 2 months ago
JSON representation
Util collections for JVM
- Host: GitHub
- URL: https://github.com/saksmt/util-collections
- Owner: saksmt
- License: mit
- Created: 2016-01-19T17:51:50.000Z (almost 9 years ago)
- Default Branch: develop
- Last Pushed: 2016-01-19T19:24:25.000Z (almost 9 years ago)
- Last Synced: 2024-01-27T16:20:20.977Z (11 months ago)
- Language: Java
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tk.saksmt.util/collections
Contains some util collection implementations
## Classes
### CyclicCollection
| FQCN | Interfaces | Thread-Safe |
|---------|-------------|:-------:|
| `tk.saksmt.util.collections.CyclicCollection` | `java.util.Collection` | ✓ |#### Description
Collection based on cycled queue (ring buffer for Java Collections) with specified size. Overflow of collection causes cyclic removal from end and addition of new element to head (see an example below)
Consider you have a `CyclicCollection` with size of 3:
| _ |
|:-:|
| _ |
| _ |After addition of 3 elements you'd have:
| 1 |
|:-:|
| 2 |
| 3 |Then you add one more element, let's say `4`, then you'd have:
| 2 |
|:-:|
| 3 |
| 4 |#### Usage
That's an implementation of description above
```java
import tk.saksmt.util.collections.CyclicCollection;Collection collection = new CyclicCollection<>(3);
// Add 3 elements
collection.add(1);
collection.add(2);
collection.add(3);// Add one more
collection.add(4);// And the result
System.out.println(collection); // [ 2 3 4 ]
```## License
This library is licensed under [MIT license](https://github.com/saksmt/util-collections/blob/develop/LICENSE)