https://github.com/samchon/ecol
Event Collections
https://github.com/samchon/ecol
collection deque event hashmap list stl treemap typescript vector
Last synced: about 2 months ago
JSON representation
Event Collections
- Host: GitHub
- URL: https://github.com/samchon/ecol
- Owner: samchon
- License: mit
- Created: 2018-03-08T14:28:16.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-14T11:21:35.000Z (over 5 years ago)
- Last Synced: 2025-04-20T03:32:20.257Z (about 2 months ago)
- Topics: collection, deque, event, hashmap, list, stl, treemap, typescript, vector
- Language: TypeScript
- Homepage:
- Size: 55.7 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# **E**vent **Col**lections
[](https://github.com/samchon/ecol/blob/master/LICENSE)
[](https://www.npmjs.com/package/ecol)
[](https://www.npmjs.com/package/ecol)
[](https://github.com/samchon/ecol/actions?query=workflow%3Abuild)
[](https://gitter.im/samchon/ecol?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)Extension of [TypeScript-STL](https://github.com/samchon/tstl) **Con**tainers dispatching **E**vents.
**TSTL** is an open-source project providing features of STL, migrated from *C++* to *TypeScript*. You can enjoy the STL's own specific *containers*, *algorithms* and *functors* in the JavaScript. If TypeScript, you also can take advantage of type restrictions and generic programming with the TypeScript.
**ECOL** is an extension module of such **TSTL**, providing special collections dispatching events. The special collections are almost similar with the original STL Containers, but you also can observe elements' I/O events with the special collections. Types of the event dispatched by the special collections are `"insert"`, `"erase"` and `"refresh"`.
## Features
### Linear Collections
- ArrayCollection
- DequeCollection
- ListCollection### Set Containers
- *Tree-based Collections*
- TreeSetCollection
- TreeMultiSetCollection
- *Hash-buckets based Collections*
- HashSetCollection
- HashMultiSetCollection### Map Collections
- *Tree-based Collections*
- TreeMapCollection
- TreeMultiMapCollection
- *Hash-buckets based Collections*
- HashMapCollection
- HashMultiMapCollection## Installation
### NPM Module
Installing **ECOL** in *NodeJS* is very easy. Just install with the `npm`.```bash
# Install TSTL from the NPM module
npm install --save ecol
```### Usage
``` typescript
import {TreeMapCollection} from "ecol";function listener(event: TreeMapCollection.Event): void
{
console.log("Event type is: " + event.type);for (let it = event.first; !it.equals(event.last); it = it.next())
console.log("\t", "An element by that event:", it.value);
}function main(): void
{
// CONSTRUCT EVENT TREE-MAP
let map: TreeMapCollection = new TreeMapCollection();
map.addEventListener("insert", listener);
map.addEventListener("erase", listener);// DISPATCHES INSERT EVENT
map.set(1, "One");
map.set(2, "Two");
map.set(3, "Three");// DISPATCHES ERASE EVENT
map.erase(2);
map.erase(3);// DISPATCHES REFRESH EVENT
map.set(2, "Second"); // AUTOMATIC
map.refresh(); // BY USER
}
main();
```## References
- **Repositories**
- [GitHub Repository](https://github.com/samchon/ecol)
- [NPM Repository](https://www.npmjs.com/package/ecol)
- **Documents**
- [**Guide Documents**](https://github.com/samchon/ecol/wiki)
- [API Documents](http://samchon.github.io/ecol/api)
- **Dependency**
- [TypeScript-STL](https://github.com/samchon/tstl)