diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-12-15 22:21:54 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-12-15 22:21:54 +0000 |
commit | 75585b58076af057d1e458ea5668a97455d93688 (patch) | |
tree | dc8a802e6195054dc07a457fe8743f2326070755 /src/common/include/gudhi_patches/CGAL/internal/Static_or_dynamic_array.h | |
parent | b93ea27ea392f49f85deee23526c9330a716093b (diff) | |
parent | 0df3c9bcca4345b8be27ca2fd90eb5137072740c (diff) |
Merge last trunk modifications
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneck_integration@1888 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 951a081ac634f829fa49265005ea1e620f2c08ca
Diffstat (limited to 'src/common/include/gudhi_patches/CGAL/internal/Static_or_dynamic_array.h')
-rw-r--r-- | src/common/include/gudhi_patches/CGAL/internal/Static_or_dynamic_array.h | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/common/include/gudhi_patches/CGAL/internal/Static_or_dynamic_array.h b/src/common/include/gudhi_patches/CGAL/internal/Static_or_dynamic_array.h new file mode 100644 index 00000000..ee6195d9 --- /dev/null +++ b/src/common/include/gudhi_patches/CGAL/internal/Static_or_dynamic_array.h @@ -0,0 +1,116 @@ +// Copyright (c) 2009-2014 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// 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. +// +// $URL$ +// $Id$ +// +// Author(s) : Samuel Hornus + +#ifndef CGAL_INTERNAL_STATIC_OR_DYNAMIC_ARRAY_H +#define CGAL_INTERNAL_STATIC_OR_DYNAMIC_ARRAY_H + +#include <CGAL/Compact_container.h> +#include <CGAL/Dimension.h> +#include <CGAL/array.h> +#include <vector> + +namespace CGAL { + +namespace internal { + +// Utility for adding one to an Dimension_tag: + +template<typename D> +struct Dimen_plus_one; + +template<> +struct Dimen_plus_one<Dynamic_dimension_tag> +{ + typedef Dynamic_dimension_tag type; +}; + +template<int D> +struct Dimen_plus_one<Dimension_tag<D> > +{ + typedef Dimension_tag<D+1> type; +}; + +// A SMALL CONTAINER UTILITY FOR DYNAMIC/STATIC MEMORY MANAGEMENT + +// stores an array of static or dynamic size, depending on template parameter <B>. + +template< typename Containee, typename D, bool WithCompactContainerHelper = false> + struct S_or_D_array; // S = static, D = dynamic + +// The case of static size: +template< typename Containee, int D, bool WithCompactContainerHelper > +struct S_or_D_array< Containee, Dimension_tag< D >, WithCompactContainerHelper > +: public array<Containee, D> +{ + typedef array<Containee, D> Base; + S_or_D_array(const int) + : Base() + {} + S_or_D_array(const int, const Containee & c) + : Base() + { + assign(c); + } + void* for_compact_container() const + { + return (*this)[0].for_compact_container(); + } + void* & for_compact_container() + { + return (*this)[0].for_compact_container(); + } +}; + +// The case of dynamic size +template< typename Containee > +struct S_or_D_array< Containee, Dynamic_dimension_tag, false > +: public std::vector<Containee> +{ + typedef std::vector<Containee> Base; + // TODO: maybe we should use some "small-vector-optimized" class. + S_or_D_array(const int d) + : Base(d) + {} + S_or_D_array(const int d, const Containee & c) + : Base(d, c) + {} +}; + +// The case of dynamic size with for_compact_container +template< typename Containee > +struct S_or_D_array< Containee, Dynamic_dimension_tag, true > +: public std::vector<Containee> +{ + typedef std::vector<Containee> Base; + S_or_D_array(const int d) + : Base(d), fcc_(NULL) + {} + S_or_D_array(const int d, const Containee & c) + : Base(d, c), fcc_(NULL) + {} + void* fcc_; + void* for_compact_container() const { return fcc_; } + void* & for_compact_container() { return fcc_; } +}; + +} // end of namespace internal + +} // end of namespace CGAL + +#endif // CGAL_INTERNAL_STATIC_OR_DYNAMIC_ARRAY_H |