Generated on: Thu Mar 29 07:46:58 PDT 2012 for custom file set
// doxy/ or-tools/ src/ util/

operations_research::ConstIntArray Class Reference

This class is used to store constant copies of int64 arrays. More...

#include <const_int_array.h>

List of all members.

Public Types

enum  Property {
  IS_CONSTANT = 0, IS_STRICTLY_INCREASING = 1, IS_INCREASING = 2, IS_STRICTLY_DECREASING = 3,
  IS_DECREASING = 4, IS_BOOLEAN = 5, IS_POSITIVE = 6, IS_NEGATIVE = 7,
  IS_POSITIVE_OR_NULL = 8, IS_NEGATIVE_OR_NULL = 9, NUM_PROPERTY = 10
}
 These describe static properties of the int64 array. More...

Public Member Functions

 ConstIntArray (const std::vector< int64 > &data)
 Build from a vector. Copy the data internally.
 ConstIntArray (const std::vector< int > &data)
 Build from a vector. Copy the data internally.
 ConstIntArray (const int64 *const data, int size)
 Build from a C array. Copy the data internally.
 ConstIntArray (const int *const data, int size)
 Build from a C array. Copy the data internally.
 ConstIntArray (std::vector< int64 > *data)
 Build from a pointer to a vector (usually created by the Release(), or SortedCopy() method).
 ~ConstIntArray ()
string DebugString () const
 Pretty print.
std::vector< int64 > * Release ()
 This code release the ownership of the data into the returned vector.
std::vector< int64 > * Copy () const
 This will create a copy of the data.
std::vector< int64 > * SortedCopy (bool increasing) const
 This will create a new data holder with the sorted array.
std::vector< int64 > * SortedCopyWithoutDuplicates (bool increasing) const
 This will create a new data holder with the sorted array where the duplicate values have been removed.
bool Equals (const ConstIntArray &other) const
 Equality test.
int size () const
 Size of the array. This is not valid after Release() has been called.
int64 operator[] (int64 index) const
 Operator to access the data at the given index.
int64 get (int64 index) const
 Accessor to value in the array.
const int64 * RawData () const
 Access to const raw data.
bool HasProperty (Property info)
 Check the status of a given info bit.


Detailed Description

This class is used to store constant copies of int64 arrays.

These copies are used inside constraints or expressions. When constructed with a C array or a vector, The const int array will make a internal copy and own that copy. It will not take ownership of the vector/array which can be deleted afterwards. This follows the semantics of constraints and expressions which store a read-only copy of the data.

Its goals are:

As const int arrays provide scanning capabilities, the code inside a constraint and its factory looks like:

IntExpr* MakeMyExpr(const std::vector<int64>& values) { ConstIntArray copy(values); if (copy.Status(ConstIntArray::IS_INCREASING)) { return new MyOptimizedExpr(copy.Release()); } else { return new MyGenericExpr(copy.Release()); } }

With: class MyOptimizedExpr : IntExpr { public: MyOptimizedExpr(std::vector<int64>* data) : values_(data) {} private: ConstIntArray values_; };

Definition at line 62 of file const_int_array.h.


Member Enumeration Documentation

These describe static properties of the int64 array.

Enumerator:
IS_CONSTANT 
IS_STRICTLY_INCREASING 
IS_INCREASING 
IS_STRICTLY_DECREASING 
IS_DECREASING 
IS_BOOLEAN  in {0, 1}
IS_POSITIVE  > 0
IS_NEGATIVE  < 0
IS_POSITIVE_OR_NULL  >= 0
IS_NEGATIVE_OR_NULL  <= 0
NUM_PROPERTY  Sentinel.

Definition at line 65 of file const_int_array.h.


Constructor & Destructor Documentation

operations_research::ConstIntArray::ConstIntArray ( const std::vector< int64 > &  data  )  [explicit]

Build from a vector. Copy the data internally.

Definition at line 22 of file const_int_array.cc.

operations_research::ConstIntArray::ConstIntArray ( const std::vector< int > &  data  )  [explicit]

Build from a vector. Copy the data internally.

Definition at line 27 of file const_int_array.cc.

operations_research::ConstIntArray::ConstIntArray ( const int64 *const   data,
int  size 
)

Build from a C array. Copy the data internally.

Definition at line 36 of file const_int_array.cc.

operations_research::ConstIntArray::ConstIntArray ( const int *const   data,
int  size 
)

Build from a C array. Copy the data internally.

Definition at line 43 of file const_int_array.cc.

operations_research::ConstIntArray::ConstIntArray ( std::vector< int64 > *  data  )  [explicit]

Build from a pointer to a vector (usually created by the Release(), or SortedCopy() method).

This call will take ownership of the data and not make a copy.

Definition at line 52 of file const_int_array.cc.

operations_research::ConstIntArray::~ConstIntArray (  ) 

Definition at line 57 of file const_int_array.cc.


Member Function Documentation

string operations_research::ConstIntArray::DebugString (  )  const

Pretty print.

Definition at line 174 of file const_int_array.cc.

std::vector< int64 > * operations_research::ConstIntArray::Release (  ) 

This code release the ownership of the data into the returned vector.

After this method is called, data_ points to a null vector.

Definition at line 59 of file const_int_array.cc.

std::vector< int64 > * operations_research::ConstIntArray::Copy (  )  const

This will create a copy of the data.

Definition at line 78 of file const_int_array.cc.

std::vector< int64 > * operations_research::ConstIntArray::SortedCopy ( bool  increasing  )  const

This will create a new data holder with the sorted array.

Definition at line 68 of file const_int_array.cc.

std::vector< int64 > * operations_research::ConstIntArray::SortedCopyWithoutDuplicates ( bool  increasing  )  const

This will create a new data holder with the sorted array where the duplicate values have been removed.

Definition at line 83 of file const_int_array.cc.

bool operations_research::ConstIntArray::Equals ( const ConstIntArray other  )  const

Equality test.

Definition at line 112 of file const_int_array.cc.

int operations_research::ConstIntArray::size (  )  const

Size of the array. This is not valid after Release() has been called.

Definition at line 63 of file const_int_array.cc.

int64 operations_research::ConstIntArray::operator[] ( int64  index  )  const [inline]

Operator to access the data at the given index.

This is not valid after a release.

Definition at line 119 of file const_int_array.h.

int64 operations_research::ConstIntArray::get ( int64  index  )  const [inline]

Accessor to value in the array.

Definition at line 125 of file const_int_array.h.

const int64* operations_research::ConstIntArray::RawData (  )  const [inline]

Access to const raw data.

Todo:
TODO(user) : deprecate API.

Definition at line 132 of file const_int_array.h.

bool operations_research::ConstIntArray::HasProperty ( Property  info  ) 

Check the status of a given info bit.

It will scan the array on demand. This is not valid after Release() has been called.

Definition at line 124 of file const_int_array.cc.


The documentation for this class was generated from the following files: