All Projects → slightlyoutofphase → Staticvec

slightlyoutofphase / Staticvec

Licence: other
Implements a fixed-capacity stack-allocated Vec alternative backed by an array, using const generics.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Staticvec

Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (-47.03%)
Mutual labels:  data-structures, vector, stack, array, datastructures, collections, containers, container
C Macro Collections
Easy to use, header only, macro generated, generic and type-safe Data Structures in C
Stars: ✭ 192 (-18.64%)
Mutual labels:  data-structures, stack, datastructures, data-structure, containers
Cdcontainers
Library of data containers and data structures for C programming language.
Stars: ✭ 57 (-75.85%)
Mutual labels:  stack, datastructures, collections, containers
Sc
Common libraries and data structures for C.
Stars: ✭ 161 (-31.78%)
Mutual labels:  data-structures, vector, stack, collections
Cdsa
A library of generic intrusive data structures and algorithms in ANSI C
Stars: ✭ 549 (+132.63%)
Mutual labels:  stack, datastructures, collections
Algodeck
An Open-Source Collection of 200+ Algorithmic Flash Cards to Help you Preparing your Algorithm & Data Structure Interview 💯
Stars: ✭ 4,441 (+1781.78%)
Mutual labels:  data-structures, stack, array
Libgenerics
libgenerics is a minimalistic and generic library for C basic data structures.
Stars: ✭ 42 (-82.2%)
Mutual labels:  data-structures, vector, stack
Data Structure And Algorithms
A complete and efficient guide for Data Structure and Algorithms.
Stars: ✭ 48 (-79.66%)
Mutual labels:  data-structures, datastructures, data-structure
Geeksforgeeks Dsa 2
This repository contains all the assignments and practice questions solved during the Data Structures and Algorithms course in C++ taught by the Geeks For Geeks team.
Stars: ✭ 53 (-77.54%)
Mutual labels:  data-structures, stack, array
Interview Questions
List of all the Interview questions practiced from online resources and books
Stars: ✭ 187 (-20.76%)
Mutual labels:  data-structures, stack, datastructures
Gods
GoDS (Go Data Structures). Containers (Sets, Lists, Stacks, Maps, Trees), Sets (HashSet, TreeSet, LinkedHashSet), Lists (ArrayList, SinglyLinkedList, DoublyLinkedList), Stacks (LinkedListStack, ArrayStack), Maps (HashMap, TreeMap, HashBidiMap, TreeBidiMap, LinkedHashMap), Trees (RedBlackTree, AVLTree, BTree, BinaryHeap), Comparators, Iterators, …
Stars: ✭ 10,883 (+4511.44%)
Mutual labels:  stack, data-structure, iterator
Mlib
Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).
Stars: ✭ 321 (+36.02%)
Mutual labels:  stack, array, collections
Data-structures
Data Structures in Java
Stars: ✭ 13 (-94.49%)
Mutual labels:  stack, datastructures, data-structures
Algorithm
Algorithm is a library of tools that is used to create intelligent applications.
Stars: ✭ 787 (+233.47%)
Mutual labels:  data-structures, stack, data-structure
Data-Structures-and-Algorithms
Data Structures and Algorithms implementation in Python
Stars: ✭ 31 (-86.86%)
Mutual labels:  stack, array, data-structures
rrbit-js
No description or website provided.
Stars: ✭ 11 (-95.34%)
Mutual labels:  vector, array, collections
php-collections
A collection library for php
Stars: ✭ 34 (-85.59%)
Mutual labels:  array, iterator, collections
BitLens
🔎 Have your bits and eat them too! A C++17 bit lens container for vector types.
Stars: ✭ 20 (-91.53%)
Mutual labels:  vector, array, container
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (+377.97%)
Mutual labels:  data-structures, stack, collections
Containers
Containers backed by std.experimental.allocator
Stars: ✭ 111 (-52.97%)
Mutual labels:  data-structures, array, containers

Latest Version Rustc Version nightly

Build status

Implements a fixed-capacity stack-allocated Vec alternative backed by an array, using const generics.

Note: the word "static" here is meant by the traditional definition of "unchanging" / "not dynamic" etc.

This crate does not use literal static variables for anything (but does provide multiple ways to instantiate a StaticVec as a static or const variable if desired).

Fully #![no_std] compatible (with almost no loss of functionality) by setting default-features = false for the staticvec dependency in your Cargo.toml.

Optional support for serialization and deserialization of the StaticVec struct via serde is available by activating the serde_support crate feature.

StaticVec also implements both Deref and DerefMut to [T], meaning that all existing slice methods are accessible through instances of it and that references to it can be used in contexts where [T] is expected.

As of version 0.8.0, this crate additionally provides a fixed-capacity StaticString struct, which is built around an instance of StaticVec<u8, N>.

As of version 0.8.5, a fixed-capacity StaticHeap struct based on the standard library BinaryHeap and built around an instance of StaticVec<T, N> has been added as well.

Contributions/suggestions/etc. very welcome!

Minimum supported Rust version: due to the use of const generics, this is a nightly-only crate at the moment.

A basic usage example:

use staticvec::{staticvec, StaticVec};

fn main() {
  let mut v = StaticVec::<usize, 64>::new();
  for i in 0..v.capacity() {
    v.push(i);
  }
  for i in &v {
    println!("{}", i);
  }
  v.clear();
  v.insert(0, 47);
  v.insert(1, 48);
  v.insert(2, 49);
  v.insert(v.len() - 1, 50);
  v.insert(v.len() - 2, 51);
  v.insert(v.len() - 3, 52);
  for i in &v {
    println!("{}", i);
  }
  for i in &v.reversed().drain(2..4) {
    println!("{}", i);
  }
  while v.is_not_empty() {
    println!("{}", v.remove(0));
  }
  for f in staticvec![12.0, 14.0, 15.0, 16.0].iter().skip(2) {
    println!("{}", f);
  }
  for i in staticvec![
    staticvec![14, 12, 10].sorted(),
    staticvec![20, 18, 16].reversed(),
    staticvec![26, 24, 22].sorted(),
    staticvec![32, 30, 28].reversed(),
  ]
  .iter()
  .flatten()
  .collect::<StaticVec<usize, 12>>()
  .iter() {
    println!("{}", i);
  }
  // The type parameter is inferred as `StaticVec<usize, 16>`.
  let filled = StaticVec::<_, 6>::filled_with_by_index(|i| {
    staticvec![
      i + 1,
      i + 2,
      i + 3,
      i + 4,
    ]
    .concat(&staticvec![6, 6, 7, 7])
    .intersperse((i + 4) * 4)
  });
  println!("{:?}", filled);
}

License:

Licensed under either the MIT license or version 2.0 of the Apache License. Your choice as to which! Any source code contributions will be dual-licensed in the same fashion.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].