Open C++ Libraries.org
develop
Loading...
Searching...
No Matches
bfs.hpp
1
// SPDX-License-Identifier: BSL-1.0
2
// Copyright 2026, Amlal El Mahrouss (amlal@nekernel.org)
3
// Distributed under the Boost Software License, Version 1.0. (See accompanying
4
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
// Official repository: https://github.com/open-cpp-libraries/tproc
6
7
#ifndef OCL_TPROC_BFS_HPP
8
#define OCL_TPROC_BFS_HPP
9
10
#include <ocl/tproc/detail/config.hpp>
11
12
namespace
ocl::tproc::bfs
13
{
14
template
<
typename
T>
15
struct
source_iterator;
16
18
template
<
typename
T>
19
struct
source_iterator
final
20
{
21
public
:
22
using
type = T;
23
using
pointer = T*;
24
using
PredT = pointer (*)(pointer);
26
27
[[maybe_unused]]
static
pointer
end
()
28
{
29
return
nullptr
;
30
}
31
32
};
33
36
template
<
typename
SrcIt>
37
inline
typename
SrcIt::type find(
typename
SrcIt::pointer beg,
typename
SrcIt::PredT pred)
38
{
39
if
(beg == SrcIt::end())
40
return
beg;
41
42
[[maybe_unused]]
auto
beg_ = beg;
43
[[maybe_unused]]
auto
prev_beg_ = beg_;
44
45
do
46
{
47
if
(!prev_beg_)
48
return
SrcIt::end();
49
50
if
(!beg_)
51
{
52
beg_ = prev_beg_->root;
53
if
(!beg_)
54
return
SrcIt::end();
55
56
continue
;
57
}
58
59
if
(pred(beg_))
60
return
beg_;
61
62
prev_beg_ = beg_;
63
64
if
(beg_->left)
65
beg_ = beg_->left;
66
else
if
(beg->right)
67
beg_ = beg_->right;
68
69
}
while
(beg_ && prev_beg_);
70
71
return
SrcIt::end();
72
}
73
74
}
// namespace ocl::tproc::bfs
75
76
#include "bfs.inl"
77
78
#endif
// OCL_TPROC_BFS_HPP
ocl::tproc::bfs::source_iterator
This data structure contains information about an iterator.
Definition
bfs.hpp:20
ocl::tproc::bfs::source_iterator::end
static pointer end()
the end iterator
Definition
bfs.hpp:27
libs
tproc
include
ocl
tproc
algos
bfs.hpp
Generated by
1.9.8