https://github.com/pharo-containers/containers-uniqueordered
To get unique (set) but ordered collection.
https://github.com/pharo-containers/containers-uniqueordered
collections pharo
Last synced: about 1 year ago
JSON representation
To get unique (set) but ordered collection.
- Host: GitHub
- URL: https://github.com/pharo-containers/containers-uniqueordered
- Owner: pharo-containers
- Created: 2018-05-08T19:48:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-26T19:41:48.000Z (about 1 year ago)
- Last Synced: 2025-03-26T20:33:36.749Z (about 1 year ago)
- Topics: collections, pharo
- Language: Smalltalk
- Size: 18.6 KB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Containers-UniqueOrdered
To get unique (set) but ordered collection.
This package contains two collections: one that is an ordered set and one that is an ordered collection with unique items.
[](https://img.shields.io/badge/license-MIT-blue.svg)

## Example
```
CTUniqueOrderedTest >> testAddBeforeOfTwiceTheSame [
collection add: 1.
collection add: 33.
collection add: 1.
self assert: collection size equals: 2.
"1 33"
collection add: 2 before: 33.
"1 2 33"
self assert: collection size equals: 3.
self assert: (collection indexOf: 2) equals: 2.
self assert: (collection indexOf: 1) equals: 1.
self assert: (collection indexOf: 33) equals: 3.
"now we add again 2"
collection add: 2 before: 1.
"2 1 33"
self assert: collection size equals: 3.
self assert: (collection indexOf: 2) equals: 1.
self assert: (collection indexOf: 1) equals: 2.
self assert: (collection indexOf: 33) equals: 3.
]
```
## Loading
```
Metacello new
baseline: 'ContainersUniqueOrdered';
repository: 'github://pharo-containers/Containers-UniqueOrdered';
load.
```
## If you want to depend on it:
```
spec
baseline: 'ContainersUniqueOrdered'
with: [ spec repository: 'github://pharo-containers/Containers-UniqueOrdered/src' ].
```
This package is part of the Containers project: This project is to collect, clean, test and document alternate collection datastructures.
Each package is modular so that users can only load the collection they need without 100 of related collections.