<commit_before>/*
 * TTNodeDirectory
 * Copyright © 2008, <NAME> & <NAME>
 *
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#include "TTNodeDirectory.h"
#include <algorithm>

TTNodeDirectory::TTNodeDirectory(TTSymbolPtr aName) :
	name(kTTSymEmpty),	
	root(NULL),	
	directory(NULL),
	aliases(NULL),
	observers(NULL),
	mutex(NULL)
{	
	// set the name of the tree
	name = aName;

	init();
}

TTNodeDirectory::~TTNodeDirectory()
{
	delete root;
	delete directory;
	delete aliases;
	delete observers;
}

TTErr TTNodeDirectory::init()
{
	TTBoolean nodeCreated = NO;
	
	if (root) delete root;
	if (directory) delete directory;
	if (aliases) delete aliases;
	
	// create a new directory
	directory = new TTHash();
	
	// create a new aliases table
	aliases = new TTHash();
	
	// if there are observers keep them
	if (!observers) {
		
		// create a lifeCycleObservers and protect it from multithreading access
		// why ? because observers could disappear when they know an address is destroyed
		this->observers = new TTHash();
		this->observers->setThreadProtection(true);
	}
	
	mutex = new TTMutex(true);
	
	// create a root
	TTNodeCreate(kTTAdrsRoot, NULL, this, &this->root, &nodeCreated);
}

TTErr TTNodeDirectory::setName(TTSymbolPtr aName)
{
	name = aName;
	return kTTErrNone;
}

TTSymbolPtr	TTNodeDirectory::getName()
{
	return name;
}

TTNodePtr	TTNodeDirectory::getRoot()
{
	return root;<commit_msg>returning the result of TTNodeCreate in the init method<commit_after>/*
 * TTNodeDirectory
 * Copyright © 2008, <NAME> <NAME> & <NAME>
 *
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#include "TTNodeDirectory.h"
#include <algorithm>

TTNodeDirectory::TTNodeDirectory(TTSymbolPtr aName) :
	name(kTTSymEmpty),	
	root(NULL),	
	directory(NULL),
	aliases(NULL),
	observers(NULL),
	mutex(NULL)
{	
	// set the name of the tree
	name = aName;

	init();
}

TTNodeDirectory::~TTNodeDirectory()
{
	delete root;
	delete directory;
	delete aliases;
	delete observers;
}

TTErr TTNodeDirectory::init()
{
	TTBoolean nodeCreated = NO;
	
	if (root) delete root;
	if (directory) delete directory;
	if (aliases) delete aliases;
	
	// create a new directory
	directory = new TTHash();
	
	// create a new aliases table
	aliases = new TTHash();
	
	// if there are observers keep them
	if (!observers) {
		
		// create a lifeCycleObservers and protect it from multithreading access
		// why ? because observers could disappear when they know an address is destroyed
		this->observers = new TTHash();
		this->observers->setThreadProtection(true);
	}
	
	mutex = new TTMutex(true);
	
	// create a root
	return TTNodeCreate(kTTAdrsRoot, NULL, this, &this->root, &nodeCreated);
}

TTErr TTNodeDirectory::setName(TTSymbolPtr aName)
{
	name = aName;
	return kTTErrNone;
}

TTSymbolPtr	TTNodeDirectory::getName()
{
	return name;
}

TTNodePtr	TTNodeDirectory::getRoot()
{
	return root;
{'fraction_non_alphanumeric': 0.11436170212765957, 'fraction_numerical': 0.0026595744680851063, 'mean_word_length': 4.363636363636363, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 18, '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': '6868423', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1000, 'n_words': 293}