More work on regex, fixed whitespace around && and operator= for vector

This commit is contained in:
Nathan Braswell
2015-06-14 11:13:30 -04:00
parent 36833ec263
commit 48f613a38b
12 changed files with 257 additions and 13 deletions

View File

@@ -8,6 +8,11 @@ fun vector<T>(in:T):vector<T> {
return out
}
fun vector<T>():vector<T> {
var out.construct():vector<T>
return out
}
obj vector<T> (Object) {
var data: T*;
var size: int;
@@ -41,9 +46,8 @@ obj vector<T> (Object) {
}
fun operator=(other:vector<T>):void {
resize(other.size)
for (var i = 0; i < other.size; i++;)
set(i, other.get(i))
destruct()
copy_construct(&other)
}
fun operator+(other:vector<T>):vector<T> {
@@ -101,6 +105,10 @@ obj vector<T> (Object) {
return;
data[index] = dataIn;
}
fun add_all(dataIn: vector<T>): void {
for (var i = 0; i < dataIn.size; i++;)
addEnd(dataIn[i]);
}
fun add(dataIn: T): void { addEnd(dataIn); }
fun addEnd(dataIn: T): void {
size++;
@@ -112,6 +120,10 @@ obj vector<T> (Object) {
for (var i = 0; i < size; i++;)
func(data[i])
}
fun do<U>(func: fun(T,U):void, extraParam: U):void {
for (var i = 0; i < size; i++;)
func(data[i], extraParam)
}
fun in_place(func: fun(T):T):void {
for (var i = 0; i < size; i++;)
data[i] = func(data[i])