<commit_before>/* 
 * File:   Buffer.h
 * Author: cjg
 *
 * Created on October 18, 2009, 1:16 PM
 */

#ifndef _BUFFER_H
#define	_BUFFER_H

#include <iostream>
#include <cstdlib>
#include <typeinfo>
#include <cstring>

#define BLOCK_SIZE  4096

using namespace std;

class Buffer {
public:
    Buffer(size_t initial_size = 0, size_t block_size = BLOCK_SIZE);
    Buffer(const Buffer& orig);
    Buffer(std::istream & in);
    Buffer(char * buffer, size_t buffer_size, size_t block_size = BLOCK_SIZE);
    virtual ~Buffer();

    template <class T> void Add(T item) {
        if ((mLength + (sizeof (T))) >= mSize) {
            mSize = ((mLength + (sizeof (T))) / mBlockSize + 1) * mBlockSize;
            if ((mpBuffer = (char *) realloc(mpBuffer, mSize)) == NULL)
                throw "Can't reallocate memory.";
        }
        memmove(mpBuffer + mLength, (char *) & item, sizeof (T));
        mLength += sizeof (T);
        mBackOffset = mLength;
    };

    template <class T> void Add(T *item, size_t n = 1) {<commit_msg>built for cuda 2.3<commit_after>/* 
 * File:   Buffer.h
 * Author: cjg
 *
 * Created on October 18, 2009, 1:16 PM
 */

#ifndef _BUFFER_H
#define	_BUFFER_H

#include <iostream>
#include <cstdlib>
#include <typeinfo>
#include <cstring>
#include <stdint.h>

#define BLOCK_SIZE  4096

using namespace std;

class Buffer {
public:
    Buffer(size_t initial_size = 0, size_t block_size = BLOCK_SIZE);
    Buffer(const Buffer& orig);
    Buffer(std::istream & in);
    Buffer(char * buffer, size_t buffer_size, size_t block_size = BLOCK_SIZE);
    virtual ~Buffer();

    template <class T> void Add(T item) {
        if ((mLength + (sizeof (T))) >= mSize) {
            mSize = ((mLength + (sizeof (T))) / mBlockSize + 1) * mBlockSize;
            if ((mpBuffer = (char *) realloc(mpBuffer, mSize)) == NULL)
                throw "Can't reallocate memory.";
        }
        memmove(mpBuffer + mLength, (char *) & item, sizeof (T));
        mLength += sizeof (T);
        mBackOffset = mLength;
    };

    template <class T> void Add(T *item, size_t n = 1) {
{'fraction_non_alphanumeric': 0.13778204512722037, 'fraction_numerical': 0.01632261161785886, 'mean_word_length': 2.87360594795539, 'pattern_counts': {'":': 0, '<': 16, '<?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': '6994806', 'n_tokens_mistral': 747, 'n_tokens_neox': 699, 'n_words': 207}