Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NiExtraData* NiObjectNET::GetExtraData(const NiFixedString& kKey) const
- {
- if (!kKey.Exists())
- {
- #ifndef __SPU__
- NiOutputDebugString(
- "Error: Attempt to retrieve ExtraData with null name.");
- #endif
- return NULL;
- }
- NIASSERT(m_usExtraDataSize < SHRT_MAX);
- short sBottom = 0;
- short sTop = (short)m_usExtraDataSize - 1;
- short sMiddle = 0;
- while (sBottom <= sTop)
- {
- sMiddle = (sTop + sBottom) >> 1; // Average to get the middle.
- ptrdiff_t dtCompare = ((const char*)kKey) -
- ((const char*)m_ppkExtra[sMiddle]->GetName());
- if (dtCompare == 0) // Equal keys. Return found extra data.
- {
- return m_ppkExtra[sMiddle];
- }
- else if (dtCompare > 0) // Search key is > "middle" key.
- {
- sBottom = sMiddle + 1;
- }
- else // Search key is < "middle" key.
- {
- sTop = sMiddle - 1;
- }
- }
- return NULL; // Couldn't find Extra Data for the given search key.
- }
- //---------------------------------------------------------------------------
- bool NiObjectNET::RemoveExtraData(const NiFixedString& kKey)
- {
- if (m_usExtraDataSize == 0)
- return NULL;
- if (!kKey.Exists())
- {
- #ifndef __SPU__
- NiOutputDebugString(
- "Error: Attempt to remove ExtraData using a null name.");
- #endif
- return false;
- }
- NIASSERT(m_usExtraDataSize < SHRT_MAX);
- short sBottom = 0;
- short sTop = (short)m_usExtraDataSize - 1;
- short sMiddle = 0;
- while (sBottom <= sTop)
- {
- sMiddle = (sTop + sBottom) >> 1; // Average to get the middle.
- ptrdiff_t dtCompare = ((const char*)kKey) -
- ((const char*) m_ppkExtra[sMiddle]->GetName());
- if (dtCompare == 0) // Equal keys. Return found extra data.
- {
- DeleteExtraData(sMiddle);
- return true;
- }
- else if (dtCompare > 0) // Search key is > "middle" key.
- {
- sBottom = sMiddle + 1;
- }
- else // Search key is < "middle" key.
- {
- sTop = sMiddle - 1;
- }
- }
- return false; // Couldn't find Extra Data for the given search key.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement