Skip to content

Commit

Permalink
'append' => 'push'
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Feb 27, 2024
1 parent 9c364f2 commit 6ebee88
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion day12.c3
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn Map* load_heightmap()
continue;
}
}
map.map.append(line);
map.map.push(line);
};
}
return map;
Expand Down
12 changes: 6 additions & 6 deletions day13.c3
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn int parse_list(void* list1, String list_inner)
index++;
}
PacketElement* element = mem::new(PacketElement, { .is_subpacket = false, .value = list_inner[start..(index - 1)].to_int()!! });
packet.append(element);
packet.push(element);
if (index == len) return len;
if (c == ']') return index + 1;
assert(c == ',');
Expand All @@ -89,7 +89,7 @@ fn int parse_list(void* list1, String list_inner)
inner_list.new_init();
index += parse_list(inner_list, list_inner[index..]);
*element = { .is_subpacket = true, .packet = inner_list };
packet.append(element);
packet.push(element);
if (index == len) return len;
c = list_inner[index];
if (c == ']') return index + 1;
Expand Down Expand Up @@ -119,7 +119,7 @@ fn PacketPairs* load_packets()
{
Packet* first = packet_from_line(io::treadline(&f)!!);
Packet* second = packet_from_line(io::treadline(&f)!!);
packet.append({ first, second });
packet.push({ first, second });
if (!f.eof()) io::treadline(&f)!!;
};
}
Expand Down Expand Up @@ -201,7 +201,7 @@ fn void insert_packet(PacketList* list, Packet* new_packet)
return;
}
}
list.append(new_packet);
list.push(new_packet);
}

fn Packet* create_div(int value)
Expand All @@ -214,8 +214,8 @@ fn Packet* create_div(int value)
inner_packet.new_init();
PacketElement* element_inner = mem::alloc(PacketElement);
*element_inner = { .value = value };
inner_packet.append(element_inner);
packet.append(element);
inner_packet.push(element_inner);
packet.push(element);
return packet;
}
fn void part2(PacketPairs* packets)
Expand Down
2 changes: 1 addition & 1 deletion day15.c3
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn CoordPairList load_sensors()
String[] parts = line.tsplit(": closest beacon is at x=");
int[<2>] sensor_at = parse_coord(parts[0])!!;
int[<2>] beacon_at = parse_coord(parts[1])!!;
list.append( { sensor_at, beacon_at });
list.push( { sensor_at, beacon_at });
};
}
return list;
Expand Down
2 changes: 1 addition & 1 deletion day16.c3
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn Valve[] load_valves(Valve[100]* available_slots)
if (!v.rate) continue;
foreach (&v2 : valves)
{
v2.list.append({ i, v2.tunnel_cost[i] });
v2.list.push({ i, v2.tunnel_cost[i] });
}
}
assert(count == v.count);
Expand Down
2 changes: 1 addition & 1 deletion day19.c3
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn void load_blueprints()
[OBSIDIAN] = split2[1][..^11].to_int()!!
};
print.max_cost = math::max(math::max(math::max(print.geode_cost, print.obsidian_cost), print.clay_cost), print.ore_cost);
blueprints.append(print);
blueprints.push(print);
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions day20.c3
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ fn void load_crypto(LongList* list, LongList* pos, long key)
@pool()
{
String line = io::treadline(&f)!!;
list.append(key * line.to_long()!!);
pos.append((int)pos.len());
list.push(key * line.to_long()!!);
pos.push((int)pos.len());
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion day21.c3
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn void load_monkeys(MonkeyList* list, MonkeyId* root_index, MonkeyId *humn_inde
}
}
map.set(name, index++);
list.append(m);
list.push(m);
};
}
foreach (&monkey : list)
Expand Down
4 changes: 2 additions & 2 deletions day23.c3
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ fn void load_map(CharsArray* list)
String line = io::treadline(&f)!!;
width = line.len;
line = ((String)&spacing).tconcat(line);
list.append(line.tconcat((String)&spacing).copy());
list.push(line.tconcat((String)&spacing).copy());
};
}
String top_line = (String)mem::alloc_array(char, width + PADDING * 2);
top_line[..] = '.';
for (int i = 0; i < PADDING; i++)
{
list.insert_at(0, top_line.copy());
list.append(top_line.copy());
list.push(top_line.copy());
}
}

Expand Down
2 changes: 1 addition & 1 deletion day7.c3
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn void parse_dir(Directory *top)
if (line[0..2] == "dir")
{
Directory *new_dir = mem::temp_new(Directory, { .name = line[4..], .parent_dir = current_dir });
current_dir.other_dirs.append(new_dir);
current_dir.other_dirs.push(new_dir);
continue;
}
String[] split = line.tsplit(" ");
Expand Down
2 changes: 1 addition & 1 deletion day8.c3
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn Forest* parse_forest()
{
String line = io::treadline(&f)!!;
assert(line.len);
forest.append(line);
forest.push(line);
}
return forest;
}
Expand Down

0 comments on commit 6ebee88

Please sign in to comment.