You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
844 B
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "ifaces/INode.h"
#include "iterators/DFSIterator.h"
#include "iterators/BFSIterator.h"
namespace traversal {
/// \brief Фабрика итераторов узлов дерева.
/// \tparam T Тип алгоритма для обхода дерева.
/// Конструирует итерируемый объект с заданным алгоритмом обхода. Например, в ширину
/// или глубину.
template<typename Policy>
class Traversal {
INode* start;
public:
explicit Traversal(INode* start) : start(start) {}
explicit Traversal(NodePtr start) : start(start.get()) {}
Policy begin() const { return Policy(start); }
Policy end() const { return Policy(nullptr); }
};
using DFS = Traversal<DFSIterator<INode>>;
using BFS = Traversal<BFSIterator<INode>>;
}