Compare commits
No commits in common. "1b6d48d14bb87be48279544f959510a11790edad" and "5f7b1107d177ea7c0e71211c53ec7bdf811e72d3" have entirely different histories.
1b6d48d14b
...
5f7b1107d1
5 changed files with 2 additions and 53 deletions
2
TODO
2
TODO
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
[Judah]
|
||||
017 [x] re-implement dynamic arrays (should mirror procedures on 'Static_Array')
|
||||
073 [array] standardize api across types (also add 'find' and 'find_pointer')
|
||||
|
||||
[Jesse]
|
||||
011 [math] add more Vec math procedures
|
||||
|
|
@ -83,4 +84,3 @@
|
|||
034 [x] can we add location info to Allocator_Proc?
|
||||
012 [map] create a simple arena-backed hash map implementation 'Map(K, V)', should be able to hash a key of any type (must include: get, set, remove, for_expansion) - possibly blocked by 032
|
||||
065 [array] add dynamic, but stable array implementation (values should not move in memory once appended to the array; should mirror procedures on 'Static_Array')
|
||||
073 [array] standardize api across types (also add 'find' and 'find_pointer')
|
||||
|
|
|
|||
|
|
@ -29,15 +29,6 @@ reset :: inline (arr: *[..]$T) {
|
|||
arr.count = 0;
|
||||
}
|
||||
|
||||
find :: (a: [..]$T, $predicate: (T) -> bool) -> T, bool, int {
|
||||
for a if inline predicate(it) return it, true, it_index;
|
||||
return mem.undefined_of(T), false, -1;
|
||||
}
|
||||
|
||||
find_pointer :: (a: *[..]$T, $predicate: (T) -> bool) -> *T, bool, int {
|
||||
for * a if inline predicate(it.*) return it, true, it_index;
|
||||
return null, false, -1;
|
||||
}
|
||||
|
||||
#scope_file;
|
||||
|
||||
|
|
|
|||
|
|
@ -51,16 +51,6 @@ reset :: (a: *Stable_Array) {
|
|||
a.chunks.count = 0;
|
||||
}
|
||||
|
||||
find :: (a: Stable_Array, $predicate: (a.T) -> bool) -> a.T, bool, int {
|
||||
for a if inline predicate(it) return it, true, it_index;
|
||||
return mem.undefined_of(a.T), false, -1;
|
||||
}
|
||||
|
||||
find_pointer :: (a: *Stable_Array, $predicate: (a.T) -> bool) -> *a.T, bool, int {
|
||||
for * a if inline predicate(it.*) return it, true, it_index;
|
||||
return null, false, -1;
|
||||
}
|
||||
|
||||
operator [] :: (a: Stable_Array, index: int, loc := #caller_location) -> a.T #no_abc {
|
||||
cidx := index / a.items_per_chunk;
|
||||
iidx := index % a.items_per_chunk;
|
||||
|
|
@ -174,17 +164,6 @@ try_lazy_init :: (a: *Stable_Array) {
|
|||
|
||||
for * a it.* = 1;
|
||||
for a test.expect(t, it == 1);
|
||||
|
||||
ptr, ok, idx := find_pointer(*a, v => v == 1);
|
||||
test.expect(t, ok);
|
||||
test.expect(t, idx == 0);
|
||||
test.expect(t, ptr == *a[0]);
|
||||
|
||||
a[a.count - 1] = -1;
|
||||
|
||||
_, ok, idx = find(a, v => v == -1);
|
||||
test.expect(t, ok);
|
||||
test.expect(t, idx == a.count - 1);
|
||||
});
|
||||
|
||||
test.run("stability", t => {
|
||||
|
|
|
|||
|
|
@ -33,16 +33,6 @@ reset :: inline (a: *Static_Array) #no_abc {
|
|||
a.count = 0;
|
||||
}
|
||||
|
||||
find :: (a: Static_Array, $predicate: (a.T) -> bool) -> a.T, bool, int {
|
||||
for a if inline predicate(it) return it, true, it_index;
|
||||
return mem.undefined_of(a.T), false, -1;
|
||||
}
|
||||
|
||||
find_pointer :: (a: *Static_Array, $predicate: (a.T) -> bool) -> *a.T, bool, int {
|
||||
for * a if inline predicate(it.*) return it, true, it_index;
|
||||
return null, false, -1;
|
||||
}
|
||||
|
||||
operator [] :: inline (a: Static_Array, $$index: int, loc := #caller_location) -> a.T #no_abc {
|
||||
meta.check_bounds(index, a.count, loc = loc);
|
||||
return a.items[index];
|
||||
|
|
@ -107,11 +97,5 @@ basic :: #import "Basic"; // @future
|
|||
|
||||
append(*a, 10, 20, 30);
|
||||
test.expect(t, a.count == 3, "count: %", a.count);
|
||||
|
||||
_, ok := find(a, v => v == 10);
|
||||
test.expect(t, ok);
|
||||
|
||||
_, ok = find_pointer(*a, v => v == 20);
|
||||
test.expect(t, ok);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,8 @@ default_of :: ($T: Type) -> T #expand {
|
|||
return default;
|
||||
}
|
||||
|
||||
undefined_of :: ($T: Type) -> T #expand {
|
||||
uninit: T = ---;
|
||||
return uninit;
|
||||
}
|
||||
|
||||
zero_of :: ($T: Type) -> T #expand {
|
||||
zero := undefined_of(T);
|
||||
zero: T = ---;
|
||||
memset(*zero, 0, size_of(T));
|
||||
return zero;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue