/** @file context.cpp
 *
 *	Definition (implementation) of module designed to ease storage of N-grams context.
 *
 *	See context.h for more info.
 *
 *	(C) Ceslav Przywara 2008, MFF UK Prague
 *
 */

// We use numeric_limits<> here.
#include <limits>

#include "context.h"

namespace ace {

// Narrow flag bitmask use the most significant bit of frequency data.
const context_frequency_t PartOfContext::_max_frequency = std::numeric_limits<context_frequency_t>::max() >> 1;
const context_frequency_t PartOfContext::_narrow_flag_bitmask = ~PartOfContext::_max_frequency;

/*	Interface item implementation - for info see description in header file.
 */
void PartOfContext::inc(void) {
	if ( (_frequency & _max_frequency) == _max_frequency ) {
		// Maximum count reached - do nothing.
		return;
	}
	// Increase.
	++_frequency;
}

} // namespace ace
