aboutsummaryrefslogtreecommitdiff
path: root/src/zenstore/hashkeyset.cpp
blob: a5436f5cb0fc0e0f1c72db858d47c9a8f7018aa8 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright Epic Games, Inc. All Rights Reserved.

#include <zenstore/hashkeyset.h>

//////////////////////////////////////////////////////////////////////////

namespace zen {

void
HashKeySet::AddHashToSet(const IoHash& HashToAdd)
{
	m_HashSet.insert(HashToAdd);
}

void
HashKeySet::AddHashesToSet(std::span<const IoHash> HashesToAdd)
{
	m_HashSet.insert(HashesToAdd.begin(), HashesToAdd.end());
}

void
HashKeySet::RemoveHashesIf(std::function<bool(const IoHash& CandidateHash)>&& Predicate)
{
	for (auto It = begin(m_HashSet), ItEnd = end(m_HashSet); It != ItEnd;)
	{
		if (Predicate(*It))
		{
			It = m_HashSet.erase(It);
		}
		else
		{
			++It;
		}
	}
}

void
HashKeySet::IterateHashes(std::function<void(const IoHash& Hash)>&& Callback) const
{
	for (auto It = begin(m_HashSet), ItEnd = end(m_HashSet); It != ItEnd; ++It)
	{
		Callback(*It);
	}
}

//////////////////////////////////////////////////////////////////////////
//
// Testing related code follows...
//

#if ZEN_WITH_TESTS

void
hashkeyset_forcelink()
{
}

#endif

}  // namespace zen