public boolean hasKey(final Key aKey) { if (mKeyCache.indexOfValue(aKey) >= 0) { return true; } for (final Key key : getKeys()) { if (key == aKey) { mKeyCache.put(key.getCode(), key); return true; } } return false; }
// generate a string and return a key that will get that string. // note, you probably shouldn't call this except at loading time, // and never call this during game play public int generateString(String s, double size) { // see if already contained int checked_key = string_container.indexOfValue(s); if (checked_key > 0) return checked_key; // find a key // not the most efficient. // but 'shouldnt' have collision problems. int key = 0; boolean key_found = false; while (!key_found) { key = GLBitmapReader.newResourceID(); if (bitmap_buffer.get(key) == null) key_found = true; } // generate generateString(s, size, key); return key; }