2
// File: sort_QuickSort_Impl.cxx
3
// Symbol: sort.QuickSort-v0.1
5
// Babel Version: 1.2.0
6
// Description: Server-side implementation for sort.QuickSort
8
// WARNING: Automatically generated; only changes within splicers preserved
11
#include "sort_QuickSort_Impl.hxx"
14
// Includes for all method dependencies.
16
#ifndef included_sidl_BaseInterface_hxx
17
#include "sidl_BaseInterface.hxx"
19
#ifndef included_sidl_ClassInfo_hxx
20
#include "sidl_ClassInfo.hxx"
22
#ifndef included_sort_Comparator_hxx
23
#include "sort_Comparator.hxx"
25
#ifndef included_sort_Container_hxx
26
#include "sort_Container.hxx"
28
#ifndef included_sort_Counter_hxx
29
#include "sort_Counter.hxx"
31
#ifndef included_sidl_NotImplementedException_hxx
32
#include "sidl_NotImplementedException.hxx"
34
#line 35 "/home/epperly/current/release_1.2.0/linux_dist/../babel_branch/regression/sort/libCxx/sort_QuickSort_Impl.cxx"
35
// DO-NOT-DELETE splicer.begin(sort.QuickSort._includes)
37
* Choose the middle of the first, middle and last element of the
38
* list. For small lists, return the middle without checking.
41
choosePivot(::sort::Container &elems,
42
::sort::Comparator &comp,
47
int32_t pivot = (start + end) >> 1;
48
if ((end - start) > 4) {
51
if (elems.compare(start, mid, comp) <= 0) {
53
if (elems.compare(mid, end - 1, comp) > 0) {
55
if (elems.compare( start, end - 1, comp) < 0) {
65
if (elems.compare( mid, end - 1, comp) < 0) {
67
if (elems.compare( start, end - 1, comp) > 0) {
80
quickSort(::sort::Container &elems,
81
::sort::Comparator &comp,
87
if ((end - start) > 1) {
88
int32_t pivot = choosePivot(elems, comp, cmp, start, end);
93
elems.swap(start, pivot);
99
} while (elems.compare( start, j, comp) < 0);
102
if (elems.compare( start, i, comp) < 0) break;
110
elems.swap(start, j);
112
quickSort(elems, comp, cmp, swp, start, j);
113
quickSort(elems, comp, cmp, swp, j + 1, end);
116
// DO-NOT-DELETE splicer.end(sort.QuickSort._includes)
117
#line 117 "../regression/sort/libCxx/sort_QuickSort_Impl.cxx"
119
// special constructor, used for data wrapping(required). Do not put code here unless you really know what you're doing!
120
sort::QuickSort_impl::QuickSort_impl() : StubBase(reinterpret_cast< void*>(
121
::sort::QuickSort::_wrapObj(reinterpret_cast< void*>(this))),false) ,
123
#line 124 "/home/epperly/current/release_1.2.0/linux_dist/../babel_branch/regression/sort/libCxx/sort_QuickSort_Impl.cxx"
124
// DO-NOT-DELETE splicer.begin(sort.QuickSort._ctor2)
125
// Insert-Code-Here {sort.QuickSort._ctor2} (ctor2)
126
// DO-NOT-DELETE splicer.end(sort.QuickSort._ctor2)
127
#line 127 "../regression/sort/libCxx/sort_QuickSort_Impl.cxx"
130
// user defined constructor
131
void sort::QuickSort_impl::_ctor() {
132
#line 133 "/home/epperly/current/release_1.2.0/linux_dist/../babel_branch/regression/sort/libCxx/sort_QuickSort_Impl.cxx"
133
// DO-NOT-DELETE splicer.begin(sort.QuickSort._ctor)
134
// add construction details here
135
// DO-NOT-DELETE splicer.end(sort.QuickSort._ctor)
136
#line 136 "../regression/sort/libCxx/sort_QuickSort_Impl.cxx"
139
// user defined destructor
140
void sort::QuickSort_impl::_dtor() {
141
#line 142 "/home/epperly/current/release_1.2.0/linux_dist/../babel_branch/regression/sort/libCxx/sort_QuickSort_Impl.cxx"
142
// DO-NOT-DELETE splicer.begin(sort.QuickSort._dtor)
143
// add destruction details here
144
// DO-NOT-DELETE splicer.end(sort.QuickSort._dtor)
145
#line 145 "../regression/sort/libCxx/sort_QuickSort_Impl.cxx"
148
// static class initializer
149
void sort::QuickSort_impl::_load() {
150
#line 151 "/home/epperly/current/release_1.2.0/linux_dist/../babel_branch/regression/sort/libCxx/sort_QuickSort_Impl.cxx"
151
// DO-NOT-DELETE splicer.begin(sort.QuickSort._load)
152
// guaranteed to be called at most once before any other method in this class
153
// DO-NOT-DELETE splicer.end(sort.QuickSort._load)
154
#line 154 "../regression/sort/libCxx/sort_QuickSort_Impl.cxx"
157
// user defined static methods: (none)
159
// user defined non-static methods:
161
* Sort elements using Quick Sort.
164
sort::QuickSort_impl::sort_impl (
165
/* in */::sort::Container& elems,
166
/* in */::sort::Comparator& comp )
168
#line 169 "/home/epperly/current/release_1.2.0/linux_dist/../babel_branch/regression/sort/libCxx/sort_QuickSort_Impl.cxx"
169
// DO-NOT-DELETE splicer.begin(sort.QuickSort.sort)
170
const int32_t num = elems.getLength();
171
::sort::Counter cmp = getCompareCounter();
172
::sort::Counter swp = getSwapCounter();
173
quickSort(elems, comp, cmp, swp, 0, num);
174
// DO-NOT-DELETE splicer.end(sort.QuickSort.sort)
175
#line 175 "../regression/sort/libCxx/sort_QuickSort_Impl.cxx"
182
sort::QuickSort_impl::getName_impl ()
185
#line 186 "/home/epperly/current/release_1.2.0/linux_dist/../babel_branch/regression/sort/libCxx/sort_QuickSort_Impl.cxx"
186
// DO-NOT-DELETE splicer.begin(sort.QuickSort.getName)
188
// DO-NOT-DELETE splicer.end(sort.QuickSort.getName)
189
#line 189 "../regression/sort/libCxx/sort_QuickSort_Impl.cxx"
193
#line 194 "/home/epperly/current/release_1.2.0/linux_dist/../babel_branch/regression/sort/libCxx/sort_QuickSort_Impl.cxx"
194
// DO-NOT-DELETE splicer.begin(sort.QuickSort._misc)
195
// Put miscellaneous code here
196
// DO-NOT-DELETE splicer.end(sort.QuickSort._misc)
197
#line 197 "../regression/sort/libCxx/sort_QuickSort_Impl.cxx"