forked from organicmaps/organicmaps
[search] Fix bug with empty search index data.
This commit is contained in:
parent
7cee9458bd
commit
cfddf0e9cd
2 changed files with 15 additions and 4 deletions
|
@ -56,21 +56,26 @@ void StringsFile::AddString(StringT const & s)
|
|||
m_strings.push_back(s);
|
||||
}
|
||||
|
||||
bool StringsFile::IteratorT::IsEnd() const
|
||||
{
|
||||
return m_file.m_queue.empty();
|
||||
}
|
||||
|
||||
StringsFile::StringT StringsFile::IteratorT::dereference() const
|
||||
{
|
||||
ASSERT ( !m_file.m_queue.empty(), () );
|
||||
ASSERT ( IsValid(), () );
|
||||
return m_file.m_queue.top().m_string;
|
||||
}
|
||||
|
||||
void StringsFile::IteratorT::increment()
|
||||
{
|
||||
ASSERT ( !m_file.m_queue.empty(), () );
|
||||
ASSERT ( IsValid(), () );
|
||||
int const index = m_file.m_queue.top().m_index;
|
||||
|
||||
m_file.m_queue.pop();
|
||||
|
||||
if (!m_file.PushNextValue(index))
|
||||
m_end = m_file.m_queue.empty();
|
||||
m_end = IsEnd();
|
||||
}
|
||||
|
||||
StringsFile::StringsFile(string const & fPath)
|
||||
|
|
|
@ -60,14 +60,20 @@ public:
|
|||
StringsFile & m_file;
|
||||
bool m_end;
|
||||
|
||||
bool IsEnd() const;
|
||||
inline bool IsValid() const { return (!m_end && !IsEnd()); }
|
||||
|
||||
public:
|
||||
IteratorT(StringsFile & file, bool isEnd)
|
||||
: m_file(file), m_end(isEnd)
|
||||
{
|
||||
// Additional check in case for empty sequence.
|
||||
if (!m_end)
|
||||
m_end = IsEnd();
|
||||
}
|
||||
|
||||
StringT dereference() const;
|
||||
bool equal(IteratorT const & r) const { return m_end == r.m_end; }
|
||||
bool equal(IteratorT const & r) const { return (m_end == r.m_end); }
|
||||
void increment();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue