3 karl 1.4 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
11 kumpf 1.1 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
18 //
19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
31 //
|
43 kumpf 1.1
44 PEGASUS_NAMESPACE_BEGIN
45
46 #include <Pegasus/Common/ArrayImpl.h>
47
48 template<class PEGASUS_ARRAY_T>
49 Boolean operator==(
50 const Array<PEGASUS_ARRAY_T>& x,
51 const Array<PEGASUS_ARRAY_T>& y)
52 {
53 if (x.size() != y.size())
54 return false;
55
56 for (Uint32 i = 0, n = x.size(); i < n; i++)
57 {
58 if (!(x[i] == y[i]))
59 return false;
60 }
61
62 return true;
63 }
64 kumpf 1.1
65 template<class PEGASUS_ARRAY_T>
66 Boolean Contains(const Array<PEGASUS_ARRAY_T>& a, const PEGASUS_ARRAY_T& x)
67 {
68 Uint32 n = a.size();
69
70 for (Uint32 i = 0; i < n; i++)
71 {
72 if (a[i] == x)
73 return true;
74 }
75
76 return false;
77 }
78
79 template<class PEGASUS_ARRAY_T>
80 void BubbleSort(Array<PEGASUS_ARRAY_T>& x)
81 {
82 Uint32 n = x.size();
83
84 if (n < 2)
85 kumpf 1.1 return;
86
87 for (Uint32 i = 0; i < n - 1; i++)
88 {
89 for (Uint32 j = 0; j < n - 1; j++)
90 {
91 if (x[j] > x[j+1])
92 {
93 PEGASUS_ARRAY_T t = x[j];
|
136 kumpf 1.1 x[j] = x[j+1];
137 x[j+1] = t;
138 }
139 }
140 }
141 }
142
143 #if 0
144 // Determine need for these functions
145 template<class PEGASUS_ARRAY_T>
146 void Unique(Array<PEGASUS_ARRAY_T>& x)
147 {
148 Array<PEGASUS_ARRAY_T> result;
149
150 for (Uint32 i = 0, n = x.size(); i < n; i++)
151 {
152 if (i == 0 || x[i] != x[i-1])
153 result.append(x[i]);
154 }
155
156 x.swap(result);
157 kumpf 1.1 }
158
159 template<class PEGASUS_ARRAY_T>
160 void Print(Array<PEGASUS_ARRAY_T>& x)
161 {
162 for (Uint32 i = 0, n = x.size(); i < n; i++)
163 PEGASUS_STD(cout) << x[i] << PEGASUS_STD(endl);
164 }
165 #endif
166
167 PEGASUS_NAMESPACE_END
168
169 #endif /* Pegasus_ArrayInternal_h */
|