@@ -7,8 +7,9 @@ use crate::simulation::optimisation::Solution;
77use crate :: time_slice:: { TimeSliceID , TimeSliceInfo , TimeSliceSelection } ;
88use crate :: units:: { Activity , Dimensionless , MoneyPerActivity , MoneyPerFlow , Year } ;
99use anyhow:: Result ;
10+ use indexmap:: IndexMap ;
1011use itertools:: iproduct;
11- use std:: collections:: { BTreeMap , HashMap , HashSet , btree_map } ;
12+ use std:: collections:: { HashMap , HashSet } ;
1213
1314/// Iterator item type for asset activity iterators
1415type Item < ' a > = ( & ' a AssetRef , & ' a TimeSliceID , Activity ) ;
@@ -98,7 +99,7 @@ pub fn calculate_prices(model: &Model, solution: &Solution, year: u32) -> Result
9899
99100/// A map relating commodity ID + region + time slice to current price (endogenous)
100101#[ derive( Default , Clone ) ]
101- pub struct CommodityPrices ( BTreeMap < ( CommodityID , RegionID , TimeSliceID ) , MoneyPerFlow > ) ;
102+ pub struct CommodityPrices ( IndexMap < ( CommodityID , RegionID , TimeSliceID ) , MoneyPerFlow > ) ;
102103
103104impl CommodityPrices {
104105 /// Insert a price for the given commodity, region and time slice
@@ -150,7 +151,9 @@ impl CommodityPrices {
150151 }
151152
152153 /// Iterate over the price map's keys
153- pub fn keys ( & self ) -> btree_map:: Keys < ' _ , ( CommodityID , RegionID , TimeSliceID ) , MoneyPerFlow > {
154+ pub fn keys (
155+ & self ,
156+ ) -> indexmap:: map:: Keys < ' _ , ( CommodityID , RegionID , TimeSliceID ) , MoneyPerFlow > {
154157 self . 0 . keys ( )
155158 }
156159
@@ -236,8 +239,7 @@ impl<'a> FromIterator<(&'a CommodityID, &'a RegionID, &'a TimeSliceID, MoneyPerF
236239
237240impl IntoIterator for CommodityPrices {
238241 type Item = ( ( CommodityID , RegionID , TimeSliceID ) , MoneyPerFlow ) ;
239- type IntoIter =
240- std:: collections:: btree_map:: IntoIter < ( CommodityID , RegionID , TimeSliceID ) , MoneyPerFlow > ;
242+ type IntoIter = indexmap:: map:: IntoIter < ( CommodityID , RegionID , TimeSliceID ) , MoneyPerFlow > ;
241243
242244 fn into_iter ( self ) -> Self :: IntoIter {
243245 self . 0 . into_iter ( )
0 commit comments