Skip to content

Commit

Permalink
Some std.container documentation fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Øvrum committed Dec 7, 2015
1 parent a0ff58e commit a2117fa
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions std/container/package.d
Expand Up @@ -48,7 +48,7 @@ assert(secondArray[0] == 12);
// secondArray now refers to an independent copy of originalArray
secondArray = originalArray.dup;
secondArray[0] = 1;
// assert that originalArray has not been effected
// assert that originalArray has not been affected
assert(originalArray[0] == 12);
---
Expand Down Expand Up @@ -80,7 +80,7 @@ assert(array1.empty);
// after initialization reference semantics work as expected
array1 = array2;
// now effects array2 as well
// now affects array2 as well
array1.removeBack();
assert(array2.empty);
---
Expand All @@ -92,11 +92,9 @@ For example, to construct an $(D Array) of ten empty $(D Array)s, use
the following that calls $(D make) ten times.
---
import std.range, std.container, std.algorithm;
import std.container, std.range;
Array!(Array!int) arrayOfArrays = make!(Array!(Array!int))(
repeat(0, 10).map!(x => make!(Array!int))
);
auto arrOfArrs = make!Array(generate!(() => make!(Array!int)).take(10));
---
Submodules:
Expand Down Expand Up @@ -141,7 +139,7 @@ its primary $(LINK2 std_range.html, range) type,
which is aliased as $(D C.Range). For example, the primary range type of
$(D Array!int) is $(D Array!int.Range).
If the documentation of a member function of a _container takes a
If the documentation of a member function of a _container takes
a parameter of type $(D Range), then it refers to the primary range type of
this _container. Oftentimes $(D Take!Range) will be used, in which case
the range refers to a span of the elements in the _container. Arguments to
Expand Down Expand Up @@ -197,13 +195,13 @@ independently of the _container implementation.
For example the primitives $(D c.remove(r)) and $(D c.linearRemove(r)) both
remove the sequence of elements in range $(D r) from the _container $(D c).
The primitive $(D c.remove(r)) guarantees $(BIGOH 1) complexity and
$(D c.linearRemove(r)) relaxes this guarantee to $(BIGOH n) (where $(D n)
is the length of the _container $(D c)).
The primitive $(D c.remove(r)) guarantees
$(BIGOH n$(SUBSCRIPT r) log n$(SUBSCRIPT c)) complexity in the worst case and
$(D c.linearRemove(r)) relaxes this guarantee to $(BIGOH n$(SUBSCRIPT c)).
Since a sequence of elements can be removed from a $(LINK2 std_container_dlist.html, doubly linked list)
in constant time, $(D DList) provides the primitive $(D c.remove(r))
as well as $(D c.linearRemove(r)). On the other hand a
as well as $(D c.linearRemove(r)). On the other hand
$(LINK2 std_container_array.html, Array) only offers $(D c.linearRemove(r)).
The following table describes the common set of primitives that containers
Expand Down

0 comments on commit a2117fa

Please sign in to comment.