skip_iterator.iterator = it;
skip_iterator.to_skip = count;
- next :: ($T: type_expr, si: ^SkipIterator(T)) -> (T, bool) {
+ next :: (si: ^SkipIterator($T)) -> (T, bool) {
while !si.skipped && si.to_skip > 0 {
si.to_skip -= 1;
value, cont := si.iterator.next(si.iterator.data);
return si.iterator.next(si.iterator.data);
}
- close :: ($T: type_expr, si: ^SkipIterator(T)) {
+ close :: (si: ^SkipIterator($T)) {
if si.iterator.close != null_proc do si.iterator.close(si.iterator.data);
cfree(si);
}
zipped_iterator.iterator1 = left_iterator;
zipped_iterator.iterator2 = right_iterator;
- next :: ($T: type_expr, $R: type_expr, zi: ^ZippedIterator(T, R)) -> (Zipped(T, R), bool) {
+ next :: (zi: ^ZippedIterator($T, $R)) -> (Zipped(T, R), bool) {
v1, cont1 := zi.iterator1.next(zi.iterator1.data);
v2, cont2 := zi.iterator2.next(zi.iterator2.data);
return .{ v1, v2 }, cont1 && cont2;
}
- close :: ($T: type_expr, $R: type_expr, zi: ^ZippedIterator(T, R)) {
+ close :: (zi: ^ZippedIterator($T, $R)) {
if zi.iterator1.close != null_proc do zi.iterator1.close(zi.iterator1.data);
if zi.iterator2.close != null_proc do zi.iterator2.close(zi.iterator2.data);
cfree(zi);
}
const :: (value: $T) -> Iterator(T) {
- next :: ($T: type_expr, data: rawptr) -> (T, bool) {
+ next :: (data: ^$T) -> (T, bool) {
return *(cast(^T) data), true;
}
ec.iterator = it;
ec.current_index = start_index;
- next :: ($T: type_expr, use data: ^Enumeration_Context(T)) -> (Enumeration_Value(T), bool) {
+ next :: (use data: ^Enumeration_Context($T)) -> (Enumeration_Value(T), bool) {
value, cont := iterator.next(iterator.data);
if !cont do return .{ current_index, __zero_value(T) }, false;
return .{ current_index, value }, true;
}
- close :: ($T: type_expr, use data: ^Enumeration_Context(T)) {
+ close :: (use data: ^Enumeration_Context($T)) {
if iterator.close != null_proc do iterator.close(iterator.data);
cfree(data);
}
c.count = arr.count;
c.current = 0;
- next :: ($T: type_expr, use _: ^Context(T)) -> (^T, bool) {
+ next :: (use _: ^Context($T)) -> (^T, bool) {
if current < count {
defer current += 1;
return ^data[current], true;
}
}
- array.sort(terminate_rules, (a: Term, b: Term) -> i32 {
- return (cast(i32) a.nt) - (cast(i32) b.nt);
- });
-
- array.sort(production_rules, (a: Prod, b: Prod) -> i32 {
- return (cast(i32) a.nt0) - (cast(i32) b.nt0);
- });
+ array.quicksort(terminate_rules, (a, b) => (cast(i32) a.nt) - (cast(i32) b.nt));
+ array.quicksort(production_rules, (a, b) => (cast(i32) a.nt0) - (cast(i32) b.nt0));
max_terminal = math.max(
production_rules[production_rules.count - 1].nt0,