Code Monkey home page Code Monkey logo

ingrid's Introduction

Ingrid

Ingrid is a self-contained crate that provides a STL-like container for dynamic two-dimensional arrays for the Rust programming language. It comes with algorithms and it's expected to be generic and good enough for most use cases; it was initially written to implement image pixels and grid-based games.

Features

  • A concise dynamic grid structure
  • Slice-like rows and columns
  • Useful set of iterators and adaptors
  • Smart implementation with capacity-like feature
  • Ready-to-use common algorithms
  • Complete code coverage
  • Extensively documented

It's distributed under the MIT license. Feel free to use the way you like as long as you keep the license around if you reuse the code.

Quick preview

To get a rough idea of what it is like to work with Ingrid, have a look at the following snipped.

use ingrid::{Coordinate, Size};
use ingrid::Grid;
use ingrid::GridIterator;
use ingrid::{coord, size}; // Macros to shorten the syntax

// Create a grid with enough allocated memory to contain 9 elements.
let mut grid = Grid::<char>::with_capacity(size!(3, 3));

// Resize the grid to be 2x2 and fill it with a default value.
grid.resize(size!(2, 3), '๐Ÿ˜ž');

// Change the content of the grid with the direct accessors.
grid[coord!(0, 0)] = '๐Ÿ˜„'; // Top-left element (first element)
grid[coord!(1, 2)] = '๐Ÿ˜„'; // Bottom-right element (last element)

// Insert a column right in the middle.
grid.insert_column(1, vec!['๐Ÿ˜ฎ', '๐Ÿ˜ฎ', '๐Ÿ˜ฎ']);

// Iterate over the elements of the last row
for (coordinate, emoticon) in grid.row(2).iterator().enumerate_coordinate() {
    println!("Emoticon at {:?} is {}", coordinate, emoticon);
}

Next step is to dig in the documentation, which comes with an excellent introduction by the way.

More information

Website: https://www.intjelic.me/project/ingrid Repository: https://github.com/intjelic/ingrid Crate: https://crates.io/crates/ingrid Documentation: https://docs.rs/ingrid Author: Jonahan De Wachter (dewachter.jonathan[at]gmail[dot]com)

ingrid's People

Contributors

intjelic avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

imnottwig

ingrid's Issues

implement Clone

It would be useful to support Clone for the Grid type when the stored elements support Clone. Currently I'm using a custom function to do this which just copies the rows and creates a new grid with from_rows, but it would be more convenient to allow other types to derive Clone if the Grid type supported it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.