Report a bug
		
				If you spot a problem with this page, click here to create a Github 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.
		
	stdx.collections.slist
- structSList(T);
- 
- this(A, this Q)(Aallocator)
 if (!is(Q == shared) && (is(A == RCISharedAllocator) || !is(Q == immutable)) && (is(A == RCIAllocator) || is(A == RCISharedAllocator)));
- Constructs a qualified singly linked list that will use the providedallocatorobject. For immutable objects, a RCISharedAllocator must be supplied.Parameters:Complexity Ο(1) Examples:auto sl = SList!int(theAllocator); auto csl = const SList!int(processAllocator); auto isl = immutable SList!int(processAllocator); 
- this(U, this Q)(U[]values...)
 if (isImplicitlyConvertible!(U, T));
- Constructs a qualified singly linked list out of a number of items. Because no allocator was provided, the list will use the GCAllocator.std.experimental.allocator.Parameters:U[] valuesa variable number of items, either in the form of a list or as a built-in array Complexity Ο(m), where m is the number of items. Examples:import std.algorithm.comparison : equal; // Create a list from a list of ints { auto sl = SList!int(1, 2, 3); assert(equal(sl, [1, 2, 3])); } // Create a list from an array of ints { auto sl = SList!int([1, 2, 3]); assert(equal(sl, [1, 2, 3])); } // Create a list from a list from an input range { auto sl = SList!int(1, 2, 3); auto sl2 = SList!int(sl); assert(equal(sl2, [1, 2, 3])); } 
- this(A, U, this Q)(Aallocator, U[]values...)
 if (!is(Q == shared) && (is(A == RCISharedAllocator) || !is(Q == immutable)) && (is(A == RCIAllocator) || is(A == RCISharedAllocator)) && isImplicitlyConvertible!(U, T));
- Constructs a qualified singly linked list out of a number of items that will use the providedallocatorobject. For immutable objects, a RCISharedAllocator must be supplied.Parameters:A allocatora allocator.html#.RCIAllocator">std.experimental. allocator.RCIAllocator or allocator.html#.RCISharedAllocator">std.experimental.allocator.RCISharedAllocatorallocatorobjectU[] valuesa variable number of items, either in the form of a list or as a built-in array Complexity Ο(m), where m is the number of items. 
- this(Stuff, this Q)(Stuffstuff)
 if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T) && !is(Stuff == T[]));
- Constructs a qualified singly linked list out of an input range. Because no allocator was provided, the list will use the GCAllocator.std.experimental.allocator.Parameters:Stuff stuffan input range of elements that are implitictly convertible to T Complexity Ο(m), where m is the number of elements in the range. 
- this(A, Stuff, this Q)(Aallocator, Stuffstuff)
 if (!is(Q == shared) && (is(A == RCISharedAllocator) || !is(Q == immutable)) && (is(A == RCIAllocator) || is(A == RCISharedAllocator)) && isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T) && !is(Stuff == T[]));
