Add simple Grid - List Wrapper Data Structure
This commit is contained in:
parent
0c487f3427
commit
27ef72014e
2 changed files with 113 additions and 0 deletions
22
lib/src/Grid.dart
Normal file
22
lib/src/Grid.dart
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import 'dart:core';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
class Grid<E> extends DelegatingList<E> {
|
||||
final List<E> _internal;
|
||||
final width;
|
||||
final height;
|
||||
|
||||
Grid(int width, int height) : this._(List<E>(width * height), width, height);
|
||||
|
||||
Grid.from(Grid<E> l)
|
||||
: this._(List<E>.from(l.getRange(0, l.length)), l.width, l.height);
|
||||
|
||||
Grid.fromList(List<E> l, int width) : this._(l, width, l.length ~/ width);
|
||||
|
||||
Grid._(l, int w, int h)
|
||||
: _internal = l,
|
||||
width = w,
|
||||
height = h,
|
||||
super(l);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue