blob: c861da9d6fc6e3c4041ad1c58a2481a27db979e7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/searchlib/common/allocatedbitvector.h>
namespace search::tensor {
/*
* Tracker for visited nodes based on search::AllocatedBitVector. Best when
* many nodes are visited.
*/
class BitVectorVisitedTracker
{
search::AllocatedBitVector _visited;
public:
BitVectorVisitedTracker(uint32_t nodeid_limit, uint32_t);
~BitVectorVisitedTracker();
void mark(uint32_t nodeid) { _visited.setBit(nodeid); }
bool try_mark(uint32_t nodeid) {
if (_visited.testBit(nodeid)) {
return false;
} else {
_visited.setBit(nodeid);
return true;
}
}
};
}
|