SRL Archive - Help and Support

Clearing an Int from a TIA without a Loop?


Sir Ducksworthy

2012-07-06 18:18:12

Is their some Pascal Function that will do this that anyone knows of, I just want to Completely delete a Single Piece of an Integer Array that Contains 1 '0' without Looping through it but also delete it's Length from the array without scanning every piece to see if it contains null

Edit:
Dw I got it
     
Store[5]:=High(CombinedColors);
For Store[6]:=0 to Store[5] do
if(CombinedColors[Store[6]]=0)then
begin
DeleteValueInIntArray(CombinedColors, Store[6]);
Store[5]:=Store[5]-1;
Break;
end;

Sin

2012-07-06 18:22:11

Not quite sure what you mean but this might work.
Instead of calling from 0 to High(TIA) do

for i := 1 to High(TIntegerArray) do

weequ

2012-07-06 18:25:17

SetLength(CurrentLength-1)?

before that move the last item in the array to the index which you want to remove.

I don't think I understood your question correctly though.

Sir Ducksworthy

2012-07-06 18:37:44

;) Ty for trying guy's. I got it now XD ^

Brandon

2012-07-06 18:38:24

Not possible. Even if pascal had iterators, you'd iterate through the entire array.


For I:= 0 To High(IntArray) Do
if (IntArray[I] = 0) then
DeleteValueInIntArray(IntArray, I);

Daniel

2012-07-06 18:55:50

From: Shay
Instead of calling from 0 to High(TIA) do

for i := 1 to High(TIntegerArray) do


Err..?

weequ

2012-07-06 19:02:19

From: Brandon
Not possible. Even if pascal had iterators, you'd iterate through the entire array.


For I:= 0 To High(IntArray) Do
if (IntArray[I] = 0) then
DeleteValueInIntArray(IntArray, I);
Yeah unless you keep track of the location of the value. Or you could keep the values in the array in order when you could find values in a logarithmic time (binary search algorithm). One option is using a hash function.

Sin

2012-07-06 21:43:01

From: Daniel
Err..?


I highly doubt I explained it properly.
I meant that if the number he wanted to delete was the lowest, then he could just not use the number, rather than calling it from the lowest.

n3ss3s

2012-07-09 00:09:12

Do you care about the order of the values? If not, you can swap the last place and the one with the 0 and then set length to 1 less…