/** * Returns true if this collection contains the specified element. * * For lists this method has a time complexity of O(N), * with N being the size of the list. * * For tree sets this method has a time complexity of O(Log N), * with N being the size of the set. * * For hash sets this method has a complexity of O(1). * * @return int rc != 0: The specified element is present. * @return int rc == 0: The specified element is not present. */ int pblCollectionContains( PblCollection * collection, /** The collection to use */ void * element /** Element to look for */ ) { if( PBL_LIST_IS_LIST( collection ) ) { return ( pblListIndexOf( (PblList *)collection, element ) >= 0 ); } return pblSetContains( (PblSet*)collection, element ); }
/** * Returns true if this map contains a mapping for the specified key. * * More formally, returns true if and only if this map contains a mapping for a key k such that * (key==null ? k==null : memcmp( key, k, keyLength ) == 0. (There can be at most one such mapping.) * * For hash maps his method has a time complexity of O(1). * For tree maps this method has a time complexity of O(Log N). * * @return int rc > 0: The map contains a mapping for the specified key. * @return int rc == 0: The map did not contain a mapping for the key. */ int pblMapContainsKey( /* */ PblMap * map, /** The map to check */ void * key, /** Key whose presence in this map is to be tested */ size_t keyLength /** Length of the key */ ) { PblMapKey mapKey; mapKey.tag = PBL_MAP_KEY_TAG; mapKey.keyLength = keyLength; mapKey.key = key; return pblSetContains( map->entrySet, &mapKey ); }
int find_my_color(PblSet * psetcolors, int nodes) { int color; for (color = 1; pblSetContains(psetcolors, (void *) color) && color < nodes; color++); return color; }