<commit_before>//
//  ex12_02.cpp
//  Exercise 12.2
//
//  Created by pezy on 12/22/14.
//  Copyright (c) 2014 pezy. All rights reserved.
//
//  Write your own version of the StrBlob class including the const versions of
//  front and back.

#include <vector>
#include <string>
#include <initializer_list>
#include <memory>
#include <exception>

using std::vector;
using std::string;

class StrBlob {
public:
    using size_type = vector<string>::size_type;

    StrBlob() : data(std::make_shared<vector<string>>()) {}
    StrBlob(std::initializer_list<string> il)
        : data(std::make_shared<vector<string>>(il))
    {
    }

    size_type size() const { return data->size(); }
    bool empty() const { return data->empty(); }

    void push_back(const string& t) { data->push_back(t); }
    void pop_back()
    {
        check(0, "pop_back on empty StrBlob");
        data->pop_back();
    }

    std::string& front()
    {
        check(0, "front on empty StrBlob");
        return data->front();
    }

    std::string& back()
    {
        check(0, "back on empty StrBlob");
        return data->back();
    }

    const std::string& front() const
    {
        check(0, "front on empty StrBlob");
        return data->front();
    }
    const std::string& back() const
    {
        check(0, "back on empty StrBlob");
        return data->back();
    }

private:
    void check(size_type i, const string& msg) const
    {
        if (i >= data->size()) throw std::out_of_range(msg);
    }

private:
    std::shared_ptr<vector<string>> data;
};<commit_msg>Update ex12_02.h<commit_after>//
//  ex12_02.h
//  Exercise 12.2
//
//  Created by pezy on 12/22/14.
//  Copyright (c) 2014 pezy. All rights reserved.
//
//  Write your own version of the StrBlob class including the const versions of
//  front and back.

#include <string>
#include <vector>
#include <exception>
#include <memory>
#include <initializer_list>

using namespace std;

class StrBlob {
public:
     typedef vector<string>::size_type size_type;

     StrBlob();
     StrBlob(initializer_list<string> il);

     size_type size() const {return data-> size();}
     bool empty() const {return data->empty();}

     void push_back(const string &t) {data->push_back(t);}
     void pop_back();

     string &front();
     const string &front() const;
     string &back();
     const string &back() const;
private:
     shared_ptr<vector<string>> data;

     void check(size_type i, const string &msg) const;
};

StrBlob::StrBlob():data(make_shared<vector<string>>()) {}
StrBlob::StrBlob(initializer_list<string> il):data(make_shared<vector<string>>(il)) {}

void StrBlob::check(size_type i, const string &msg) const
{
    if(i>=data->size())
        throw out_of_range(msg);
}

string &StrBlob::front()
{
    check(0, "front on empty StrBlob");
    return data->front();
}

const string &StrBlob::front() const
{
    check(0, "front on empty StrBlob");
    return data->front();
}

string &StrBlob::back()
{
    check(0, "back on empty StrBlob");
    return data->back();
}

const string &StrBlob::back() const
{
    check(0, "back on empty StrBlob");
    return data->back();
}

void StrBlob::pop_back()
{
    check(0, "pop_back on empty StrBlob");
    data->pop_back();
}

#include <string>
#include <vector>
#include <exception>
#include <memory>
#include <initializer_list>

using namespace std;

class StrBlob {
public:
    using size_type = vector<string>::size_type;

    StrBlob():data(make_shared<vector<string>>()) {}
    StrBlob(initializer_list<string> il):data(make_shared<vector<string>>(il)) {}

    size_type size() const { return data->size(); }
    bool empty() const { return data->empty(); }

    void push_back(const string &t) { data->push_back(t); }
    void pop_back()
    {
        check(0, "pop_back on empty StrBlob");
        data->pop_back();
    }

    string &front()
    {
        check(0, "front on empty StrBlob");
        return data->front();
    }

    string &back()
    {
        check(0, "back on empty StrBlob");
        return data->back();
    }

    const string &front() const
    {
        check(0, "front on empty StrBlob");
        return data->front();
    }
    const string &back() const
    {
        check(0, "back on empty StrBlob");
        return data->back();
    }

private:
    void check(size_type i, const string &msg) const
    {
        if (i >= data->size())
            throw out_of_range(msg);
    }

    shared_ptr<vector<string>> data;
};
{'fraction_non_alphanumeric': 0.15329608938547487, 'fraction_numerical': 0.011843575418994414, 'mean_word_length': 2.98220640569395, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 73, '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': '4248722', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1454, 'n_words': 392}