algos 0.1.0

A collection of algorithms in rust
Documentation

Algos

A rust library with a collection of algorithms.

Only sort algorithms for now. It is planned to add search and graph algorithms as well.

Usage

Add this to your Cargo.toml:

[dependencies]
algos = "0.1"

and this to your crate root:

extern crate algos;

Sorts algorithms

Add this to your crate root:

use algos::sort;

and create a array and use like this:

fn fn main() {
    let mut v = [2, 3, 1, 9, 8, 4];
    // Crescent sorting
    sort::heap(&mut v, &|a,b| a<b);
    // For decreasing sorting, change the signal in &|a,b| a>b.
}

It can also work in an array of Strings, sorting by the length of the string:

fn main() {
    let mut v = ["bc", "a", "def", "klmno", "ghij", "pqrstu"];
    // Crescent sorting
    sort::merge(&mut v, &|a,b| a.len()<b.len())
}

Implemented

Sorts

  • Selection Sort
  • Bubble Sort
  • Cocktail Sort
  • Insertion Sort
  • Merge Sort
  • Quick Sort
  • Heap Sort