Add list data type

This commit is contained in:
zontreck 2024-08-22 14:11:33 -07:00
parent 5965b3205c
commit 97bc0d3a5f
2 changed files with 55 additions and 1 deletions

54
lib/omv/types/list.dart Normal file
View file

@ -0,0 +1,54 @@
import 'package:libac_dart/nbt/Stream.dart';
class list {
List<dynamic> _list = [];
list([List<dynamic>? args]) {
_list = args ?? [];
}
int get count => _list.length;
void add(dynamic entry) {
_list.add(entry);
}
void addRange(list other) {
_list.addAll(other.toList());
}
void insert(int index, dynamic value) {
_list.insert(index, value);
}
dynamic operator [](int index) => _list[index];
void operator []=(int index, dynamic value) => _list[index] = value;
List<dynamic> toList() {
return List.from(_list);
}
list operator +(dynamic other) {
var newList = list(toList());
if (other is list)
newList.addRange(other);
else
newList.add(other);
return newList;
}
void remove(int index) {
_list.removeAt(index);
}
@override
int get hashCode => _list.hashCode;
/// This overridden method will return a CSV string with a space after each comma. Default behavior is that vectors and rotations will have their toString method invoked
@override
String toString() {
return _list
.join(", "); // This should trigger the ToString method on each element.
}
}

View file

@ -1,6 +1,6 @@
name: libac_dart
description: "Aria's Creations code library"
version: 1.2.082224+1252
version: 1.2.082224+1411
homepage: "https://zontreck.com"