arraypp 0.1.0

A `no_std` and no `alloc` library for more efficient array processing.
Documentation
  • Coverage
  • 69.57%
    16 out of 23 items documented0 out of 16 items with examples
  • Size
  • Source code size: 36.37 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.7 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Joker2770/arraypp
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Joker2770

arraypp

Rust

A no_std and no alloc library for more efficient array processing.

Usage

Compare elements:

use arraypp::compare::ArrayExtrema;

// Find both the minimum and maximum values and their indices at the same time
let arr = [1.5, 3.2, 2.8, 4.7, 2.8];
let result = ArrayExtrema::min_max_with_indices(&arr).unwrap();

println!("Min: {} at index {}", result.min.value, result.min.index);
println!("Max: {} at index {}", result.max.value, result.max.index);

// Find the minimum value and its index only
let min = ArrayExtrema::min_with_index(&arr).unwrap();
println!("Min: {} at index {}", min.value, min.index);

// Find the maximum value and its index only
let max = ArrayExtrema::max_with_index(&arr).unwrap();
println!("Max: {} at index {}", max.value, max.index);

Queue options:

use arraypp::queue::ArrayQueue;

let mut queue: ArrayQueue<i32, 3> = ArrayQueue::new();

assert!(queue.is_empty());
assert_eq!(queue.len(), 0);

assert_eq!(queue.enqueue(1), Ok(()));
assert_eq!(queue.enqueue(2), Ok(()));
assert_eq!(queue.enqueue(3), Ok(()));

assert!(queue.is_full());
assert_eq!(queue.len(), 3);

assert_eq!(queue.enqueue(4), Err(4)); // Queue is full

assert_eq!(queue.peek(), Some(&1));
assert_eq!(queue.dequeue(), Some(1));

assert_eq!(queue.len(), 2);

assert_eq!(queue.enqueue(4), Ok(())); // Now there is space

assert_eq!(queue.dequeue(), Some(2));
assert_eq!(queue.dequeue(), Some(3));
assert_eq!(queue.dequeue(), Some(4));

assert!(queue.is_empty());
assert_eq!(queue.dequeue(), None);