--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+// $Id$
+// $MpId: AliMpArrayI.cxx,v 1.5 2006/05/24 13:58:29 ivana Exp $
+// Category: basic
+// ------------------------
+// Class AliMpArrayI
+// ------------------------
+// Helper class for sorted integer array
+// Author:Ivana Hrivnacova; IPN Orsay
+
+#include "AliMpArrayI.h"
+#include "AliMpIntPair.h"
+
+#include "AliLog.h"
+
+#include <TClass.h>
+#include <TString.h>
+#include <Riostream.h>
+
+#include <stdlib.h>
+
+/// \cond CLASSIMP
+ClassImp(AliMpArrayI)
+/// \endcond
+
+const Int_t AliMpArrayI::fgkDefaultSize = 100;
+
+//_____________________________________________________________________________
+AliMpArrayI::AliMpArrayI()
+ : TObject(),
+ fNofValues(0),
+ fValues(fgkDefaultSize)
+{
+/// Standard & default constructor
+
+}
+
+//_____________________________________________________________________________
+AliMpArrayI::AliMpArrayI(TRootIOCtor* /*ioCtor*/)
+ : TObject(),
+ fNofValues(),
+ fValues()
+{
+/// IO constructor
+}
+
+//_____________________________________________________________________________
+AliMpArrayI::~AliMpArrayI()
+{
+/// Destructor
+}
+
+//
+// private methods
+//
+
+//_____________________________________________________________________________
+Int_t AliMpArrayI::GetPosition(Int_t value) const
+{
+/// Return the new positon where the value should be put
+
+ for ( Int_t i=0; i<fNofValues; i++ ) {
+ if ( fValues.At(i) > value ) return i;
+ }
+
+ return fNofValues;
+}
+
+//
+// public methods
+//
+
+//_____________________________________________________________________________
+Bool_t AliMpArrayI::Add(Int_t value)
+{
+/// Add object with its key to the map and arrays
+
+ // Resize array if needed
+ if ( fValues.GetSize() == fNofValues ) {
+ fValues.Set(2*fValues.GetSize());
+ AliWarningStream() << "Resized array." << endl;
+ }
+
+ // Find the position for the new value
+ Int_t pos = GetPosition(value);
+
+ // Move elements
+ for ( Int_t i=fNofValues; i>=pos; i-- )
+ fValues.AddAt(fValues.At(i), i+1);
+
+ // Add the new value in freed space
+ fValues.AddAt(value, pos);
+ ++fNofValues;
+
+ return true;
+}
+
+//_____________________________________________________________________________
+Bool_t AliMpArrayI::Remove(Int_t value)
+{
+/// Add object with its key to the map and arrays
+
+ // Find the position for the new value
+ Int_t pos = GetPosition(value);
+
+ // Return if value is not present
+ if ( pos == fNofValues ) return false;
+
+ // Move elements
+ for ( Int_t i=pos; i<fNofValues-1; i++ )
+ fValues.AddAt(fValues.At(i+1), i);
+
+ // Decrement number of values
+ --fNofValues;
+
+ return true;
+}
+
+//_____________________________________________________________________________
+void AliMpArrayI::SetSize(Int_t size)
+{
+/// Set given size to the array
+
+ fValues.Set(size);
+}
+
+//_____________________________________________________________________________
+Int_t AliMpArrayI::GetSize() const
+{
+/// Return the map size
+
+ return fNofValues;
+}
+
+//_____________________________________________________________________________
+Int_t AliMpArrayI::GetValue(Int_t index) const
+{
+/// Return the index-th value
+
+ if ( index < 0 || index >= fNofValues ) {
+ AliErrorStream() << "Index outside limits" << endl;
+ return 0;
+ }
+
+ return fValues.At(index);
+}
+
+//_____________________________________________________________________________
+Bool_t AliMpArrayI::HasValue(Int_t value) const
+{
+/// Return true if contains the given value
+
+ if ( ! fNofValues ) return false;
+
+ if ( fValues.At(0) > value || fValues.At(fNofValues-1) < value )
+ return false;
+
+ for ( Int_t i=0; i<fNofValues; i++ )
+ if ( fValues.At(i) == value ) return true;
+
+ return false;
+}
+
--- /dev/null
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+// $Id$
+// $MpId: AliMpArrayI.h,v 1.4 2006/05/24 13:58:07 ivana Exp $
+
+/// \ingroup basic
+/// \class AliMpArrayI
+/// \brief Helper class for sorted integer array
+///
+/// \author Ivana Hrivnacova; IPN Orsay
+
+#ifndef ALI_MP_ARRAY_I_H
+#define ALI_MP_ARRAY_I_H
+
+#include <TObject.h>
+#include <TArrayI.h>
+
+class AliMpIntPair;
+
+class TString;
+
+class AliMpArrayI : public TObject
+{
+ public:
+ AliMpArrayI();
+ AliMpArrayI(TRootIOCtor* /*ioCtor*/);
+ virtual ~AliMpArrayI();
+
+ // methods
+ Bool_t Add(Int_t value);
+ Bool_t Remove(Int_t value);
+
+ // set methods
+ void SetSize(Int_t size);
+
+ // get methods
+ Int_t GetSize() const;
+ Int_t GetValue(Int_t index) const;
+ Bool_t HasValue(Int_t value) const;
+
+ private:
+ // methods
+ Int_t GetPosition(Int_t value) const;
+
+ // static data members
+ static const Int_t fgkDefaultSize; ///< Default initial size
+
+ // data members
+ Int_t fNofValues; ///< Number of values in the array
+ TArrayI fValues; ///< Array of values
+
+ ClassDef(AliMpArrayI,1) // Helper class for sorted integer array
+};
+
+#endif //ALI_MP_EX_MAP_H
+