File: sort_IntegerContainer_Impl.cc

package info (click to toggle)
babel 0.10.2-1
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 43,932 kB
  • ctags: 29,707
  • sloc: java: 74,695; ansic: 73,142; cpp: 40,649; sh: 18,411; f90: 10,062; fortran: 6,727; python: 6,406; makefile: 3,866; xml: 118; perl: 48
file content (168 lines) | stat: -rw-r--r-- 5,288 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// 
// File:          sort_IntegerContainer_Impl.cc
// Symbol:        sort.IntegerContainer-v0.1
// Symbol Type:   class
// Babel Version: 0.10.2
// Description:   Server-side implementation for sort.IntegerContainer
// 
// WARNING: Automatically generated; only changes within splicers preserved
// 
// babel-version = 0.10.2
// 
#include "sort_IntegerContainer_Impl.hh"

#line 14 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
// DO-NOT-DELETE splicer.begin(sort.IntegerContainer._includes)
#include <sstream>
#include <iostream>
#include "synch_RegOut.hh"
// DO-NOT-DELETE splicer.end(sort.IntegerContainer._includes)
#line 20 "sort_IntegerContainer_Impl.cc"

// user-defined constructor.
void sort::IntegerContainer_impl::_ctor() {
#line 22 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer._ctor)
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer._ctor)
#line 27 "sort_IntegerContainer_Impl.cc"
}

// user-defined destructor.
void sort::IntegerContainer_impl::_dtor() {
#line 28 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer._dtor)
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer._dtor)
#line 35 "sort_IntegerContainer_Impl.cc"
}

// static class initializer.
void sort::IntegerContainer_impl::_load() {
#line 34 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer._load)
  // guaranteed to be called at most once before any other method in this class
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer._load)
#line 44 "sort_IntegerContainer_Impl.cc"
}

// user-defined static methods: (none)

// user-defined non-static methods:
/**
 * This sets the container length and pseudo-randomly orders the
 * Integer elements contained.
 */
void
sort::IntegerContainer_impl::setLength (
  /* in */ int32_t len ) 
throw () 
{
#line 51 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.setLength)
  int32_t i, j;
  d_elements = sidl::array<sort::Integer>::create1d(len);
  for(i = 0; i < len; ++i){
    sort::Integer intObj = sort::Integer::_create();
    intObj.setValue(i);
    d_elements.set(i, intObj);
  }
  for(i = len - 1; i > 0; --i) {
    j = random() % (i + 1);
    if (j != i) {
      self.swap(i, j);
    }
  }
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.setLength)
#line 75 "sort_IntegerContainer_Impl.cc"
}

/**
 * Return the number of elements in the container.
 */
int32_t
sort::IntegerContainer_impl::getLength ()
throw () 

{
#line 76 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.getLength)
  return 1 + d_elements.upper(0) - d_elements.lower(0);
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.getLength)
#line 90 "sort_IntegerContainer_Impl.cc"
}

/**
 * Return -1 if element i is less than element j, 0 if element i
 * is equal to element j, or otherwise 1.
 */
int32_t
sort::IntegerContainer_impl::compare (
  /* in */ int32_t i,
  /* in */ int32_t j,
  /* in */ ::sort::Comparator comp ) 
throw () 
{
#line 92 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.compare)
  sidl::BaseInterface i1(d_elements.get(i));
  sidl::BaseInterface i2(d_elements.get(j));
  return comp.compare(i1, i2);
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.compare)
#line 110 "sort_IntegerContainer_Impl.cc"
}

/**
 * Swap elements i and j.
 */
void
sort::IntegerContainer_impl::swap (
  /* in */ int32_t i,
  /* in */ int32_t j ) 
throw () 
{
#line 108 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.swap)
  const int32_t len = self.getLength();
  if (i >= 0 && j >= 0 && i < len && j < len) {
    sort::Integer 
      i1(d_elements.get(i)),
      i2(d_elements.get(j));
    d_elements.set(i, i2);
    d_elements.set(j, i1);
  }
  else {
    std::cerr << "sort::IntegerContainer::swap index out of bounds swap ("
	      << i << ", " << j << ") len (" << len << ")" << std::endl;
    synch::RegOut::getInstance().forceFailure();
  }
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.swap)
#line 138 "sort_IntegerContainer_Impl.cc"
}

/**
 * Print elements s through e-1
 */
void
sort::IntegerContainer_impl::output (
  /* in */ int32_t s,
  /* in */ int32_t e ) 
throw () 
{
#line 134 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
  // DO-NOT-DELETE splicer.begin(sort.IntegerContainer.output)
  std::ostringstream buf;
  buf << "list";
  while (s < e) {
    buf << ' ' << d_elements.get(s++).getValue();
  }
  synch::RegOut::getInstance().writeComment(buf.str());
  // DO-NOT-DELETE splicer.end(sort.IntegerContainer.output)
#line 159 "sort_IntegerContainer_Impl.cc"
}


#line 145 "../../../../babel/regression/sort/libCxx/sort_IntegerContainer_Impl.cc"
// DO-NOT-DELETE splicer.begin(sort.IntegerContainer._misc)
// Put miscellaneous code here
// DO-NOT-DELETE splicer.end(sort.IntegerContainer._misc)
#line 167 "sort_IntegerContainer_Impl.cc"