<commit_before>#ifndef _NODO_BINARY_TREE_HPP_
#define _NODO_BINARY_TREE_HPP_
#include <iostream>

template<class T>
class NodeBT
{
    private:
        T _key;
        NodeBT<T> *_left, *_right;
        
    public:
        NodeBT() : _left(NULL), _right(NULL) { };
        NodeBT(const T in) : _key(in), _left(NULL), _right(NULL) { };
        NodeBT(const T in, NodeBT<T>* l, NodeBT<T>* r) : _key(in), _left(l), _right(r) { };
        NodeBT(const NodeBT<T>& in) : _key(in.key), _left(NULL), _right(NULL) { };
    
        T getKey() const { return _key; }
        NodeBT<T>* getLeft() const { return _left; }
        NodeBT<T>* getRight() const { return _right; }
        bool isLeaf() const { return _left == NULL && _right == NULL; }
        bool isFullNode() const { return _left != NULL && _right != NULL; }
        int height() const { return max(height(_left), height(_right)); }
        
        void setKey(const T);
        void setLeft(NodeBT<T>*);
        void setRight(NodeBT<T>*);
        
    private:
        int height(NodeBT<T>*) const;
        int max(int, int) const;
};

/**
 * Key setter
 * */
template<class T>
void NodeBT<T>::setKey(const T item)
{
    _key = item;
}

/**
 * Left setter
 * */
template<class T>
void NodeBT<T>::setLeft(NodeBT<T>* l)
{
    _left = l;
}

/**
 * Right setter
 * */
template<class T>
void NodeBT<T>::setRight(NodeBT<T>* r)
{
    _right = r;
}

// =====================================================================

template<class T>
int NodeBT<T>::height(NodeBT<T>* p) const
{
    if (p != NULL)
    {
        if (p->isLeaf()) return 0;
        
        return 1 + max(height(p->getLeft()), height(p->getRight()));
    }
    return 0; 
}

template<class T>
int NodeBT<T>::max(int a, int b) const
{
    return a > b ? a : b;
}

#endif<commit_msg>height() added<commit_after>#ifndef _NODO_BINARY_TREE_HPP_
#define _NODO_BINARY_TREE_HPP_
#include <iostream>

template<class T>
class NodeBT
{
    private:
        T _key;
        NodeBT<T> *_left, *_right;
        
    public:
        NodeBT() : _left(NULL), _right(NULL) { };
        NodeBT(const T in) : _key(in), _left(NULL), _right(NULL) { };
        NodeBT(const T in, NodeBT<T>* l, NodeBT<T>* r) : _key(in), _left(l), _right(r) { };
        NodeBT(const NodeBT<T>& in) : _key(in.key), _left(NULL), _right(NULL) { };
    
        T getKey() const { return _key; }
        NodeBT<T>* getLeft() const { return _left; }
        NodeBT<T>* getRight() const { return _right; }
        bool isLeaf() const { return _left == NULL && _right == NULL; }
        bool isFullNode() const { return _left != NULL && _right != NULL; }
        int height() const;
        
        void setKey(const T);
        void setLeft(NodeBT<T>*);
        void setRight(NodeBT<T>*);
        
    private:
        int height(NodeBT<T>*) const;
        int max(int, int) const;
};

template<class T>
int NodeBT<T>::height() const
{
    if (this != NULL)
        return max(height(_left), height(_right));
    
    return 0;
}

/**
 * Key setter
 * */
template<class T>
void NodeBT<T>::setKey(const T item)
{
    _key = item;
}

/**
 * Left setter
 * */
template<class T>
void NodeBT<T>::setLeft(NodeBT<T>* l)
{
    _left = l;
}

/**
 * Right setter
 * */
template<class T>
void NodeBT<T>::setRight(NodeBT<T>* r)
{
    _right = r;
}

// =====================================================================

template<class T>
int NodeBT<T>::height(NodeBT<T>* p) const
{
    if (p != NULL)
    {
        if (p->isLeaf()) return 1;
        
        return 1 + max(height(p->getLeft()), height(p->getRight()));
    }
    return 0; 
}

template<class T>
int NodeBT<T>::max(int a, int b) const
{
    return a > b ? a : b;
}

#endif
{'fraction_non_alphanumeric': 0.19967620075553158, 'fraction_numerical': 0.0018888289260658392, 'mean_word_length': 2.695912263210369, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 61, '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': '343014', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1351, 'n_words': 320}