public V put(int key, V value)
	{
		if (entrycnt == threshold) {
			capacity <<= 1;  // double the capacity
			allocateBuckets();
		}
		final int bktid = getBucket(key);
		int[] bucket = keytbl[bktid];
		final int lmt = (bucket == null ? 1 : bucket[0] + 1);
		int slot = 1;

		if (bucket == null) {
			// this bucket doesn't exist yet, so its obviously a new key, and we need to create its bucket
			bucket = growBucket(bktid);
		} else {
			// check if key already exists
			while (slot != lmt) {
				if (key == bucket[slot]) break;
				slot++;
			}

			if (slot == bucket.length) {
				// not only did we not find a match, but the bucket is full so we'll have to grow it before appending this new key to it
				bucket = growBucket(bktid);
			}
		}
		V oldvalue;

		if (slot == lmt) {
			// adding a new key
			bucket[slot] = key;
			bucket[0]++;
			entrycnt++;
			if (keyset_only) return null;
			oldvalue = null;
		} else {
			// updating the value of an existing key
			if (keyset_only) return dummyvalue; //there are no values, caller just wants to know that key existed
			oldvalue = valtbl[bktid][slot-1];
		}
		valtbl[bktid][slot-1] = value;
		return oldvalue;
	}