[][src]Struct calcify::Collection

pub struct Collection<T: Serializable> {
    pub vec: Vec<T>,
}

A wrapper around the std::vec::vec

Note

  • Collection only implements some basic functionality of real Vecs. The goal is not to supersede, but to add to. So you should use Vec in most cases, and wrap it in a Collection if you need one of those functions.

Fields

vec: Vec<T>

Methods

impl<T: Serializable> Collection<T>[src]

pub fn from_vec(vec: Vec<T>) -> Collection<T>[src]

Returns new Collection from a Vec<T: Serializable>

Arguments

  • vec - Vec<calcify::FourVec>

Example

use calcify::FourVec;
use calcify::Collection;

let col4V = Collection::from_vec(
    vec![FourVec::new(10.0,1.0,1.0,1.0)]
);

pub fn empty() -> Collection<T>[src]

Returns new Collection from a Vec<T: Serializable>

Example

use calcify::FourVec;
use calcify::Collection;

let col4V: Collection<FourVec> = Collection::empty();

pub fn at(&mut self, i: usize) -> &mut T[src]

Returns a mutable reference to the T: Serializable at index i

Arguments

  • i - usize

Example

use calcify::FourVec;
use calcify::Collection;

let mut col4V = Collection::from_vec(
    vec![FourVec::new(10.0,1.0,1.0,1.0)]
);
assert_eq!(*col4V.at(0),FourVec::new(10.0,1.0,1.0,1.0));
*col4V.at(0) += FourVec::new(10.0,1.0,1.0,1.0);
assert_eq!(*col4V.at(0),FourVec::new(20.0,2.0,2.0,2.0));

pub fn push(&mut self, nn: T)[src]

Push new T: Serializable into Collection

Arguments

  • nn - T: Serializable

Example

use calcify::FourVec;
use calcify::Collection;

let mut col4V = Collection::empty();
col4V.push(FourVec::new(10.0,1.0,1.0,1.0));
assert_eq!(*col4V.at(0),FourVec::new(10.0,1.0,1.0,1.0));

pub fn map<F, Z: Serializable>(&self, close: F) -> Collection<Z> where
    F: FnMut(&T) -> Z, 
[src]

Maps a function and returns a new Collection

Implements Vec::iter::map and Vec::iter::collect.

Arguments

  • close - F: FnMut(&T: Serializable) -> Z: Serializable

Example

use calcify::FourVec;
use calcify::Collection;

let mut col4V: Collection<FourVec> = Collection::empty();
for _i in 0..9999 {
    col4V.push(FourVec::new(1.0,0.0,0.0,0.0));
}
let mut mass_col4V: Collection<f64> = Collection::empty();
for _i in 0..9999 {
    mass_col4V.push(1.0);
}
assert_eq!(col4V.map(FourVec::s), mass_col4V);

impl Collection<f64>[src]

pub fn hist(&self, num_bins: u64) -> Collection<Bin>[src]

Return Collection histogram

Example

use calcify::Collection;
use calcify::Bin;
use calcify::ThreeVec;

let mut col_3v = Collection::empty();
    for _i in 0..99999 {
        col_3v.push(ThreeVec::random(10.0));
    }
let len_col: Collection<f64> = col_3v.map(ThreeVec::r);
let histogram: Collection<Bin> = len_col.hist(50);

Trait Implementations

impl<T: Serializable> Serializable for Collection<T>[src]

impl<T: Clone + Serializable> Clone for Collection<T>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: PartialEq + Serializable> PartialEq<Collection<T>> for Collection<T>[src]

impl<T: Debug + Serializable> Debug for Collection<T>[src]

impl<T: Serializable> FromIterator<T> for Collection<T>[src]

Auto Trait Implementations

impl<T> Send for Collection<T> where
    T: Send

impl<T> Sync for Collection<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]