Skip to content

Instantly share code, notes, and snippets.

@caseycrites
Created August 23, 2012 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caseycrites/3442540 to your computer and use it in GitHub Desktop.
Save caseycrites/3442540 to your computer and use it in GitHub Desktop.
/**
* Returns an index for which {@link #valueAt} would return the
* specified key, or a negative number if no keys map to the
* specified value.
* Beware that this is a linear search, unlike lookups by key,
* and that multiple keys can map to the same value and this will
* find only one of them.
*/
public int indexOfValue(E value) {
if (mGarbage) {
gc();
}
for (int i = 0; i < mSize; i++)
if (mValues[i] == value)
return i;
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment