File tree 2 files changed +30
-5
lines changed
2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ aa[std.zlib]=-dip1000
60
60
aa[std.algorithm.comparison] =-dip1000
61
61
aa[std.algorithm.internal] =-dip1000
62
62
aa[std.algorithm.iteration] =-dip25 # WIP_carblue
63
- aa[std.algorithm.mutation]=-dip25 # depends on std.container.slist (https://github.com/dlang/phobos/pull/6295)
63
+ aa[std.algorithm.mutation]=-dip1000
64
64
aa[std.algorithm.package] =-dip1000
65
65
aa[std.algorithm.searching] =-dip25 # depends on https://github.com/dlang/phobos/pull/6246 merged and std.algorithm.comparison fixed
66
66
aa[std.algorithm.setops]=-dip1000
@@ -95,7 +95,7 @@ aa[std.container.binaryheap]=-dip1000
95
95
aa[std.container.dlist] =-dip1000
96
96
aa[std.container.package] =-dip1000
97
97
aa[std.container.rbtree] =-dip25 # DROP
98
- aa[std.container.slist]=-dip25 # - dip1000 -version=DIP1000 depends on https://github.com/dlang/phobos/pull/6295 merged
98
+ aa[std.container.slist]=-dip1000 -version=DIP1000 # merged https://github.com/dlang/phobos/pull/6295
99
99
aa[std.container.util]=-dip25 # TODO
100
100
101
101
aa[std.datetime.date] =-dip25 # depends on a fix for writefln
Original file line number Diff line number Diff line change @@ -138,9 +138,22 @@ struct SList(T)
138
138
/**
139
139
Constructor taking a number of nodes
140
140
*/
141
- this (U)(U[] values ... ) if (isImplicitlyConvertible! (U, T))
141
+ this (U)(scope U[] values ... ) if (isImplicitlyConvertible! (U, T))
142
142
{
143
- insertFront(values );
143
+ initialize();
144
+ Node* n, newRoot;
145
+ foreach (item; values )
146
+ {
147
+ auto newNode = new Node(null , item);
148
+ (newRoot ? n._next : newRoot) = newNode;
149
+ n = newNode;
150
+ }
151
+ if (n)
152
+ {
153
+ // Last node points to the old root
154
+ n._next = _first;
155
+ _first = newRoot;
156
+ }
144
157
}
145
158
146
159
/**
@@ -359,7 +372,7 @@ Complexity: $(BIGOH m), where $(D m) is the length of $(D stuff)
359
372
{
360
373
initialize();
361
374
size_t result;
362
- Node * n, newRoot;
375
+ Node* n, newRoot;
363
376
foreach (item; stuff)
364
377
{
365
378
auto newNode = new Node(null , item);
@@ -911,3 +924,15 @@ Complexity: $(BIGOH n)
911
924
s.reverse();
912
925
assert (s[].equal([3 , 2 , 1 ]));
913
926
}
927
+
928
+ version (DIP1000)
929
+ @safe unittest
930
+ {
931
+ int i, j;
932
+ auto s = SList! (int * )([&i, &j]);
933
+ assert (s._root);
934
+ assert (s._root._next);
935
+ assert (s._root._next._next);
936
+ assert (s._root._next._payload == &i);
937
+ assert (s._root._next._next._payload == &j);
938
+ }
You can’t perform that action at this time.
0 commit comments