1 kumpf 1.1 //%/////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 kumpf 1.1 //==============================================================================
23 //
24 // Author: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
25 //
26 // Modified By:
27 //
28 //%/////////////////////////////////////////////////////////////////////////////
29
30 #ifndef Pegasus_ArrayInternal_h
31 #define Pegasus_ArrayInternal_h
32
33 #include <Pegasus/Common/Config.h>
34 #include <Pegasus/Common/Array.h>
35
36 PEGASUS_NAMESPACE_BEGIN
37
38 #include <Pegasus/Common/ArrayImpl.h>
39
40 template<class PEGASUS_ARRAY_T>
41 Boolean operator==(
42 const Array<PEGASUS_ARRAY_T>& x,
43 kumpf 1.1 const Array<PEGASUS_ARRAY_T>& y)
44 {
45 if (x.size() != y.size())
46 return false;
47
48 for (Uint32 i = 0, n = x.size(); i < n; i++)
49 {
50 if (!(x[i] == y[i]))
51 return false;
52 }
53
54 return true;
55 }
56
57 template<class PEGASUS_ARRAY_T>
58 Boolean Contains(const Array<PEGASUS_ARRAY_T>& a, const PEGASUS_ARRAY_T& x)
59 {
60 Uint32 n = a.size();
61
62 for (Uint32 i = 0; i < n; i++)
63 {
64 kumpf 1.1 if (a[i] == x)
65 return true;
66 }
67
68 return false;
69 }
70
71 template<class PEGASUS_ARRAY_T>
72 void BubbleSort(Array<PEGASUS_ARRAY_T>& x)
73 {
74 Uint32 n = x.size();
75
76 if (n < 2)
77 return;
78
79 for (Uint32 i = 0; i < n - 1; i++)
80 {
81 for (Uint32 j = 0; j < n - 1; j++)
82 {
83 if (x[j] > x[j+1])
84 {
85 kumpf 1.1 PEGASUS_ARRAY_T t = x[j];
86 x[j] = x[j+1];
87 x[j+1] = t;
88 }
89 }
90 }
91 }
92
93 #if 0
94 // Determine need for these functions
95 template<class PEGASUS_ARRAY_T>
96 void Unique(Array<PEGASUS_ARRAY_T>& x)
97 {
98 Array<PEGASUS_ARRAY_T> result;
99
100 for (Uint32 i = 0, n = x.size(); i < n; i++)
101 {
102 if (i == 0 || x[i] != x[i-1])
103 result.append(x[i]);
104 }
105
106 kumpf 1.1 x.swap(result);
107 }
108
109 template<class PEGASUS_ARRAY_T>
110 void Print(Array<PEGASUS_ARRAY_T>& x)
111 {
112 for (Uint32 i = 0, n = x.size(); i < n; i++)
113 PEGASUS_STD(cout) << x[i] << PEGASUS_STD(endl);
114 }
115 #endif
116
117 PEGASUS_NAMESPACE_END
118
119 #endif /* Pegasus_ArrayInternal_h */
|