<commit_before>#ifndef node_node_system_h
#define node_node_system_h
#include <vector>
#include <tuple>
#include <unordered_set>
#include <boost/optional.hpp>
#include "../types.hh"
#include "node.hh"
#include "../helpers/variadic.hh"


namespace doanimate {
	namespace nodes {
		struct node_wrapper {
			node* n;
			std::vector<std::pair<size_t, size_t>> input_links;

			inline node_wrapper(node* n) : n(n), input_links(n->get_inputs().size(), {-1, 0}) {
			}
		};


		class node_system {
			protected:
				std::vector<boost::optional<node_wrapper>> nodes;

			public:
				template <typename T>
				class iterator_base {
					protected:
					T begin;
					T current;
					T end;

					iterator_base(T begin, T end) : begin(begin), current(begin), end(end) {
						while (*current == boost::none and current != end)
							++ current;
					}

					public:

					iterator_base() {
					}

					iterator_base<T> operator++() {
						++ current;
						while (*current == boost::none and current != end)
							++ current;
						return *this;
					}

					node_wrapper& operator*() {
						return (*current).value();
					}

					node_wrapper* operator->() {
						return &*current;
					}

					size_t index() const {
						return current - begin;
					}

					friend node_system;
				};

				using iterator = iterator_base<decltype(nodes)::iterator>;
				using const_iterator = iterator_base<decltype(nodes)::const_iterator>;

				inline node_system() {
				}

				iterator begin();

				iterator end();

				const_iterator cbegin() const;

				const_iterator cend() const;

				const_iterator begin() const;

				const_iterator end() const;

				node_wrapper& at(size_t index);

				void remove(iterator it);

				void remove(const size_t index);

				size_t add(node* n);

				void quick_add(node* n);

				void rerun(const std::unordered_set<size_t> source, const bool skip_first_stage = false);

				template <typename... Ts>
					void rerun(size_t first, Ts... data) {
						return rerun(helpers::unordered_set_of(first, data...));
					}

				void rerun(const std::unordered_set<iterator*> source);

				template <typename... Ts>
					void rerun(iterator* first, Ts... data) {
						return rerun(helpers::unordered_set_of(first, data...));
					}

				void rerun();

				bool would_create_cycle(const size_t node, const std::pair<size_t, size_t> connection) const;

				void force_connection(const size_t node, const size_t index, const std::pair<size_t, size_t> connection);

				bool create_connection(const size_t node, const size_t index, const std::pair<size_t, size_t> connection);
		};
	}
}
#endif
<commit_msg>Formatted node_system.hh<commit_after>#ifndef node_node_system_h
#define node_node_system_h
#include <vector>
#include <tuple>
#include <unordered_set>
#include <boost/optional.hpp>
#include "../types.hh"
#include "node.hh"
#include "../helpers/variadic.hh"


namespace doanimate {
	namespace nodes {
		struct node_wrapper {
			node* n;
			std::vector<std::pair<size_t, size_t>> input_links;

			inline node_wrapper(node* n)
				: n(n), input_links(n->get_inputs().size(), {-1, 0}) {
			}
		};


		class node_system {
			protected:
				std::vector<boost::optional<node_wrapper>> nodes;

			public:
				template <typename T>
				class iterator_base {
					protected:
					T begin;
					T current;
					T end;

					iterator_base(T begin, T end)
						: begin(begin), current(begin), end(end) {
						while (*current == boost::none and current != end)
							++ current;
					}

					public:

					iterator_base() {
					}

					iterator_base<T> operator++() {
						++ current;
						while (*current == boost::none and current != end)
							++ current;
						return *this;
					}

					node_wrapper& operator*() {
						return (*current).value();
					}

					node_wrapper* operator->() {
						return &*current;
					}

					size_t index() const {
						return current - begin;
					}

					friend node_system;
				};

				using iterator = iterator_base<decltype(nodes)::iterator>;
				using const_iterator = iterator_base<decltype(nodes)::const_iterator>;

				inline node_system() {
				}

				iterator begin();

				iterator end();

				const_iterator cbegin() const;

				const_iterator cend() const;

				const_iterator begin() const;

				const_iterator end() const;

				node_wrapper& at(size_t index);

				void remove(iterator it);

				void remove(const size_t index);

				size_t add(node* n);

				void quick_add(node* n);

				void rerun(const std::unordered_set<size_t> source,
						const bool skip_first_stage = false);

				template <typename... Ts>
					void rerun(size_t first, Ts... data) {
						return rerun(helpers::unordered_set_of(first, data...));
					}

				void rerun(const std::unordered_set<iterator*> source);

				template <typename... Ts>
					void rerun(iterator* first, Ts... data) {
						return rerun(helpers::unordered_set_of(first, data...));
					}

				void rerun();

				bool would_create_cycle(const size_t node,
						const std::pair<size_t, size_t> connection) const;

				void force_connection(const size_t node, const size_t index,
						const std::pair<size_t, size_t> connection);

				bool create_connection(const size_t node, const size_t index,
						const std::pair<size_t, size_t> connection);
		};
	}
}
#endif

{'fraction_non_alphanumeric': 0.13027037247116657, 'fraction_numerical': 0.0007562866326337682, 'mean_word_length': 3.053639846743295, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4585158', 'n_tokens_mistral': 2265, 'n_tokens_neox': 1670, 'n_words': 413}