ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
string5a.cpp
Go to the documentation of this file.
1 
8 #include <fvar.hpp>
9 #include <stdlib.h>
10 
12 {
13  return append_distinct(s);
14 }
15 
17 {
18  int tmp_min = 1;
19  int tmp_max = 1;
20  if (shape)
21  {
22  tmp_min=shape->indexmin();
23  tmp_max=shape->indexmax()+1;
24  delete shape;
25  shape = 0;
26  }
27  vector_shape* tmp_shape = new vector_shape(tmp_min,tmp_max);
28  if (!tmp_shape)
29  {
30  cerr << "Error allocating memory in adstring_array" << endl;
31  }
32  int size = tmp_max - tmp_min + 1;
33  adstring** tmp_ptr =
34  new adstring*[static_cast<unsigned int>(size < 0 ? 0 : size)];
35  if (!tmp_ptr)
36  {
37  cerr << "Error allocating memory in adstring_array +=" << endl;
38  }
39  tmp_ptr-=tmp_min;
40  for (int i=tmp_min;i<=tmp_max-1;i++)
41  {
42  tmp_ptr[i]=new adstring(*(ptr[i]));
43  }
44  tmp_ptr[tmp_max]=new adstring();
45  *tmp_ptr[tmp_max]=s;
46  if (ptr)
47  {
48  for (int i=tmp_min;i<=tmp_max-1;i++)
49  {
50  delete ptr[i];
51  ptr[i] = 0;
52  }
53  ptr+=tmp_min;
54  delete [] ptr;
55  ptr = 0;
56  }
57  ptr=tmp_ptr;
58  shape=tmp_shape;
59  adstring_array* tmp = (adstring_array*)this->next;
60  while (tmp != this)
61  {
62  if (tmp)
63  {
64  tmp->shape = shape;
65  tmp->ptr = ptr;
66  tmp = (adstring_array*)tmp->next;
67  }
68  }
69  return *this;
70 }
adstring ** ptr
Definition: adstring.hpp:201
Description not yet available.
Definition: fvar.hpp:509
adstring_array & operator+=(const adstring &s)
Definition: string5a.cpp:11
int indexmin() const
Definition: fvar.hpp:553
vector_shape * shape
Definition: adstring.hpp:200
prnstream & endl(prnstream &)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
adstring_array & append_distinct(const adstring &s)
Definition: string5a.cpp:16
int indexmax() const
Definition: fvar.hpp:557
int size() const
Definition: string5.cpp:65
clist * next
Definition: clist.h:48