https://github.com/lpogic/suite
Uniwersalny kontener
https://github.com/lpogic/suite
data-structures java
Last synced: 8 months ago
JSON representation
Uniwersalny kontener
- Host: GitHub
- URL: https://github.com/lpogic/suite
- Owner: lpogic
- Created: 2020-06-06T09:50:19.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-22T19:05:02.000Z (about 4 years ago)
- Last Synced: 2025-02-04T22:39:21.656Z (about 1 year ago)
- Topics: data-structures, java
- Language: Java
- Homepage:
- Size: 667 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# suite
Uniwersalny kontener. Mapa pamiętająca kolejność dodawania. Stosuje luźne podejście do typów.
# Przykłady
W nazewnictwie przyjęto zasadę, że obiekty klasy Subject (czyli tworzonego przez Suite/$uite) dostają prefix '$'.
W przykładach użyto notacji BracketTree
## 1. Utwórz zbiór liczb od 1 do 5:
```
1 [] 2 [] 3 [] 4 [] 5
```
## ⇩
```
var $set = Suite.set(1, 2, 3, 4, 5);
```
albo przy statycznym użyciu metod $uite (`import static suite.suite.$uite.*;`):
```
var $set = $(1, 2, 3, 4, 5);
```
## 2. Utwórz listę liczb od 1 do 5:
```
[ 1 ][ 2 ][ 3 ][ 4 ][ 5 ]
```
## ⇩
```
var $list = Suite.add(1, 2, 3, 4, 5);
```
albo przy statycznym użyciu metod $uite (`import static suite.suite.$uite.*;`):
```
var $list = $($(1), $(2), $(3), $(4), $(5));
```
## 3. Utwórz mapę jak poniżej:
```
1 [ a ]
2 [ b ]
3 [ c ]
```
## ⇩
```
var $map = Suite.put(1, 'a').put(2, 'b').put(3, 'c');
```
albo przy statycznym użyciu metod $uite (`import static suite.suite.$uite.*;`):
```
var $map = $(
1, $('a'),
2, $('b'),
3, $('c')
);
```
## 4. Utwórz drzewo:
```
1 [ 1 ]
2 [ 1 [] 2 ]
3 [ 1 [] 3 ]
4 [
1 []
2 [ 1 [] 2 ]
4 []
]
```
## ⇩
```
var $tree = Suite.put(1, 1)
.input(2, Suite.set(1, 2))
.input(3, Suite.set(1, 3))
.input(4, Suite.set(1)
.input(2, Suite.set(1, 2))
.set(4));
```
albo przy statycznym użyciu metod $uite (`import static suite.suite.$uite.*;`):
```
var $map = $(
1, $(1),
2, $(1, 2),
3, $(1, 3),
4, $(1, 2, $(1, 2), 4)
);
```
## 5. Utwórz graf:
```
[
#[ a ]
[ #b ]
][
#[ b ]
[ #c ]
][
#[ c ]
[ #a ]
]
```
## ⇩
```
var $c = Suite.set();
var $b = Suite.inset($c);
var $a = Suite.inset($b);
$c.inset($a);
```