File indexing completed on 2024-03-24 03:54:32
0001 /* 0002 This file is part of the KDE Baloo project. 0003 SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #include "vectorpostingiterator.h" 0009 0010 using namespace Baloo; 0011 0012 VectorPostingIterator::VectorPostingIterator(const QVector<quint64>& values) 0013 : m_values(values) 0014 , m_pos(-1) 0015 { 0016 } 0017 0018 quint64 VectorPostingIterator::docId() const 0019 { 0020 if (m_pos < 0 || m_pos >= m_values.size()) { 0021 return 0; 0022 } 0023 0024 return m_values[m_pos]; 0025 } 0026 0027 quint64 VectorPostingIterator::next() 0028 { 0029 if (m_pos >= m_values.size() - 1) { 0030 m_pos = m_values.size(); 0031 m_values.clear(); 0032 return 0; 0033 } 0034 0035 m_pos++; 0036 return m_values[m_pos]; 0037 }