コード例 #1
0
InitialData::InitialData(const string& radius_file,
			 const string& density_file,
			 const string& temperature_file,
			 const string& velocity_file):
  radius_list(load_txt(radius_file)),
  radius_mid(mid_array(radius_list)),
  density_list(decapitate(load_txt(density_file))),
  temperature_list(decapitate(load_txt(temperature_file))),
  velocity_list(load_txt(velocity_file)),
  tracers_list(get_composition_data()) {}
コード例 #2
0
T LinkedList::removeAt(unsigned int const position) {
 if (head == nullptr || position > length()) throw std::exception();

  unsigned int count = 0;
  Node* current = head;
  while (current != nullptr) {
    // first position
    if (position == 0) {
      int value = head->value;
      decapitate();
      return value;
    }
    // last position
    else if (position == length()) {
      int value = tail->value;
      decaudate();
      return value;
    }
    // next item is our position
    else if (count+1 == position) {
      Node* temp = current->next;
      int value = temp->value;
      delete temp;
      current->next = current->next->next;
      return value;
    }
    else {
      current = current->next;
      ++count;
    }
  }
}
コード例 #3
0
map<string,vector<double> > get_composition_data(void)
{
  map<string,vector<double> > res;
  const map<string,pair<double,double> > atomic_properties = generate_atomic_properties();
  for(map<string,pair<double,double> >::const_iterator it =
	atomic_properties.begin();
      it != atomic_properties.end(); ++it)
    res[it->first] = decapitate(load_txt(string("tracer_")+it->first+".txt"));
  return res;
}
コード例 #4
0
ファイル: LinkedList.cpp プロジェクト: egross91/Fall2013
int LinkedList::decaudate()
{
	if (head == nullptr) // If empty().
		throw ("The list is empty!\n");
	else if (head->next == nullptr) // If only one item in the list.
		return decapitate();
	else // If there are several items in the list.
	{
		Node* here = head;
		while (here->next->next != nullptr) // Iterate through the LL until we're one before the end.
			here = here->next;

		int value = here->next->data;
		delete here->next;
		here->next = nullptr;
		return value;
	}
	// return head->decaudate();
}
コード例 #5
0
ファイル: LinkedList.cpp プロジェクト: egross91/Fall2013
int LinkedList::removeAt(unsigned int position)
{
	if (head == nullptr) // If it's empty().
		throw ("The list is empty!\n");
	else if (position == 0) // If we want to get rid of the first element.
		return decapitate();
	else
	{
		Node* here = head;
		while (position-- != 1) // Keeping going through the list until we're one from the end.
		{
			if (here->next->next == nullptr) // If we reach the end of the list before we reach the desired position.
				throw ("The position does not exist!\n");
			here = here->next;
		}
		Node* doomed = here->next;
		int value = doomed->data;
		here->next = doomed->next;
		delete doomed;
		return value;
	}
	// return head->removeAt(position);
}