https://github.com/localvoid/tuple
Tuple data structure for Dart
https://github.com/localvoid/tuple
Last synced: 12 months ago
JSON representation
Tuple data structure for Dart
- Host: GitHub
- URL: https://github.com/localvoid/tuple
- Owner: localvoid
- License: bsd-2-clause
- Created: 2014-10-17T05:00:22.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-09-20T09:07:35.000Z (over 10 years ago)
- Last Synced: 2025-04-11T21:13:45.130Z (12 months ago)
- Language: Dart
- Size: 249 KB
- Stars: 1
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tuple data structure
There are two versions of this data structure:
- mutable [Tuple2], [Tuple3]...
- persistent [PersistentTuple2], [PersistentTuple3]...
## Usage example
```dart
final t = new Tuple2('a', 10);
print(t.i1); // prints 'a'
print(t.i2); // prints '10'
```
## Persistent Tuple
> In computing, a persistent data structure is a data structure that always
> preserves the previous version of itself when it is modified. Such data
> structures are effectively immutable, as their operations do not (visibly)
> update the structure in-place, but instead always yield a new updated
> structure. (A persistent data structure is not a data structure committed
> to persistent storage, such as a disk; this is a different and unrelated
> sense of the word "persistent.")
>
> [wikipedia](http://en.wikipedia.org/wiki/Persistent_data_structure)
```dart
final t1 = const PersistentTuple2('a', 10);
final t2 = t1.setI1('c');
// t2 is a new [PersistentTuple2] object with i1 is 'c' and i2 is 10.
```