BCP_vector_sanity.cpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #include "BCP_error.hpp"
4 #include "BCP_vector.hpp"
5 
6 //#############################################################################
7 
10  const int maxsize)
11 {
12  if (firstpos == lastpos)
13  return;
14  if (*firstpos < 0)
15  throw BCP_fatal_error("Negative entry in a BCP_vec_sanity_check.\n");
16  if (*(lastpos - 1) >= maxsize)
17  throw BCP_fatal_error("Too big entry in a BCP_vec_sanity_check.\n");
18  int prev = -1;
19  while (firstpos != lastpos){
20  if (*firstpos < prev)
21  throw BCP_fatal_error
22  ("Entry list is not ordered in BCP_vec_sanity_check.\n");
23  if (*firstpos == prev)
24  throw BCP_fatal_error
25  ("Duplicate entry in BCP_vec_sanity_check.\n");
26  prev = *firstpos;
27  ++firstpos;
28  }
29 }
30 
void BCP_vec_sanity_check(BCP_vec< int >::const_iterator firstpos, BCP_vec< int >::const_iterator lastpos, const int maxsize)
A helper function to test whether a set positions is sane for a vector.
Currently there isn&#39;t any error handling in BCP.
Definition: BCP_error.hpp:20
The class BCP_vec serves the same purpose as the vector class in the standard template library...
Definition: BCP_vector.hpp:24