- Constructs a qualified singly linked list out of an input range that will use the providedallocatorobject. For immutable objects, a RCISharedAllocator must be supplied.Parameters:A allocatora allocator.html#.RCIAllocator">std.experimental. allocator.RCIAllocator or allocator.html#.RCISharedAllocator">std.experimental.allocator.RCISharedAllocatorallocatorobjectStuff stuffan input range of elements that are implitictly convertible to T Complexity Ο(m), where m is the number of elements in the range. 
- const boolisUnique();
- Check whether there are no more references to this list instance.Returns:true if this is the only reference to this list instance; false otherwise.Complexity Ο(n). Examples:auto sl = SList!int(24, 42); assert(sl.isUnique); { auto sl2 = sl; assert(!sl.isUnique); sl2.front = 0; assert(sl.front == 0); } // sl2 goes out of scope assert(sl.isUnique); 
- const pure nothrow @nogc @safe boolempty();
- Check if the list isempty.Returns:true if there are no nodes in the list; false otherwise.Complexity Ο(1). Examples:SList!int sl; assert(sl.empty); size_t pos = 0; sl.insert(pos, 1); assert(!sl.empty); 
- ref autofront(this _)();
- Provide access to the first element in the list. The user must check that the list isn't empty, prior to calling this function.Returns:a reference to the first element.Complexity Ο(1). Examples:auto sl = SList!int(1, 2, 3); assert(sl.front == 1); sl.front = 0; assert(sl.front == 0); 
- voidpopFront();
- Advance to the next element in the list. The user must check that the list isn't empty, prior to calling this function.If there are no more references to the current element (which is being consumed), then the current element will be destroyed; this will call T's dtor, if one is defined, and will collect it's resources.Complexity Ο(1). Examples:auto a = [1, 2, 3]; auto sl = SList!int(a); size_t i = 0; while (!sl.empty) { assert(sl.front == a[i++]); sl.popFront; } assert(sl.empty); 
- Qualifiedtail(this Qualified)();
- Advance to the next element in the list. The user must check that the list isn't empty, prior to calling this function.This must be used in order to iterate through a const or immutable list. For a mutable list this is equivalent to calling popFront.Returns:a list that starts with the next element in the original listComplexity Ο(1). Examples:auto isl = immutable SList!int([1, 2, 3]); assert(isl.tail.front == 2); 
- templateeach(alias fun)
- Eagerly iterate overeachelement in the list and call fun overeachelement. This should be used to iterate through const and immutable lists.Normally, the entire list is iterated. If partial iteration (early stopping) is desired, fun needs to return a value of type std.typecons.Flag!"each" (Yes.eachto continue iteration, or No.eachto stop).Parameters:fun unary function to apply on eachelement of the list.Returns:Yes.eachif it has iterated through all the elements in the list, or No.eachotherwise.Complexity Ο(n). Examples:import std.typecons : Flag, Yes, No; auto isl = immutable SList!int([1, 2, 3]); static bool foo(int x) { return x > 0; } assert(isl.each!foo == Yes.each); 
- ref Qualifiedsave(this Qualified)();
- Perform a shallow copy of the list.Returns:a new reference to the current list.Complexity Ο(1). Examples:auto a = [1, 2, 3]; auto sl = SList!int(a); size_t i = 0; auto tmp = sl.save; while (!tmp.empty) { assert(tmp.front == a[i++]); tmp.popFront; } assert(tmp.empty); assert(!sl.empty); 
- SList!Tdup(this Q)();
- Perform a copy of the list. This will create a new list that will copy the elements of the current list. This will NOT calldupon the elements of the list, regardless if T defines it or not.Returns:a new list.Complexity Ο(n). Examples:import std.algorithm.comparison : equal; auto stuff = [1, 2, 3]; auto sl = immutable SList!int(stuff); auto slDup = sl.dup; assert(equal(slDup, stuff)); slDup.front = 0; assert(slDup.front == 0); assert(sl.front == 1); 
- size_tinsert(Stuff)(size_tpos, Stuffstuff)
 if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T));
 size_tinsert(Stuff)(size_tpos, Stuff[]stuff...)
 if (isImplicitlyConvertible!(Stuff, T));
- Inserts the elements of an input range, or a variable number of items, at the givenpos.If no allocator was provided when the list was created, the GCAllocator.std.experimental.allocator will be used.Parameters:size_t posa positive integer Stuff stuffan input range of elements that are implitictly convertible to T; a variable number of items either in the form of a list or as a built-in array Returns:the number of elements insertedComplexity Ο( pos+ m), where m is the number of elements in the range.Examples:import std.algorithm.comparison : equal; auto s = SList!int(4, 5); SList!int sl; assert(sl.empty); size_t pos = 0; pos += sl.insert(pos, 1); pos += sl.insert(pos, [2, 3]); assert(equal(sl, [1, 2, 3])); // insert from an input range pos += sl.insert(pos, s); assert(equal(sl, [1, 2, 3, 4, 5])); s.front = 0; assert(equal(sl, [1, 2, 3, 4, 5])); 
- size_tinsertBack(Stuff)(Stuffstuff)
 if (isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T));
 size_tinsertBack(Stuff)(Stuff[]stuff...)
 if (isImplicitlyConvertible!(Stuff, T));
