View source code
							
							
						
								Display the source code in std/array.d from which this
								page was generated on github.
							
						
							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
								local clone.
							
						std.array.Appender/appender  - multiple declarations
				Function appender
Convenience function that returns a RefAppender instance initialized
    with arrayPtr. Don't use null for the array pointer, use the other
    version of appender instead.
						
					
				Example
int[] a = [1, 2];
auto app2 = appender(&a);
writeln(app2Function appender
Convenience function that returns an Appender instance,
    optionally initialized with array.
Example
auto w = appender!string;
// pre-allocate space for at least 10 elements (this avoids costly reallocations)
wStruct Appender
Implements an output range that appends data to an array. This is
recommended over array ~= data when appending many elements because it is more
efficient. Appender maintains its own array metadata locally, so it can avoid
global locking for each append where capacity is non-zero.
						
				struct Appender(A)
				
				  
				
				if (isDynamicArray!A);
						
					
				Constructors
| Name | Description | 
|---|---|
| this | Constructs an Appenderwith a given array.  Note that this does not copy the
 data.  If the array has a larger capacity as determined byarr,
 it will be used by the appender.  After initializing an appender on an array,
 appending to the original array will reallocate. | 
Properties
| Name | Type | Description | 
|---|---|---|
| capacity[get] | size_t | |
| data[get] | inout(ElementEncodingType!A)[] | 
Methods
| Name | Description | 
|---|---|
| clear | Clears the managed array. This allows the elements of the array to be reused for appending. | 
| opOpAssign | Appends rhsto the managed array. | 
| put | Appends itemto the managed array. Performs encoding forchartypes ifAis a differently typedchararray. | 
| put | Appends an entire range to the managed array. Performs encoding for charelements ifAis a differently typedchararray. | 
| reserve | Reserve at least newCapacity elements for appending.  Note that more elements
 may be reserved than requested. If newCapacity <= capacity, then nothing is
 done. | 
| shrinkTo | Shrinks the managed array to the given length. | 
| toString | Gives a string in the form of Appender!(A)(data). | 
Parameters
| Name | Description | 
|---|---|
| A | the array type to simulate. | 
See Also
Example
auto app = appender!string();
string b = "abcdefg";
foreach (char c; b)
    appAuthors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.