diff --git a/soroban-env-host/src/host/metered_map.rs b/soroban-env-host/src/host/metered_map.rs index b819b15ed..dd8050c9f 100644 --- a/soroban-env-host/src/host/metered_map.rs +++ b/soroban-env-host/src/host/metered_map.rs @@ -260,56 +260,6 @@ where Ok(self.find(key, ctx)?.is_ok()) } - pub fn get_prev(&self, key: &Q, ctx: &Ctx) -> Result, HostError> - where - K: Borrow, - Ctx: Compare, - { - match self.find(key, ctx)? { - Ok(hit) if hit == 0 => Ok(None), - Ok(hit) => Ok(Some(&self.map[hit - 1])), - // Err(miss) means you could insert key at miss - // to maintain sort order (meaning that the element - // currently at miss, if it exists, is > than key). - Err(miss) if miss == 0 => Ok(None), - Err(miss) if miss - 1 < self.map.len() => Ok(Some(&self.map[miss - 1])), - Err(_) => Ok(None), - } - } - - pub fn get_next(&self, key: &Q, ctx: &Ctx) -> Result, HostError> - where - K: Borrow, - Ctx: Compare, - { - match self.find(key, ctx)? { - Ok(hit) if (hit < usize::MAX) && (hit + 1 < self.map.len()) => { - Ok(Some(&self.map[hit + 1])) - } - Ok(hit) => Ok(None), - Err(miss) if (miss < self.map.len()) => Ok(Some(&self.map[miss])), - Err(miss) => Ok(None), - } - } - - pub fn get_min(&self, ctx: &Ctx) -> Result, HostError> - where - K: Borrow, - Ctx: Compare, - { - self.charge_access(1, ctx)?; - Ok(self.map.as_slice().first()) - } - - pub fn get_max(&self, ctx: &Ctx) -> Result, HostError> - where - K: Borrow, - Ctx: Compare, - { - self.charge_access(1, ctx)?; - Ok(self.map.as_slice().last()) - } - pub fn keys(&self, ctx: &Ctx) -> Result, HostError> { self.charge_scan(ctx)?; Ok(self.map.iter().map(|(k, _)| k)) diff --git a/soroban-env-host/src/host/metered_vector.rs b/soroban-env-host/src/host/metered_vector.rs index 3a10659b8..873326778 100644 --- a/soroban-env-host/src/host/metered_vector.rs +++ b/soroban-env-host/src/host/metered_vector.rs @@ -302,22 +302,6 @@ where } } - pub fn retain_mut(&mut self, mut f: F, budget: &Budget) -> Result - where - F: FnMut(usize, &mut A) -> Result, - { - // The closure evaluation is not metered here, it is assumed to be taken care of outside. - // Here just covers the cost of cloning a Vec. - self.charge_deep_clone(budget)?; - let mut vec = Vec::with_capacity(self.len()); - for (i, v) in self.vec.iter_mut().enumerate() { - if f(i, v)? { - vec.push(v.clone()); - } - } - Self::from_vec(vec) - } - pub fn iter(&self) -> std::slice::Iter<'_, A> { self.vec.iter() } diff --git a/soroban-env-host/src/test/vec.rs b/soroban-env-host/src/test/vec.rs index 8dd7a0188..701bba517 100644 --- a/soroban-env-host/src/test/vec.rs +++ b/soroban-env-host/src/test/vec.rs @@ -227,6 +227,10 @@ fn vec_insert_and_cmp() -> Result<(), HostError> { let obj2 = host.vec_insert(obj1, 2u32.into(), 3u32.into())?; let obj_ref = host.test_vec_obj::(&[1, 2, 3])?; assert_eq!(host.obj_cmp(obj2.into(), obj_ref.into())?, 0); + + let obj3 = host.vec_insert(obj2, 2u32.into(), 4u32.into())?; + let obj_ref = host.test_vec_obj::(&[1, 2, 4, 3])?; + assert_eq!(host.obj_cmp(obj3.into(), obj_ref.into())?, 0); Ok(()) }