Skip to content

Instantly share code, notes, and snippets.

@programaths
Last active August 29, 2015 14:28
Show Gist options
  • Save programaths/2ddf7cb7cf4de54677b9 to your computer and use it in GitHub Desktop.
Save programaths/2ddf7cb7cf4de54677b9 to your computer and use it in GitHub Desktop.
Remove items from a list on specific criterion
// The bad
isFound boolean = true;
while(isFound)
isFound = false;
for(j int from 1 to array.getSize())
if (array[j].attribute == "lookupValue")
array.removeElement(j);
isFound = true;
end
end
end
//And the beautifull
nbItems int=array.getSize();
j int=1;
while(j<=nbProfils)
if (array[j].attribute == "lookupValue")
array.removeElement(j);
nbItems=nbItems-1;
else
j=j+1;
end
end
//And the most beautifull
for(i int=array.getSize() to 1 by -1)
if (array[j].attribute == "lookupValue")
array.removeElement(j);
else
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment