www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is std.container.array more or less an equivalent of C#'s List<T>?

reply A Guy With a Question <aguywithanquestion gmail.com> writes:
Reading this, the interface seems very similar, but I'm not sure. 
There's only like a two sentence general description, then it 
goes on to talk about a boolean specialization...

https://dlang.org/phobos/std_container_array.html

I'm looking for something that doesn't have to resize every 
insert/append, but also it's going to be copying the whole array 
either each time.
Dec 04 2017
next sibling parent A Guy With a Question <aguywithanquestion gmail.com> writes:
On Monday, 4 December 2017 at 16:26:02 UTC, A Guy With a Question 
wrote:
 Reading this, the interface seems very similar, but I'm not 
 sure. There's only like a two sentence general description, 
 then it goes on to talk about a boolean specialization...

 https://dlang.org/phobos/std_container_array.html

 I'm looking for something that doesn't have to resize every 
 insert/append, but also it's going to be copying the whole 
 array either each time.
For clarity (had a typo in the original question). I do not want it copying the entire array every time. I'm looking for something
Dec 04 2017
prev sibling next sibling parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 12/4/17 11:26 AM, A Guy With a Question wrote:
 Reading this, the interface seems very similar, but I'm not sure. 
 There's only like a two sentence general description, then it goes on to 
 talk about a boolean specialization...
 
 https://dlang.org/phobos/std_container_array.html
 
 I'm looking for something that doesn't have to resize every 
 insert/append, but also it's going to be copying the whole array either 
 each time.
Appending is amortized (IIRC, it doubles the size when it needs more space), everything else must copy data. It's an array underneath, but instead of using the GC, it uses C heap functions. It isn't really any different than a D builtin array, but has some better performance characteristics in some cases. It's also not safe to keep pointers to elements if it reallocs. -Steve
Dec 04 2017
prev sibling parent Basile B. <b2.temp gmx.com> writes:
On Monday, 4 December 2017 at 16:26:02 UTC, A Guy With a Question 
wrote:
 Reading this, the interface seems very similar, but I'm not 
 sure. There's only like a two sentence general description, 
 then it goes on to talk about a boolean specialization...

 https://dlang.org/phobos/std_container_array.html

 I'm looking for something that doesn't have to resize every 
 insert/append, but also it's going to be copying the whole 
 array either each time.
std.Array.Appender or iz.containers.Array
Dec 04 2017