File tree Expand file tree Collapse file tree 5 files changed +8
-38
lines changed
Expand file tree Collapse file tree 5 files changed +8
-38
lines changed Original file line number Diff line number Diff line change 77
88#include < algorithm>
99#include < optional>
10+ #include < set>
1011#include < stdexcept>
1112
1213#include < immer/algorithm.hpp>
@@ -29,28 +30,9 @@ struct NODISCARD ImmOrderedSet final
2930 DEFAULT_RULE_OF_5 (ImmOrderedSet);
3031
3132public:
32- explicit ImmOrderedSet (const Type id )
33- : m_vector{id }
33+ explicit ImmOrderedSet (const std::set<T> &from )
34+ : m_vector{from. begin (), from. end () }
3435 {}
35- explicit ImmOrderedSet (const Vector &other)
36- : m_vector{other}
37- {}
38- explicit ImmOrderedSet (Vector &&other)
39- : m_vector{std::move (other)}
40- {}
41-
42- ImmOrderedSet &operator =(const Vector &other)
43- {
44- if (m_vector == other)
45- return *this ;
46- m_vector = other;
47- return *this ;
48- }
49- ImmOrderedSet &operator =(Vector &&other)
50- {
51- m_vector = std::move (other);
52- return *this ;
53- }
5436
5537public:
5638 NODISCARD size_t size () const { return m_vector.size (); }
Original file line number Diff line number Diff line change @@ -20,15 +20,6 @@ void runRoomIdSetTests()
2020 TEST_ASSERT (!defaultConstructorSet.contains (RoomId (1 )));
2121 TEST_ASSERT (defaultConstructorSet.begin () == defaultConstructorSet.end ());
2222
23- RoomId singleId (42 );
24- Type setWithSingleId (singleId);
25- TEST_ASSERT (!setWithSingleId.empty ());
26- TEST_ASSERT (setWithSingleId.size () == 1ULL );
27- TEST_ASSERT (setWithSingleId.contains (singleId));
28- TEST_ASSERT (!setWithSingleId.contains (RoomId (1 )));
29- TEST_ASSERT (*setWithSingleId.begin () == singleId);
30- TEST_ASSERT (*setWithSingleId.begin () == singleId);
31-
3223 Type setForInsert;
3324 setForInsert.insert (RoomId (10 ));
3425 TEST_ASSERT (!setForInsert.empty ());
Original file line number Diff line number Diff line change @@ -638,10 +638,6 @@ void World::checkConsistency(ProgressCounter &counter) const
638638 };
639639
640640 auto checkRemapping = [this ](const RoomId id) {
641- if (!getRoomSet ().contains (id)) {
642- throw MapConsistencyError (" room set does not contain the room id" );
643- }
644-
645641 const auto &area = getRoomArea (id);
646642 if (!getArea (area).contains (id)) {
647643 throw MapConsistencyError (" room set does not contain the room id" );
@@ -1210,7 +1206,7 @@ World World::init(ProgressCounter &counter,
12101206 DECL_TIMER (t3, " insert-rooms-area-infos" );
12111207 counter.setNewTask (ProgressMsg{" preparing to insert rooms to areas" }, rooms.size ());
12121208 std::unordered_map<RoomArea, AreaInfo> map;
1213- ImmRoomIdSet global;
1209+ std::set<RoomId> global;
12141210 for (const auto &room : rooms) {
12151211 map[room.getArea ()].roomSet .insert (room.id );
12161212 global.insert (room.id );
Original file line number Diff line number Diff line change @@ -27,10 +27,11 @@ AreaInfoMap::AreaInfoMap()
2727 assert (find (RoomArea{}) != nullptr );
2828}
2929
30- void AreaInfoMap::init (const std::unordered_map<RoomArea, AreaInfo> &map, const ImmRoomIdSet &global)
30+ void AreaInfoMap::init (const std::unordered_map<RoomArea, AreaInfo> &map,
31+ const std::set<RoomId> &global)
3132{
3233 m_map.init (map);
33- m_global = global;
34+ m_global = ImmRoomIdSet{ global} ;
3435}
3536
3637const AreaInfo *AreaInfoMap::find (const RoomArea &area) const
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ struct NODISCARD AreaInfoMap final
3131
3232public:
3333 NODISCARD explicit AreaInfoMap ();
34- void init (const std::unordered_map<RoomArea, AreaInfo> &map, const ImmRoomIdSet &global);
34+ void init (const std::unordered_map<RoomArea, AreaInfo> &map, const std::set<RoomId> &global);
3535
3636public:
3737 NODISCARD const ImmRoomIdSet &getGlobal () const { return m_global; }
You can’t perform that action at this time.
0 commit comments