<commit_before>#ifndef PANDORA_HSIZE_H
#define PANDORA_HSIZE_H

#include <stdexcept>

namespace pandora {

class PSize {
public:
	typedef hsize_t        value_type;
	typedef hsize_t       *iterator;
	typedef const hsize_t *const_iterator;
	typedef hsize_t       &reference;
	typedef const hsize_t  const_reference;
	typedef hsize_t       *pointer;
	typedef size_t         difference_type;
	typedef size_t         size_type;

	PSize() : rank(0), dims(nullptr) { }

	explicit PSize(size_t _rank) : rank(_rank), dims(nullptr) {
		allocate();
	}

	//copy
	PSize(const PSize &other) : rank(other.rank), dims(nullptr) {
		allocate();
		std::copy(other.dims, other.dims + rank, dims);
	}

	//move (not tested due to: http://llvm.org/bugs/show_bug.cgi?id=12208)
	PSize(PSize &&other) : rank(other.rank), dims(other.dims) {
		other.dims = nullptr;
		other.rank = 0;
	}

	//copy and move assignment operator (not tested, see above)
	PSize& operator=(PSize other) {
		swap(other);
		return *this;
	}

	hsize_t& operator[] (const size_t index) {
		const PSize *this_const = const_cast<const PSize*>(this);
		return const_cast<hsize_t&>(this_const->operator[](index));
	}

	const hsize_t& operator[] (const size_t index) const {
		if (index > rank) {
			throw std::out_of_range ("Index out of bounds");
		}
		return dims[index];
	}

	void swap(PSize &other) {
		using std::swap;
		swap(dims, other.dims);
		rank = other.rank;
	}

	size_t size() const { return rank; }

	~PSize(){
		delete[] dims;
	}

	//we are modelling a boost::Collection
	iterator begin() { return dims; }
	iterator end() { return dims + rank; }
	const_iterator begin() const { return dims; }
	const_iterator end() const { return dims + rank; }
	bool empty() const { return rank == 0; }

private:
	void allocate() {
		if (rank > 0) {
			dims = new hsize_t[rank];
		}
	}

	size_t   rank;
	hsize_t *dims;
};

} //namespace pandroa
#endif // PANDORA_HSIZE_H
<commit_msg>PSize: change guards from HSIZE to PSIZE<commit_after>#ifndef PANDORA_PSIZE_H
#define PANDORA_PSIZE_H

#include <stdexcept>

namespace pandora {

class PSize {
public:
	typedef hsize_t        value_type;
	typedef hsize_t       *iterator;
	typedef const hsize_t *const_iterator;
	typedef hsize_t       &reference;
	typedef const hsize_t  const_reference;
	typedef hsize_t       *pointer;
	typedef size_t         difference_type;
	typedef size_t         size_type;

	PSize() : rank(0), dims(nullptr) { }

	explicit PSize(size_t _rank) : rank(_rank), dims(nullptr) {
		allocate();
	}

	//copy
	PSize(const PSize &other) : rank(other.rank), dims(nullptr) {
		allocate();
		std::copy(other.dims, other.dims + rank, dims);
	}

	//move (not tested due to: http://llvm.org/bugs/show_bug.cgi?id=12208)
	PSize(PSize &&other) : rank(other.rank), dims(other.dims) {
		other.dims = nullptr;
		other.rank = 0;
	}

	//copy and move assignment operator (not tested, see above)
	PSize& operator=(PSize other) {
		swap(other);
		return *this;
	}

	hsize_t& operator[] (const size_t index) {
		const PSize *this_const = const_cast<const PSize*>(this);
		return const_cast<hsize_t&>(this_const->operator[](index));
	}

	const hsize_t& operator[] (const size_t index) const {
		if (index > rank) {
			throw std::out_of_range ("Index out of bounds");
		}
		return dims[index];
	}

	void swap(PSize &other) {
		using std::swap;
		swap(dims, other.dims);
		rank = other.rank;
	}

	size_t size() const { return rank; }

	~PSize(){
		delete[] dims;
	}

	//we are modelling a boost::Collection
	iterator begin() { return dims; }
	iterator end() { return dims + rank; }
	const_iterator begin() const { return dims; }
	const_iterator end() const { return dims + rank; }
	bool empty() const { return rank == 0; }

private:
	void allocate() {
		if (rank > 0) {
			dims = new hsize_t[rank];
		}
	}

	size_t   rank;
	hsize_t *dims;
};

} //namespace pandroa
#endif // PANDORA_PSIZE_H

{'fraction_non_alphanumeric': 0.13393548387096774, 'fraction_numerical': 0.00464516129032258, 'mean_word_length': 3.7326007326007327, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '2455206', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1448, 'n_words': 368}