I have an array of integers 0,0,0,2,2,3. I have a list which displays these values along with a button to remove these values from the array. I know how to remove the list item but not a actual specified value, I could do pick each interger but the values after wouldnt shift back by 1
for example
array [ 0,0,0,1,1,2]
I then use the remove button to remove array element 4 which is 1
This is how I want the array to become after the remove
Galaxy doesn't support dynamic memory, so the size of your array will never change. You can use invalid values to indicate that spot is "empty" if you want. My solution is to use strings with some sort of delimiter for my integer arrays... like "1 404 193 04 2 40 2"
I have an array of integers 0,0,0,2,2,3. I have a list which displays these values along with a button to remove these values from the array. I know how to remove the list item but not a actual specified value, I could do pick each interger but the values after wouldnt shift back by 1
for example
array [ 0,0,0,1,1,2]
I then use the remove button to remove array element 4 which is 1
This is how I want the array to become after the remove
array[0,0,0,1,2]
Is there anyway to do this?
@farban6: Go
Galaxy doesn't support dynamic memory, so the size of your array will never change. You can use invalid values to indicate that spot is "empty" if you want. My solution is to use strings with some sort of delimiter for my integer arrays... like "1 404 193 04 2 40 2"
@soulzek:
You need to also keep track of how many numbers you have.
eg:
int array = [0, 0, 0, 1, 1, 2];
int size = 6;
list_array()
{
int i;
for(i = 1; i <= size; i++}
AddListItem(array[i]);
}
remove(x)
{
int i;
for(i = x; i <size; i++)
array[i] = array[i + 1]
size = size - 1;
}
so the command list() would result in 0,0,0,1,1,2
after the command remove(4) the array would be 0,0,0,1,2,2
but list() would now return 0,0,0,1,2
the size of the array cannot change. So just make sure that you make it bigger than you need to and then keep track of how big the list is yourself.