public int register ( String key ) { Integer id = store . get ( key ) ; if ( id != null ) { return id ; } int localId = nextId . getAndIncrement ( ) ; while ( localId < maxId ) { if ( store . setIfAbsent ( key , localId ) ) { return localId ; } Integer storeId = store . get ( key ) ; if ( storeId != null ) { return storeId ; } localId = nextId . getAndIncrement ( ) ; } throw new IllegalStateException ( "StringMap id space exhausted" ) ; }
Registers a key with the map and returns the matching id .