Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CharCountNode
- {
- private:
- char character;
- int count;
- public:
- CharCountNode * left;
- CharCountNode * right;
- CharCountNode()
- {
- character = '~';
- count = 0;
- left = right = NULL;
- }
- CharCountNode(char c, int n)
- {
- character = c;
- count = n;
- left = right = NULL;
- }
- ~CharCountNode()
- {
- delete right;
- right = NULL;
- delete left;
- left = NULL;
- }
- CharCountNode(const CharCountNode & rhs)
- {
- character = rhs.character;
- count = rhs.count;
- if (rhs.left == NULL)
- left = NULL;
- else
- left = new CharCountNode(*rhs.left);
- if (rhs.right == NULL)
- right = NULL;
- else
- right = new CharCountNode(*rhs.right);
- }
- CharCountNode operator=(const CharCountNode & rhs)
- {
- character = rhs.character;
- count = rhs.count;
- if (rhs.left == NULL)
- left = NULL;
- else
- left = new CharCountNode(*rhs.left);
- if (rhs.right == NULL)
- right = NULL;
- else
- right = new CharCountNode(*rhs.right);
- return *this;
- }
- char getCharacter()
- { return character; }
- int getCount()
- { return count; }
- bool operator<(const CharCountNode & rhs) const
- { return count < rhs.count; }
- bool operator>(const CharCountNode & rhs) const
- { return count > rhs.count; }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement