项目作者: pharo-containers

项目描述 :
To get unique (set) but ordered collection.
高级语言: Smalltalk
项目地址: git://github.com/pharo-containers/Containers-UniqueOrdered.git


Containers-UniqueOrdered


Pharo

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.

License
https://github.com/pharo-containers/Containers-UniqueOrdered/workflows/test/badge.svg

Example

  1. CTUniqueOrderedTest >> testAddBeforeOfTwiceTheSame [
  2. collection add: 1.
  3. collection add: 33.
  4. collection add: 1.
  5. self assert: collection size equals: 2.
  6. "1 33"
  7. collection add: 2 before: 33.
  8. "1 2 33"
  9. self assert: collection size equals: 3.
  10. self assert: (collection indexOf: 2) equals: 2.
  11. self assert: (collection indexOf: 1) equals: 1.
  12. self assert: (collection indexOf: 33) equals: 3.
  13. "now we add again 2"
  14. collection add: 2 before: 1.
  15. "2 1 33"
  16. self assert: collection size equals: 3.
  17. self assert: (collection indexOf: 2) equals: 1.
  18. self assert: (collection indexOf: 1) equals: 2.
  19. self assert: (collection indexOf: 33) equals: 3.
  20. ]

Loading

  1. Metacello new
  2. baseline: 'ContainersUniqueOrdered';
  3. repository: 'github://pharo-containers/Containers-UniqueOrdered';
  4. load.

If you want to depend on it:

  1. spec
  2. baseline: 'ContainersUniqueOrdered'
  3. 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.