117 lines
6.5 KiB
MQL5
117 lines
6.5 KiB
MQL5
|
|
#ifndef LIB_MQLPLUS_OBJ_TREE_TEMPLATES_MQH_INCLUDED
|
||
|
|
#define LIB_MQLPLUS_OBJ_TREE_TEMPLATES_MQH_INCLUDED
|
||
|
|
#property version "1.0";
|
||
|
|
/**********************************************************************************
|
||
|
|
* Copyright (C) 2010-2022 Dominik Egert <info@freie-netze.de>
|
||
|
|
*
|
||
|
|
* This file is the objects include file.
|
||
|
|
*
|
||
|
|
* MQLplus, including this file may not be copied and/or distributed
|
||
|
|
* without explecit permit by the author.
|
||
|
|
* Author Dominik Egert / Freie Netze UG.
|
||
|
|
**********************************************************************************
|
||
|
|
*
|
||
|
|
* Version: 1.0
|
||
|
|
* State: production
|
||
|
|
*
|
||
|
|
* File information
|
||
|
|
* ================
|
||
|
|
*
|
||
|
|
*
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
#ifdef DBG_MSG_TRACE_FILE_LOADER
|
||
|
|
DBG_MSG_TRACE_FILE_LOADER;
|
||
|
|
|
||
|
|
#endif
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// Incluse base object
|
||
|
|
#include "nodes/lib_obj_node_tree_binary.mqh"
|
||
|
|
#include "base/lib_base_tree.mqh"
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/*********************************************************************************************************************************************************/
|
||
|
|
/* */
|
||
|
|
/* MQLplus data structures */
|
||
|
|
/* */
|
||
|
|
/*********************************************************************************************************************************************************/
|
||
|
|
|
||
|
|
|
||
|
|
///////////////////////////////////////
|
||
|
|
//
|
||
|
|
// Binary Tree object
|
||
|
|
//
|
||
|
|
|
||
|
|
// Derived simple type class object
|
||
|
|
#define BTREE_NODE_TYPE object_tree_node<USER_DATA>
|
||
|
|
#define TREE_TYPE _tree<USER_DATA, BTREE_NODE_TYPE>
|
||
|
|
|
||
|
|
template <typename USER_DATA>
|
||
|
|
struct binary_tree : public TREE_TYPE
|
||
|
|
{
|
||
|
|
// Constructors / Destructor
|
||
|
|
binary_tree() : TREE_TYPE() { };
|
||
|
|
binary_tree(const binary_tree<USER_DATA>& p_in) : TREE_TYPE(p_in) { };
|
||
|
|
~binary_tree() { };
|
||
|
|
|
||
|
|
// Assignment operator
|
||
|
|
void operator=(const binary_tree<USER_DATA>& p_in) { TREE_TYPE::operator=((TREE_TYPE)p_in); };
|
||
|
|
|
||
|
|
// Element functions
|
||
|
|
const bool add(USER_DATA& p_in) { return(TREE_TYPE::insert(p_in)); };
|
||
|
|
const bool remove(USER_DATA& p_in) { return(TREE_TYPE::remove(p_in)); };
|
||
|
|
|
||
|
|
// Comparison operators
|
||
|
|
const bool operator==(const binary_tree<USER_DATA>& p_in) { return(TREE_TYPE::operator==((TREE_TYPE)p_in)); }
|
||
|
|
const bool operator!=(const binary_tree<USER_DATA>& p_in) { return(!operator==(p_in)); }
|
||
|
|
};
|
||
|
|
|
||
|
|
#undef TREE_TYPE
|
||
|
|
#undef BTREE_NODE_TYPE
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// Derived complex type class object for pointers
|
||
|
|
#define BTREE_NODE_TYPE ptr_object_tree_node<USER_DATA>
|
||
|
|
#define TREE_TYPE _tree<USER_DATA*, BTREE_NODE_TYPE>
|
||
|
|
|
||
|
|
template <typename USER_DATA>
|
||
|
|
struct ptr_binary_tree : public TREE_TYPE
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
// Constructors / Destructor
|
||
|
|
ptr_binary_tree() : TREE_TYPE() { };
|
||
|
|
ptr_binary_tree(const ptr_binary_tree<USER_DATA>& p_in) : TREE_TYPE(p_in) { };
|
||
|
|
ptr_binary_tree(const bool _do_not_destroy) : TREE_TYPE() { p_params.do_not_destroy = _do_not_destroy; };
|
||
|
|
~ptr_binary_tree() { };
|
||
|
|
|
||
|
|
// Assignment operator
|
||
|
|
void operator=(const ptr_binary_tree<USER_DATA>& p_in) { TREE_TYPE::operator=((TREE_TYPE)p_in); };
|
||
|
|
|
||
|
|
// Buffer functions
|
||
|
|
const bool dnd(const bool _do_not_destroy = true) { p_params.do_not_destroy |= _do_not_destroy; return(p_params.do_not_destroy); };
|
||
|
|
|
||
|
|
// Element functions
|
||
|
|
const bool add(USER_DATA& p_in) { USER_DATA* tmp_ptr = new USER_DATA(p_in); return(TREE_TYPE::insert(tmp_ptr)); };
|
||
|
|
const bool add(USER_DATA* p_in) { return(TREE_TYPE::insert(p_in)); };
|
||
|
|
|
||
|
|
const bool remove(USER_DATA& p_in, const bool _do_not_destroy = false) { USER_DATA* tmp_ptr = GetPointer(p_in); return(TREE_TYPE::remove(tmp_ptr, p_params.do_not_destroy || _do_not_destroy)); };
|
||
|
|
const bool remove(USER_DATA* p_in, const bool _do_not_destroy = false) { return(TREE_TYPE::remove(p_in, p_params.do_not_destroy || _do_not_destroy)); };
|
||
|
|
|
||
|
|
// Comparison operators
|
||
|
|
const bool operator==(const ptr_binary_tree<USER_DATA>& p_in) { return(TREE_TYPE::operator==((TREE_TYPE)p_in)); }
|
||
|
|
const bool operator!=(const ptr_binary_tree<USER_DATA>& p_in) { return(!operator==(p_in)); }
|
||
|
|
};
|
||
|
|
|
||
|
|
#undef TREE_TYPE
|
||
|
|
#undef BTREE_NODE_TYPE
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
//
|
||
|
|
// END MQL data structures */
|
||
|
|
//*********************************************************************************************************************************************************/
|
||
|
|
#endif // LIB_MQLPLUS_OBJ_TREE_TEMPLATES_MQH_INCLUDED
|