object_index.h

来自「CGAL is a collaborative effort of severa」· C头文件 代码 · 共 62 行

H
62
字号
// Copyright (c) 1997-2000  Max-Planck-Institute Saarbruecken (Germany).// All rights reserved.//// This file is part of CGAL (www.cgal.org); you may redistribute it under// the terms of the Q Public License version 1.0.// See the file LICENSE.QPL distributed with CGAL.//// Licensees holding a valid commercial license may use this file in// accordance with the commercial license agreement provided with the software.//// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.//// $Source: /CVSROOT/CGAL/Packages/Nef_2/include/CGAL/Nef_2/Object_index.h,v $// $Revision: 1.6 $ $Date: 2003/10/21 12:21:00 $// $Name:  $//// Author(s)     : Michael Seel <seel@mpi-sb.mpg.de>#ifndef OBJECT_INDEX_H#define OBJECT_INDEX_H#include <CGAL/basic.h>#include <CGAL/Unique_hash_map.h>#include <string>#include <sstream>CGAL_BEGIN_NAMESPACEtemplate <typename I>class Object_index {  char _prefix;  CGAL::Unique_hash_map<I,int> _index;public:  Object_index() : _prefix('\0'), _index(-1) {}  Object_index(I first, I beyond, char c=' ') : _prefix(c), _index(-1)  { for(int i=0 ; first!=beyond; ++i,++first) _index[first]=i; }  int operator[](const I& it) const { return _index[it]; }   int& operator[](const I& it) { return _index[it]; }   void index(I first, I beyond, char c=' ')  { _prefix=c;    for(int i=0 ; first!=beyond; ++i,++first) _index[first]=i;  }  std::string operator()(const I& it, bool verbose=true) const  { if (verbose && _index[it]==-1) return "nil";    if (verbose && _index[it]==-2) return "end";    std::ostringstream os;     if (verbose) os << _prefix;    os << _index[it];        return os.str();   }};CGAL_END_NAMESPACE#endif //OBJECT_INDEX_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?