List::push_back
pub fn push_back(T v) Import
Source: use collections::list::{List}; src/collections/list.hy Adds v at the back. Walks the list, so it takes time proportional to its length.
Called on a List value as value.push_back(…).
Parameters#
| Name | Type |
|---|---|
v | T |
Contracts#
Checked according to --contracts (see Contracts).
ensures self.len == old(self.len) + 1
Examples#
use collections::list::{List};
use tests::assert;
let xs: List<int> = List::new();
xs.push_back(1);
xs.push_back(2);
let v = xs.to_vec();
assert!(v[1] == 2);
See also#
List: A singly-linked list with constant-time push and pop at the front.List::new: Creates an empty list.List::size: Returns the number of values.List::is_empty: Returnstruewhen the list has no values.List::push_front: Addsvat the front.List::peek_front: Returns the front value without removing it, orNonewhen the list is empty.List::pop_front: Removes and returns the front value, orNonewhen the list is empty.List::pop_back: Removes and returns the back value, orNonewhen the list is empty.