pub fn push(&mut self, item: T) {
        if self.items.len() < (self.len_cap as usize) {
            self.items.push(item);
        } else {
            self.items[self.head_index as usize] = item;
            self.head_index = (self.head_index + 1) % (self.items.len() as u32);
        }
    }
/// Appends an element to the back of the `CapVec`.
///
/// If after appending collection's length is equal to `len_cap` then first element is removed
/// automatically from the front.
///
/// # Examples
/// ```
/// # use financial_primitives::capvec::CapVec;
/// let mut items = CapVec::<u64>::new(2);
/// items.push(1);
/// ```
Appends an element to the back of the `CapVec`.
If after appending collection's length is equal to `len_cap` then first element is removed
automatically from the front.
Appends an element to the back of the ` CapVec ` . If after appending collection ' s length is equal to ` len_cap ` then first element is removed automatically from the front .
pub fn push(&mut self, item: T) {
        if self.items.len() < (self.len_cap as usize) {
            self.items.push(item);
        } else {
            self.items[self.head_index as usize] = item;
            self.head_index = (self.head_index + 1) % (self.items.len() as u32);
        }
    }
pub fn push ( & mut self , item : T ) { if self . items . len ( ) < ( self . len_cap as usize ) { self . items . push ( item ) ; } else { self . items [ self . head_index as usize ] = item ; self . head_index = ( self . head_index + 1 ) % ( self . items . len ( ) as u32 ) ; } }
Appends an element to the back of the `CapVec`.
Appends an element to the back of the ` CapVec ` .
&mut self
item
T
&mut self
item
T
examples
None
use financial_primitives::capvec::capvec;
None