bool FilterList::GetFilterByID(UINT ID, FilterInfo *pFilter) const { const int Index = IDToIndex(ID); if (Index < 0) return false; *pFilter = m_FilterList[Index]; return true; }
const JString& CBFileListTable::GetFileName ( const JFAID_t id ) const { JIndex index; const JBoolean found = IDToIndex(id, &index); assert( found ); return *((GetFullNameList()).NthElement(index)); }
JFAID_t CBFileListTable::GetUniqueID() const { if (itsFileInfo->IsEmpty()) { return JFAID::kMinID; } const JFAID_t prevUniqueID = JMax(itsLastUniqueID, (JFAID_t) itsFileInfo->GetElementCount()); // this is relevant to the outmost do-while loop enum Range { kAboveLastUniqueID, kBelowLastUniqueID, kEmpty }; Range idRange = kAboveLastUniqueID; do { // try the larger Id's first JFAID_t firstId, lastId; if (idRange == kAboveLastUniqueID && prevUniqueID < JFAID::kMaxID) { firstId = prevUniqueID + 1; lastId = JFAID::kMaxID; } else if (idRange == kAboveLastUniqueID) { idRange = kBelowLastUniqueID; firstId = JFAID::kMinID; lastId = JFAID::kMaxID; } else { assert( idRange == kBelowLastUniqueID ); firstId = JFAID::kMinID; lastId = prevUniqueID; } // try all possible id's in the given range for (JFAID_t id=firstId; id<=lastId; id++) { JIndex index; if (!IDToIndex(id, &index)) { itsLastUniqueID = id; return id; } } if (idRange == kAboveLastUniqueID) { idRange = kBelowLastUniqueID; } else if (idRange == kBelowLastUniqueID) { idRange = kEmpty; } } while (idRange != kEmpty); // We've tried everything. It's time to give up. return JFAID::kInvalidID; }