Struct dbscan::matrix::SymmetricMatrix [] [src]

pub struct SymmetricMatrix<T> { /* fields omitted */ }

A generic symmetric matrix.

Methods

impl<T> SymmetricMatrix<T> where T: Default + Copy
[src]

Constructs a new symmetric matrix with the given number of rows and columns.

Each cell in the matrix is initialied to T::default(). For example, when T is an integral type, each cell is initialied to 0.

Examples

let m: SymmetricMatrix<i32> = SymmetricMatrix::new(5);

Returns the number of rows and columns of the matrix.

Examples

let m: SymmetricMatrix<i32> = SymmetricMatrix::new(5);
assert_eq!(m.size(), 5);

Returns the value of the given cell.

Since the matrix is symmetric, get(x, y) returns the same value as get(y, x).

Examples

let m = SymmetricMatrix::new(5);
m.set(1, 2, 42);
assert_eq!(m.get(1, 2), 42);
assert_eq!(m.get(2, 1), 42);

Panics

When the given cell does not exist. For example, when the size of the matrix is 5, calling get(5, 1) will panic.

Sets the value of the given cell.

Since the matrix is symmetric, set(x, y, value) automatically sets the value of (y, x).

Examples

let m = SymmetricMatrix::new(5);
m.set(1, 2, 42);
assert_eq!(m.get(1, 2), 42);
assert_eq!(m.get(2, 1), 42);

Panics

When the given cell does not exist. For example, when the size of the matrix is 5, calling set(5, 1, X) will panic.

Trait Implementations

impl<T: Debug> Debug for SymmetricMatrix<T>
[src]

Formats the value using the given formatter.