Struct comp_sci::data_structures::array_list::ArrayList [-]  [+] [src]

pub struct ArrayList<A> {
    // some fields omitted
}

An implementation of a growable and mutable array type, which is allocated on the heap.

Minimum memory requirement is three pointer sized integers, e.g. 24-bytes on 64-bit system.

Methods

impl<A> ArrayList<A>

fn new() -> ArrayList<A>

Creates a new array list with a default capacity of 10.

fn with_capacity(capacity: usize) -> ArrayList<A>

Creates a new array list with the given capacity.

fn push(&mut self, element: A)

Adds an element to the end of the list.

More capacity will be allocated if necessary.

fn insert(&mut self, index: usize, element: A)

Inserts an element at the given index.

More capacity will be allocated if necessary.

fn remove_at(&mut self, index: usize)

Removes an element at the given index.

fn as_mut_slice<'a>(&'a mut self) -> &'a mut [A]

fn capacity(&self) -> usize

Returns the capacity of this list.

fn length(&self) -> usize

Returns the number of elements in the list.

Trait Implementations

impl<A> AsSlice<A> for ArrayList<A>

fn as_slice<'a>(&'a self) -> &'a [A]

impl<A> Index<usize> for ArrayList<A>

type Output = A

fn index<'a>(&'a self, index: &usize) -> &'a A

impl<A> IndexMut<usize> for ArrayList<A>

type Output = A

fn index_mut<'a>(&'a mut self, index: &usize) -> &'a mut A