std.container.util - D Programming Language

Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Feature Overview
  - DMD Manual
  - Articles
- Packages
- Community
  - Bug Tracker
  - Forums
  - IRC
  - D on GitHub
  - Wiki
  - Review Queue
  - Twitter
  - More Links
- Resources
  - NEW Library Reference Preview
  - D-Specific Tools
  - Visual D
  - Editors
  - IDEs
  - Tutorials
  - Books
  - The D Style
  - Glossary
  - Acknowledgments
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# std.container.util

This module contains some common utilities used by containers.
This module is a submodule of std.container.

Source: std/container/util.d

License:
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at boost.org/LICENSE_1_0.txt).
Authors:
Steven Schveighoffer, Andrei Alexandrescu

template make(T) if (is(T == struct) || is(T == class))
  Returns an initialized object. This function is mainly for eliminating construction differences between structs and classes. It allows code to not worry about whether the type it's constructing is a struct or a class.
  Examples:

      import std.container;
      import std.algorithm : equal;
      import std.algorithm : equal;

      auto arr = make!(Array!int)([4, 2, 3, 1]);
      assert(equal(arr[], [4, 2, 3, 1]));

      auto rbt = make!(RedBlackTree!(int, "a > b"))([4, 2, 3, 1]);
      assert(equal(rbt[], [4, 3, 2, 1]));

      alias makeList = make!(SList!int);
      auto slist = makeList(1, 2, 3);
      assert(equal(slist[], [1, 2, 3]));

template make(alias Container, Args...) if (!is(Container))
  Convenience function for constructing a generic container.
  Examples:

      import std.container.array, std.container.rbtree, std.container.slist;
      import std.range : iota;
      import std.algorithm : equal;

      auto arr = make!Array(iota(5));
      assert(equal(arr[], [0, 1, 2, 3, 4]));

      auto rbtmax = make!(RedBlackTree, "a > b")(iota(5));
      assert(equal(rbtmax[], [4, 3, 2, 1, 0]));

      auto rbtmin = make!RedBlackTree(4, 1, 3, 2);
      assert(equal(rbtmin[], [1, 2, 3, 4]));

      alias makeList = make!SList;
      auto list = makeList(1, 7, 42);
      assert(equal(list[], [1, 7, 42]));

Red-black tree code copyright (C) 2008- by Steven Schveighoffer. Other code copyright 2010- Andrei Alexandrescu. All rights reserved by the respective holders. | Page generated by Ddoc on Wed Mar 30 06:34:11 2016