neuron_group.cpp #include #include #include "neuron_group.h" #include "neuron.h" #include "connection.h" NeuronGroup::NeuronGroup() { index = -1; neurons.reserve(10); } NeuronGroup::NeuronGroup(unsigned int num_neurons) { index = -1; neurons.reserve(num_neurons); for (unsigned int i = 0; i < num_neurons; i++) { pNeuronX tmp(new Neuron()); tmp->setIndex(i); neurons.push_back(tmp); } } int NeuronGroup::getIndex(void) { return index; } void NeuronGroup::setIndex(const int& index) { this->index = index; } unsigned int NeuronGroup::getSize(void) { return neurons.size(); } void NeuronGroup::addNeuron(const pNeuronX& n) { neurons.push_back(n); } void NeuronGroup::removeNeuron(const int& idx) { assert(neurons.size() >= idx); for (unsigned i = neurons.size() - 1; i > 0; i--) { if (neurons[i]->getIndex() == idx) { neurons.erase(neurons.begin() + i); return; } } } pNeuronX &NeuronGroup::getNeuron(const int& idx) { assert(neurons.size() >= idx); return neurons[idx]; } void NeuronGroup::printOutput(void) { std::cout << "Layer " << index << " has " << neurons.size() << " Neurons" << std::endl; for (unsigned int i = 0; i