- Inserts the elements of an input range, or a variable number of items, at the end of the list.If no allocator was provided when the list was created, the GCAllocator.std.experimental.allocator will be used.Parameters:Stuff stuffan input range of elements that are implitictly convertible to T; a variable number of items either in the form of a list or as a built-in array Returns:the number of elements insertedComplexity Ο(pos + m), where m is the number of elements in the range. Examples:import std.algorithm.comparison : equal; auto s = SList!int(4, 5); SList!int sl; assert(sl.empty); sl.insertBack(1); sl.insertBack([2, 3]); assert(equal(sl, [1, 2, 3])); // insert from an input range sl.insertBack(s); assert(equal(sl, [1, 2, 3, 4, 5])); s.front = 0; assert(equal(sl, [1, 2, 3, 4, 5])); 
- ref autoopBinary(string op, U)(auto ref Urhs)
 if (op == "~" && (is(U == typeof(this)) || is(U : T) || isInputRange!U && isImplicitlyConvertible!(ElementType!U, T)));
- Create a new list that results from the concatenation of this list withrhs.Parameters:U rhscan be an element that is implicitly convertible to T, an input range of such elements, or another singly linked list Returns:the newly created listComplexity Ο(n + m), where m is the number of elements in rhs.Examples:import std.algorithm.comparison : equal; auto sl = SList!int(1); auto sl2 = sl ~ 2; assert(equal(sl2, [1, 2])); sl.front = 0; assert(equal(sl2, [1, 2])); 
- ref autoopAssign()(auto ref typeof(this)rhs);
- Assignrhsto this list. The current list will now become another reference torhs, unlessrhsis null, in which case the current list will become empty. Ifrhsrefers to the current list nothing will happen.All the previous list elements that have no more references to them will be destroyed; this leads to a Ο(n) complexity.Parameters:typeof(this) rhsa reference to a singly linked list Returns:a reference to this listComplexity Ο(n). Examples:import std.algorithm.comparison : equal; auto sl = SList!int(1); auto sl2 = SList!int(1, 2); sl = sl2; // this will free the old sl assert(equal(sl, [1, 2])); sl.front = 0; assert(equal(sl2, [0, 2])); 
- ref autoopOpAssign(string op, U)(auto ref Urhs)
 if (op == "~" && (is(U == typeof(this)) || is(U : T) || isInputRange!U && isImplicitlyConvertible!(ElementType!U, T)));
- Append the elements ofrhsat the end of the list.If no allocator was provided when the list was created, the GCAllocator.std.experimental.allocator will be used.Parameters:U rhscan be an element that is implicitly convertible to T, an input range of such elements, or another singly linked list Returns:a reference to this listComplexity Ο(n + m), where m is the number of elements in rhs.Examples:import std.algorithm.comparison : equal; auto s = SList!int(4, 5); SList!int sl; assert(sl.empty); sl ~= 1; sl ~= [2, 3]; assert(equal(sl, [1, 2, 3])); // append an input range sl ~= s; assert(equal(sl, [1, 2, 3, 4, 5])); s.front = 0; assert(equal(sl, [1, 2, 3, 4, 5])); 
- voidremove(size_tidx= 0);
- Remove the element at the givenidxfrom the list. If there are no more references to the given element, then it will be destroyed.Parameters:size_t idxa positive integer Examples:import std.algorithm.comparison : equal; auto sl = SList!int(1, 2, 3); auto sl2 = sl; auto pos = 1; assert(equal(sl, [1, 2, 3])); sl.remove(pos); assert(equal(sl, [1, 3])); assert(equal(sl2, [1, 3])); 
 
Copyright © 1999-2018 by the D Language Foundation | Page generated by
Ddoc on Thu May  3 12:49:01 2018