pub fn remove(&mut self, object: &K) {
        if let Some(start_position) = self.objects.remove(object) {
            let mut segment_position = self
                .segments
                .iter_mut()
                .position(|seg| seg.pos == start_position)
                .expect("logic error!");
            assert_eq!(false, self.segments[segment_position].free, "logic error!");
            self.segments[segment_position].free = true;
            // Merge with the segment before if possible
            if segment_position > 0 {
                if self.segments[segment_position - 1].free {
                    self.segments[segment_position - 1].len += self.segments[segment_position].len;
                    self.segments.remove(segment_position);
                    segment_position -= 1;
                }
            }
            // Merge with the segment after if possible
            if segment_position < self.segments.len() - 1 {
                if self.segments[segment_position + 1].free {
                    self.segments[segment_position].len += self.segments[segment_position + 1].len;
                    self.segments.remove(segment_position + 1);
                }
            }
        }
    }
/// Remove object `object` from the buffer
Remove object `object` from the buffer
Remove object ` object ` from the buffer
pub fn remove(&mut self, object: &K) {
        if let Some(start_position) = self.objects.remove(object) {
            let mut segment_position = self
                .segments
                .iter_mut()
                .position(|seg| seg.pos == start_position)
                .expect("logic error!");
            assert_eq!(false, self.segments[segment_position].free, "logic error!");
            self.segments[segment_position].free = true;
            // Merge with the segment before if possible
            if segment_position > 0 {
                if self.segments[segment_position - 1].free {
                    self.segments[segment_position - 1].len += self.segments[segment_position].len;
                    self.segments.remove(segment_position);
                    segment_position -= 1;
                }
            }
            // Merge with the segment after if possible
            if segment_position < self.segments.len() - 1 {
                if self.segments[segment_position + 1].free {
                    self.segments[segment_position].len += self.segments[segment_position + 1].len;
                    self.segments.remove(segment_position + 1);
                }
            }
        }
    }
pub fn remove ( & mut self , object : & K ) { if let Some ( start_position ) = self . objects . remove ( object ) { let mut segment_position = self . segments . iter_mut ( ) . position ( | seg | seg . pos == start_position ) . expect ( " " ) ; assert_eq ! ( false self segments [ segment_position ] free " " ) ; self . segments [ segment_position ] . free = true ; // Merge with the segment before if possible if segment_position > 0 { if self . segments [ segment_position - 1 ] . free { self . segments [ segment_position - 1 ] . len += self . segments [ segment_position ] . len ; self . segments . remove ( segment_position ) ; segment_position -= 1 ; } } // Merge with the segment after if possible if segment_position < self . segments . len ( ) - 1 { if self . segments [ segment_position + 1 ] . free { self . segments [ segment_position ] . len += self . segments [ segment_position + 1 ] . len ; self . segments . remove ( segment_position + 1 ) ; } } } }
Remove object `object` from the buffer
Remove object ` object ` from the buffer
&mut self
object
&K
&mut self
object
&K