dcontain 1.0.2

Various container types for D


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

dcontain

DContain is a small utility library containing various container types.

Containers are under the containers module

Example

import containers;
import std.stdio;

struct User {
    string firstname;
    string lastname;
    size_t id;
}

void main() {
    User eve = User("Eve", "", 3);
    List!User users = [
        User("John", "Doe", 0),
        User("Alice", "", 1),
        User("Bob", "", 2)
    ];

    users ~= eve;
    
    // Remove Bob
    users.removeAt(2);
    
    /// should output the lists contents without bob.
    writeln(users);

    /// Reverse users list and print again
    users.reverse();
    writeln(users);
    users.reverse();

    /// Remove Eve
    users.remove(eve);
    writeln(users);

    /// Foreach loops
    foreach(user; users) {
    	writeln(user);   
    }
    
    /// Getting index also works!
    foreach_reverse(i, user; users) {
    	writeln(i, ": ", user);   
    }
}
Output
[User("John", "Doe", 0), User("Alice", "", 1), User("Eve", "", 3)]
[User("Eve", "", 3), User("Alice", "", 1), User("John", "Doe", 0)]
[User("John", "Doe", 0), User("Alice", "", 1)]
User("John", "Doe", 0)
User("Alice", "", 1)
1: User("Alice", "", 1)
0: User("John", "Doe", 0)
Authors:
  • clipsey
Dependencies:
none
Versions:
1.0.3 2019-Jun-11
1.0.2 2019-Jun-03
1.0.1 2019-Jun-03
1.0.0 2019-May-25
~main 2021-Jan-01
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 57 downloads total

Score:
0.6
Short URL:
dcontain.dub.pm