| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/checkvec.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002  TerraLib - a library for developing GIS applications.
    00003 Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00023
    00024 // include/checkvec : vector class with checked limits
    00025 #ifndef CHECKVEC_H
    00026 #define CHECKVEC_H
    00027 #include<cassert>
    00028 #include<vector>
    00029
    00030 namespace br_stl
    00031 {
    00032            template<class T>
    00033            class checkedVector : public std::vector<T>
    00034            {
    00035            public:
    00036                       // inherited types
    00037                       typedef typename checkedVector::size_type size_type;
    00038                       typedef typename checkedVector::iterator iterator;
    00039                       typedef typename checkedVector::difference_type difference_type;
    00040                       typedef typename checkedVector::reference reference;
    00041                       typedef typename checkedVector::const_reference const_reference;
    00042
    00043                       checkedVector() {
    00044                       }
    00045
    00046                       checkedVector(size_type n, const T& value = T())
    00047                       : std::vector<T>(n, value) {
    00048                       }
    00049
    00050            //           checkedVector(iterator i, iterator j)
    00051            //      : std::vector<T>(i, j) {}
    00052
    00053                       reference operator[](difference_type index) {
    00054                                  assert(index >=0
    00055                                             && index < static_cast<difference_type>(this->size()));
    00056                                  return std::vector<T>::operator[](index);
    00057                       }
    00058
    00059
    00060                                  const_reference operator[](difference_type index) const {
    00061                                  assert(index >=0
    00062                                             && index < static_cast<difference_type>(this->size()));
    00063                                  return std::vector<T>::operator[](index);
    00064                       }
    00065
    00066            };
    00067 }
    00068
    00069
    00070 #endif
    00071

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines