(file) Return to ArrayInternal.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 karl  1.5 //%2005////////////////////////////////////////////////////////////////////////
  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 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           //
 32 kumpf 1.2 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
 33           //                (carolann_graves@hp.com)
 34 kumpf 1.1 //
 35           //%/////////////////////////////////////////////////////////////////////////////
 36           
 37           #ifndef Pegasus_ArrayInternal_h
 38           #define Pegasus_ArrayInternal_h
 39           
 40           #include <Pegasus/Common/Config.h>
 41           #include <Pegasus/Common/Array.h>
 42 kumpf 1.2 #include <Pegasus/Common/CIMName.h>
 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];
 94 kumpf 1.2                 x[j] = x[j+1];
 95                           x[j+1] = t;
 96                       }
 97                   }
 98               }
 99           }
100           
101           inline void BubbleSort(Array<CIMName>& x) 
102           {
103               Uint32 n = x.size();
104           
105               if (n < 2)
106                   return;
107           
108               for (Uint32 i = 0; i < n - 1; i++)
109               {
110                   for (Uint32 j = 0; j < n - 1; j++)
111                   {
112                       if (x[j].getString() > x[j+1].getString())
113                       {
114                           CIMName t = x[j];
115 kumpf 1.2                 x[j] = x[j+1];
116                           x[j+1] = t;
117                       }
118                   }
119               }
120           }
121           
122           inline void BubbleSort(Array<CIMNamespaceName>& x) 
123           {
124               Uint32 n = x.size();
125           
126               if (n < 2)
127                   return;
128           
129               for (Uint32 i = 0; i < n - 1; i++)
130               {
131                   for (Uint32 j = 0; j < n - 1; j++)
132                   {
133                       if (x[j].getString() > x[j+1].getString())
134                       {
135                           CIMNamespaceName 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 */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2