1 karl 1.6 //%2006////////////////////////////////////////////////////////////////////////
|
2 kumpf 1.1 //
|
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.;
|
6 karl 1.3 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.4 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.5 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.6 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 kumpf 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
33 //
|
34 kumpf 1.2 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
35 // (carolann_graves@hp.com)
|
36 kumpf 1.1 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
39 #ifndef Pegasus_ArrayInternal_h
40 #define Pegasus_ArrayInternal_h
41
42 #include <Pegasus/Common/Config.h>
43 #include <Pegasus/Common/Array.h>
|
44 kumpf 1.2 #include <Pegasus/Common/CIMName.h>
|
45 kumpf 1.1
46 PEGASUS_NAMESPACE_BEGIN
47
48 #include <Pegasus/Common/ArrayImpl.h>
49
50 template<class PEGASUS_ARRAY_T>
51 Boolean operator==(
52 const Array<PEGASUS_ARRAY_T>& x,
53 const Array<PEGASUS_ARRAY_T>& y)
54 {
55 if (x.size() != y.size())
56 return false;
57
58 for (Uint32 i = 0, n = x.size(); i < n; i++)
59 {
60 if (!(x[i] == y[i]))
61 return false;
62 }
63
64 return true;
65 }
66 kumpf 1.1
67 template<class PEGASUS_ARRAY_T>
68 Boolean Contains(const Array<PEGASUS_ARRAY_T>& a, const PEGASUS_ARRAY_T& x)
69 {
70 Uint32 n = a.size();
71
72 for (Uint32 i = 0; i < n; i++)
73 {
74 if (a[i] == x)
75 return true;
76 }
77
78 return false;
79 }
80
81 template<class PEGASUS_ARRAY_T>
82 void BubbleSort(Array<PEGASUS_ARRAY_T>& x)
83 {
84 Uint32 n = x.size();
85
86 if (n < 2)
87 kumpf 1.1 return;
88
89 for (Uint32 i = 0; i < n - 1; i++)
90 {
91 for (Uint32 j = 0; j < n - 1; j++)
92 {
93 if (x[j] > x[j+1])
94 {
95 PEGASUS_ARRAY_T t = x[j];
|
96 kumpf 1.2 x[j] = x[j+1];
97 x[j+1] = t;
98 }
99 }
100 }
101 }
102
103 inline void BubbleSort(Array<CIMName>& x)
104 {
105 Uint32 n = x.size();
106
107 if (n < 2)
108 return;
109
110 for (Uint32 i = 0; i < n - 1; i++)
111 {
112 for (Uint32 j = 0; j < n - 1; j++)
113 {
114 if (x[j].getString() > x[j+1].getString())
115 {
116 CIMName t = x[j];
117 kumpf 1.2 x[j] = x[j+1];
118 x[j+1] = t;
119 }
120 }
121 }
122 }
123
124 inline void BubbleSort(Array<CIMNamespaceName>& x)
125 {
126 Uint32 n = x.size();
127
128 if (n < 2)
129 return;
130
131 for (Uint32 i = 0; i < n - 1; i++)
132 {
133 for (Uint32 j = 0; j < n - 1; j++)
134 {
135 if (x[j].getString() > x[j+1].getString())
136 {
137 CIMNamespaceName t = x[j];
|
138 kumpf 1.1 x[j] = x[j+1];
139 x[j+1] = t;
140 }
141 }
142 }
143 }
144
145 #if 0
146 // Determine need for these functions
147 template<class PEGASUS_ARRAY_T>
148 void Unique(Array<PEGASUS_ARRAY_T>& x)
149 {
150 Array<PEGASUS_ARRAY_T> result;
151
152 for (Uint32 i = 0, n = x.size(); i < n; i++)
153 {
154 if (i == 0 || x[i] != x[i-1])
155 result.append(x[i]);
156 }
157
158 x.swap(result);
159 kumpf 1.1 }
160
161 template<class PEGASUS_ARRAY_T>
162 void Print(Array<PEGASUS_ARRAY_T>& x)
163 {
164 for (Uint32 i = 0, n = x.size(); i < n; i++)
165 PEGASUS_STD(cout) << x[i] << PEGASUS_STD(endl);
166 }
167 #endif
168
169 PEGASUS_NAMESPACE_END
170
171 #endif /* Pegasus_ArrayInternal_h */
|