void ArpLongArray::AddAt(long index, long value) {
	if (index >= size) GrowToAtLeast(index);

	count++;
	for (long i=count; i>index; i--) elements[i] = elements[i-1];
	elements[index] = value;
}
// Add the node to the chain.  First we must verify that the chain
// is large enough for nArg; if not, grow it.  Than add it at
// the appropriate index.
status_t ArpIndexedList::pAddNode(ArpIndexedNode *node)
{
	long hash = HashForIndex(node->Index());
#if 0 	// why did I write this?  Isn't the POINT that if the hash is
		// too large, then the list grows?
	if (not HashExists(hash)) {
		delete node;
		return B_ERROR;
	}
#endif

	if (hash >= count) {
		GrowToAtLeast(hash + ARP_CHAIN_INCREMENT);	
	}

	if (chain[hash] == NULL) {
		chain[hash] = node;
		pAddNodeAtChainHead(node, hash);
	} else if (node->Index() < chain[hash]->Index()) {
		chain[hash]->AddNode(node);
		chain[hash] = node;
	} else {
		chain[hash]->AddNode(node);
	}
	
	// If the node is the new last node in the list then assign it
	// to the cached tailNode.
//	if ((tailNode == NULL) or (tailNode->Index() < node->Index()))
//		tailNode = node;

	AddedNode(node);
	return B_OK;
}
void TestConcurrentGrowToAtLeast() {
    MyVector v;
    for( size_t s=1; s<1000; s*=10 ) {
        tbb::parallel_for( tbb::blocked_range<size_t>(0,1000000,100), GrowToAtLeast(v) );
    }
}
void ArpLongArray::AtNextPut(long value) {
	if ((count+1) >= size) GrowToAtLeast(count+1);
	count++;
	elements[count] = value;
}
void ArpLongArray::AtPut(long index, long value) {
	if (index >= size) GrowToAtLeast(index);
	elements[index] = value;
	if (index > count) count = index;
}
ArpIndexedList::ArpIndexedList(int32 chainIndexesArg) {
	chain = 0;
	chainIndexes = chainIndexesArg;
	GrowToAtLeast(ARP_CHAIN_INCREMENT);
	tailNode = 0;
}