Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] View of /trunk/gadget/strstack.cc
[mareframe] / trunk / gadget / strstack.cc Repository:
ViewVC logotype

View of /trunk/gadget/strstack.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 20 - (download) (annotate)
Fri Apr 7 09:20:55 2017 UTC (7 years, 1 month ago) by agomez
File size: 826 byte(s)
OpenMP integrated in a single model and first version of PSO
#include "strstack.h"
#include "gadget.h"
#include "omp.h"

StrStack::~StrStack() {
  int i;
  for (i = 0; i < v.Size(); i++)
    delete[] v[i];
}

void StrStack::clearString() {
#pragma omp critical
  if (size > 0)
    size--;
}

void StrStack::storeString(const char* str) {
#pragma omp critical
{
  if (size == v.Size()) {
    v.resize(new char[MaxStrLength]);
    strncpy(v[size], "", MaxStrLength);
  }
  strcpy(v[size], str);
  size++;
}
}

char* StrStack::sendAll() const {
  int i, len;
  len = size * MaxStrLength;
  char* rstr = new char[len];
  strncpy(rstr, "", len);
  for (i = 0; i < size; i++)
    strcat(rstr, v[i]);

  return rstr;
}

char* StrStack::sendTop() const {
  char* rstr = new char[MaxStrLength];
  strncpy(rstr, "", MaxStrLength);
  if (size != 0)
    strcpy(rstr, v[size - 1]);

  return rstr;
}

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge