mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Remove *_remove from demo and use built-in versions
This commit is contained in:
@@ -403,7 +403,9 @@ unordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_loca
|
|||||||
@builtin
|
@builtin
|
||||||
ordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) {
|
ordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) {
|
||||||
bounds_check_error_loc(loc, index, len(array));
|
bounds_check_error_loc(loc, index, len(array));
|
||||||
copy(array[index:], array[index+1:]);
|
if index+1 < len(array) {
|
||||||
|
copy(array[index:], array[index+1:]);
|
||||||
|
}
|
||||||
pop(array);
|
pop(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ slice_expr_error_hi :: proc "contextless" (file: string, line, column: int, hi:
|
|||||||
}
|
}
|
||||||
|
|
||||||
slice_expr_error_lo_hi :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
slice_expr_error_lo_hi :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
||||||
if 0 <= lo && lo < len && len <= hi && hi <= len do return;
|
if 0 <= lo && lo < len && lo <= hi && hi <= len do return;
|
||||||
handle_error :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
handle_error :: proc "contextless" (file: string, line, column: int, lo, hi: int, len: int) {
|
||||||
fd := os.stderr;
|
fd := os.stderr;
|
||||||
print_caller_location(fd, Source_Code_Location{file, line, column, "", 0});
|
print_caller_location(fd, Source_Code_Location{file, line, column, "", 0});
|
||||||
|
|||||||
@@ -561,20 +561,6 @@ threading_example :: proc() {
|
|||||||
when os.OS == "windows" {
|
when os.OS == "windows" {
|
||||||
fmt.println("# threading_example");
|
fmt.println("# threading_example");
|
||||||
|
|
||||||
unordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) {
|
|
||||||
runtime.bounds_check_error_loc(loc, index, len(array));
|
|
||||||
n := len(array)-1;
|
|
||||||
if index != n {
|
|
||||||
array[index] = array[n];
|
|
||||||
}
|
|
||||||
pop(array);
|
|
||||||
}
|
|
||||||
ordered_remove :: proc(array: ^$D/[dynamic]$T, index: int, loc := #caller_location) {
|
|
||||||
runtime.bounds_check_error_loc(loc, index, len(array));
|
|
||||||
copy(array[index:], array[index+1:]);
|
|
||||||
pop(array);
|
|
||||||
}
|
|
||||||
|
|
||||||
worker_proc :: proc(t: ^thread.Thread) -> int {
|
worker_proc :: proc(t: ^thread.Thread) -> int {
|
||||||
for iteration in 1..5 {
|
for iteration in 1..5 {
|
||||||
fmt.printf("Thread %d is on iteration %d\n", t.user_index, iteration);
|
fmt.printf("Thread %d is on iteration %d\n", t.user_index, iteration);
|
||||||
|
|||||||
Reference in New Issue
Block a user