public int addAndGetPosition(Type type, Block block, int position, long valueHash)
    {
        if (values.getPositionCount() >= maxFill) {
            rehash();
        }

        int bucketId = getBucketId(valueHash, mask);
        int valuePointer;

        // look for an empty slot or a slot containing this key
        int probeCount = 1;
        int originalBucketId = bucketId;
        while (true) {
            checkState(probeCount < bucketCount, "could not find match for value nor empty slot in %s buckets", bucketCount);
            valuePointer = buckets.get(bucketId);

            if (valuePointer == EMPTY_BUCKET) {
                valuePointer = values.getPositionCount();
                valueHashes.set(valuePointer, (int) valueHash);
                type.appendTo(block, position, values);
                buckets.set(bucketId, valuePointer);

                return valuePointer;
            }
            else if (type.equalTo(block, position, values, valuePointer)) {
                // value at position
                return valuePointer;
            }
            else {
                int probe = nextProbe(probeCount);
                bucketId = nextBucketId(originalBucketId, mask, probe);
                probeCount++;
            }
        }
    }
public int addAndGetPosition ( Type type , Block block , int position , long valueHash ) { if ( values . getPositionCount ( ) >= maxFill ) { rehash ( ) ; } int bucketId = getBucketId ( valueHash , mask ) ; int valuePointer ; int probeCount = 1 ; int originalBucketId = bucketId ; while ( true ) { checkState ( probeCount < bucketCount , "could not find match for value nor empty slot in %s buckets" , bucketCount ) ; valuePointer = buckets . get ( bucketId ) ; if ( valuePointer == EMPTY_BUCKET ) { valuePointer = values . getPositionCount ( ) ; valueHashes . set ( valuePointer , ( int ) valueHash ) ; type . appendTo ( block , position , values ) ; buckets . set ( bucketId , valuePointer ) ; return valuePointer ; } else if ( type . equalTo ( block , position , values , valuePointer ) ) { return valuePointer ; } else { int probe = nextProbe ( probeCount ) ; bucketId = nextBucketId ( originalBucketId , mask , probe ) ; probeCount ++ ; } } }
This will add an item if not already in the system. It returns a pointer that is unique for multiple instances of the value. If item present,
returns the pointer into the system