Array List object?
Gan via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jan 26 22:02:38 PST 2015
On Tuesday, 27 January 2015 at 06:00:50 UTC, Gan wrote:
> On Tuesday, 27 January 2015 at 05:32:09 UTC, Gan wrote:
>> Hey I'm using normal arrays for my project:
>> //Declaring the array
>> SBTile[] tiles;
>>
>> //Initializing the array
>> tiles = new SBTile[](0);
>>
>> //Clearing the array
>> tiles = [];
>>
>> //Removing a tile at index i from the array
>> tiles.remove(i);
>>
>> //Adding a tile to the array
>> tiles ~= tile;
>>
>> But I think I'm doing something very wrong because my list of
>> tiles is growing larger and larger. Am I misusing the array or
>> is there a better way of doing those array list functions?
>
> Found my problem. When you call remove, you need to set it.
>
> tiles = tiles.remove(i);
>
> Though isn't it incredibly inefficient to continually have it
> re-create the arrays for adding and removing? I'm asking cause
> I'm not very knowledgable on this subject.
On a side note, my program's ram usage is increasing very
rapidly. All I'm doing to adding and removing objects from an
array.
More information about the Digitalmars-d-learn
mailing list