We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
temp_init_from_map
Example code:
import std::io; import std::collections::map; def Vector2 = int[<2>]; fn uint Vector2.hash(self) => self.x * 31 + self.y; HashMap(<Vector2, Vector2>) visited_positions; fn void main() { visited_positions.set({1,10}, {0,-1}); visited_positions.set({1,5}, {0,-1}); visited_positions.set({1,6}, {0,-1}); visited_positions.set({1,7}, {0,-1}); visited_positions.set({3,5}, {0,1}); visited_positions.@each(;Vector2 pos, Vector2 dir) { io::printfn("%s: %s", pos, dir); }; io::printn("Copy:"); HashMap(<Vector2, Vector2>) visited_positions_copy; visited_positions_copy.temp_init_from_map(&visited_positions); visited_positions_copy.@each(;Vector2 pos, Vector2 dir) { io::printfn("%s: %s", pos, dir); }; }
Running this with c3c compile-run test.c3 will result in following output:
c3c compile-run test.c3
Program linked to executable 'test'. Launching ./test [<3, 5>]: [<0, 1>] [<1, 7>]: [<0, -1>] [<1, 5>]: [<0, -1>] [<1, 6>]: [<0, -1>] [<1, 10>]: [<0, -1>] Copy: [<3, 5>]: [<0, 1>] [<1, 5>]: [<0, -1>] [<1, 6>]: [<0, -1>] [<1, 10>]: [<0, -1>]
As you can see, [<1, 7>]: [<0, -1>] is missing in the copied HashMap.
[<1, 7>]: [<0, -1>]
The text was updated successfully, but these errors were encountered:
Managed to get even simpler repro:
import std::io; import std::collections::map; def Map = HashMap(<String, usz>); fn void main() { Map map; map.temp_init(); map.set("aa", 1); map.set("b", 2); map.set("bb", 1); Map map_copy; map_copy.temp_init_from_map(&map); map_copy.@each(;String key, usz val) { io::printfn("%s: %s", key, val); }; }
Sorry, something went wrong.
Fix hashmap put all for create + test case
b809bcb
Closes: c3lang#1695
Successfully merging a pull request may close this issue.
Example code:
Running this with
c3c compile-run test.c3
will result in following output:As you can see,
[<1, 7>]: [<0, -1>]
is missing in the copied HashMap.The text was updated successfully, but these errors were encountered: