/home/coin/SVN-release/OS-2.0.0/Bcp/src/Member/BCP_vector_sanity.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2000, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #include "BCP_error.hpp"
00004 #include "BCP_vector.hpp"
00005 
00006 //#############################################################################
00007 
00008 void BCP_vec_sanity_check(BCP_vec<int>::const_iterator firstpos,
00009                           BCP_vec<int>::const_iterator lastpos,
00010                           const int maxsize)
00011 {
00012    if (firstpos == lastpos)
00013       return;
00014    if (*firstpos < 0)
00015       throw BCP_fatal_error("Negative entry in a BCP_vec_sanity_check.\n");
00016    if (*(lastpos - 1) >= maxsize)
00017       throw BCP_fatal_error("Too big entry in a BCP_vec_sanity_check.\n");
00018    int prev = -1;
00019    while (firstpos != lastpos){
00020       if (*firstpos < prev)
00021          throw BCP_fatal_error
00022             ("Entry list is not ordered in BCP_vec_sanity_check.\n");
00023       if (*firstpos == prev)
00024          throw BCP_fatal_error
00025             ("Duplicate entry in BCP_vec_sanity_check.\n");
00026       prev = *firstpos;
00027       ++firstpos;
00028    }
00029 }
00030 

Generated on Mon Aug 3 03:02:15 2009 by  doxygen 1.4.7