uint64_t getBlockIndex(uint64_t const ikey) const { // std::cerr << "getBlockIndex(" << ikey << ")" << std::endl; if ( ! numentries ) return numentries; else if ( ikey < getMinKey() ) return 0; else if ( ikey > getMaxKey() ) return numentries-1; const_iterator ita = std::lower_bound(begin(),end(),value_type(ikey)); uint64_t const index = ita - begin(); if ( (ita != end()) && (*ita).ikey == ikey ) { return index; } else { assert ( index > 0 ); return index-1; } }
std::string MoveChunkRequest::toString() const { std::stringstream ss; ss << "ns: " << getNss().ns() << ", " << redact(ChunkRange(getMinKey(), getMaxKey()).toString()) << ", fromShard: " << getFromShardId() << ", toShard: " << getToShardId(); return ss.str(); }
bool MaxHeap::pushHeap(size_t value, float key) { if (heapIsFull()) { if(key > getMaxKey()) return false; HeapNode node = HeapNode(); node.key = key; node.value = value; swapNode(1,m_nextIndex-1); (*m_array)[m_nextIndex-1] = node; balanceTreeRec(1); return true; } else if (m_nextIndex == m_size) { HeapNode node = HeapNode(); node.key = key; node.value = value; (*m_array).push_back(node); m_nextIndex++; balanceEntireTree(); return true; } else { HeapNode node = HeapNode(); node.key = key; node.value = value; (*m_array).push_back(node); m_nextIndex++; return true; } }
void Board2048::checkOver(){ if(getMaxKey()>=2048){ showBoard('O'); } }