@@ -16,9 +16,13 @@ pub enum StoreLoadError {
16
16
// ---
17
17
18
18
/// Stores many [`EntityDb`]s of recordings and blueprints.
19
+ ///
20
+ /// The stores are kept and iterated in insertion order to allow the UI to display them by default
21
+ /// in opening order.
19
22
#[ derive( Default ) ]
20
23
pub struct StoreBundle {
21
- recording_store : ahash:: HashMap < StoreId , EntityDb > ,
24
+ // `indexmap` is used to keep track of the insertion order.
25
+ recording_store : indexmap:: IndexMap < StoreId , EntityDb > ,
22
26
}
23
27
24
28
impl StoreBundle {
@@ -38,24 +42,18 @@ impl StoreBundle {
38
42
Ok ( slf)
39
43
}
40
44
41
- /// All loaded [`EntityDb`], both recordings and blueprints, in arbitrary order.
45
+ /// All loaded [`EntityDb`], both recordings and blueprints, in insertion order.
42
46
pub fn entity_dbs ( & self ) -> impl Iterator < Item = & EntityDb > {
43
47
self . recording_store . values ( )
44
48
}
45
49
46
- /// All loaded [`EntityDb`], both recordings and blueprints, in arbitrary order.
50
+ /// All loaded [`EntityDb`], both recordings and blueprints, in insertion order.
47
51
pub fn entity_dbs_mut ( & mut self ) -> impl Iterator < Item = & mut EntityDb > {
48
52
self . recording_store . values_mut ( )
49
53
}
50
54
51
- pub fn append ( & mut self , mut other : Self ) {
52
- for ( id, entity_db) in other. recording_store . drain ( ) {
53
- self . recording_store . insert ( id, entity_db) ;
54
- }
55
- }
56
-
57
55
pub fn remove ( & mut self , id : & StoreId ) -> Option < EntityDb > {
58
- self . recording_store . remove ( id)
56
+ self . recording_store . shift_remove ( id)
59
57
}
60
58
61
59
// --
@@ -113,29 +111,22 @@ impl StoreBundle {
113
111
. insert ( entity_db. store_id ( ) . clone ( ) , entity_db) ;
114
112
}
115
113
116
- /// In no particular order.
114
+ /// In insertion order.
117
115
pub fn recordings ( & self ) -> impl Iterator < Item = & EntityDb > {
118
116
self . recording_store
119
117
. values ( )
120
118
. filter ( |log| log. store_kind ( ) == StoreKind :: Recording )
121
119
}
122
120
123
- /// In no particular order.
124
- pub fn blueprints ( & self ) -> impl Iterator < Item = & EntityDb > {
125
- self . recording_store
126
- . values ( )
127
- . filter ( |log| log. store_kind ( ) == StoreKind :: Blueprint )
128
- }
129
-
130
121
// --
131
122
132
123
pub fn retain ( & mut self , mut f : impl FnMut ( & EntityDb ) -> bool ) {
133
124
self . recording_store . retain ( |_, db| f ( db) ) ;
134
125
}
135
126
136
- /// In no particular order.
127
+ /// In insertion order.
137
128
pub fn drain_entity_dbs ( & mut self ) -> impl Iterator < Item = EntityDb > + ' _ {
138
- self . recording_store . drain ( ) . map ( |( _, store) | store)
129
+ self . recording_store . drain ( .. ) . map ( |( _, store) | store)
139
130
}
140
131
141
132
// --
0 commit comments