openbox lab initialized
This commit is contained in:
603
openflow/usr/include/c++/5/ext/algorithm
Normal file
603
openflow/usr/include/c++/5/ext/algorithm
Normal file
@@ -0,0 +1,603 @@
|
||||
// Algorithm extensions -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Hewlett-Packard Company makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1996
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/** @file ext/algorithm
|
||||
* This file is a GNU extension to the Standard C++ Library (possibly
|
||||
* containing extensions from the HP/SGI STL subset).
|
||||
*/
|
||||
|
||||
#ifndef _EXT_ALGORITHM
|
||||
#define _EXT_ALGORITHM 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::ptrdiff_t;
|
||||
using std::min;
|
||||
using std::pair;
|
||||
using std::input_iterator_tag;
|
||||
using std::random_access_iterator_tag;
|
||||
using std::iterator_traits;
|
||||
|
||||
//--------------------------------------------------
|
||||
// copy_n (not part of the C++ standard)
|
||||
|
||||
template<typename _InputIterator, typename _Size, typename _OutputIterator>
|
||||
pair<_InputIterator, _OutputIterator>
|
||||
__copy_n(_InputIterator __first, _Size __count,
|
||||
_OutputIterator __result,
|
||||
input_iterator_tag)
|
||||
{
|
||||
for ( ; __count > 0; --__count)
|
||||
{
|
||||
*__result = *__first;
|
||||
++__first;
|
||||
++__result;
|
||||
}
|
||||
return pair<_InputIterator, _OutputIterator>(__first, __result);
|
||||
}
|
||||
|
||||
template<typename _RAIterator, typename _Size, typename _OutputIterator>
|
||||
inline pair<_RAIterator, _OutputIterator>
|
||||
__copy_n(_RAIterator __first, _Size __count,
|
||||
_OutputIterator __result,
|
||||
random_access_iterator_tag)
|
||||
{
|
||||
_RAIterator __last = __first + __count;
|
||||
return pair<_RAIterator, _OutputIterator>(__last, std::copy(__first,
|
||||
__last,
|
||||
__result));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copies the range [first,first+count) into [result,result+count).
|
||||
* @param __first An input iterator.
|
||||
* @param __count The number of elements to copy.
|
||||
* @param __result An output iterator.
|
||||
* @return A std::pair composed of first+count and result+count.
|
||||
*
|
||||
* This is an SGI extension.
|
||||
* This inline function will boil down to a call to @c memmove whenever
|
||||
* possible. Failing that, if random access iterators are passed, then the
|
||||
* loop count will be known (and therefore a candidate for compiler
|
||||
* optimizations such as unrolling).
|
||||
* @ingroup SGIextensions
|
||||
*/
|
||||
template<typename _InputIterator, typename _Size, typename _OutputIterator>
|
||||
inline pair<_InputIterator, _OutputIterator>
|
||||
copy_n(_InputIterator __first, _Size __count, _OutputIterator __result)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
|
||||
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
|
||||
typename iterator_traits<_InputIterator>::value_type>)
|
||||
|
||||
return __gnu_cxx::__copy_n(__first, __count, __result,
|
||||
std::__iterator_category(__first));
|
||||
}
|
||||
|
||||
template<typename _InputIterator1, typename _InputIterator2>
|
||||
int
|
||||
__lexicographical_compare_3way(_InputIterator1 __first1,
|
||||
_InputIterator1 __last1,
|
||||
_InputIterator2 __first2,
|
||||
_InputIterator2 __last2)
|
||||
{
|
||||
while (__first1 != __last1 && __first2 != __last2)
|
||||
{
|
||||
if (*__first1 < *__first2)
|
||||
return -1;
|
||||
if (*__first2 < *__first1)
|
||||
return 1;
|
||||
++__first1;
|
||||
++__first2;
|
||||
}
|
||||
if (__first2 == __last2)
|
||||
return !(__first1 == __last1);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline int
|
||||
__lexicographical_compare_3way(const unsigned char* __first1,
|
||||
const unsigned char* __last1,
|
||||
const unsigned char* __first2,
|
||||
const unsigned char* __last2)
|
||||
{
|
||||
const ptrdiff_t __len1 = __last1 - __first1;
|
||||
const ptrdiff_t __len2 = __last2 - __first2;
|
||||
const int __result = __builtin_memcmp(__first1, __first2,
|
||||
min(__len1, __len2));
|
||||
return __result != 0 ? __result
|
||||
: (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
|
||||
}
|
||||
|
||||
inline int
|
||||
__lexicographical_compare_3way(const char* __first1, const char* __last1,
|
||||
const char* __first2, const char* __last2)
|
||||
{
|
||||
#if CHAR_MAX == SCHAR_MAX
|
||||
return __lexicographical_compare_3way((const signed char*) __first1,
|
||||
(const signed char*) __last1,
|
||||
(const signed char*) __first2,
|
||||
(const signed char*) __last2);
|
||||
#else
|
||||
return __lexicographical_compare_3way((const unsigned char*) __first1,
|
||||
(const unsigned char*) __last1,
|
||||
(const unsigned char*) __first2,
|
||||
(const unsigned char*) __last2);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief @c memcmp on steroids.
|
||||
* @param __first1 An input iterator.
|
||||
* @param __last1 An input iterator.
|
||||
* @param __first2 An input iterator.
|
||||
* @param __last2 An input iterator.
|
||||
* @return An int, as with @c memcmp.
|
||||
*
|
||||
* The return value will be less than zero if the first range is
|
||||
* <em>lexigraphically less than</em> the second, greater than zero
|
||||
* if the second range is <em>lexigraphically less than</em> the
|
||||
* first, and zero otherwise.
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
*/
|
||||
template<typename _InputIterator1, typename _InputIterator2>
|
||||
int
|
||||
lexicographical_compare_3way(_InputIterator1 __first1,
|
||||
_InputIterator1 __last1,
|
||||
_InputIterator2 __first2,
|
||||
_InputIterator2 __last2)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<
|
||||
typename iterator_traits<_InputIterator1>::value_type>)
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<
|
||||
typename iterator_traits<_InputIterator2>::value_type>)
|
||||
__glibcxx_requires_valid_range(__first1, __last1);
|
||||
__glibcxx_requires_valid_range(__first2, __last2);
|
||||
|
||||
return __lexicographical_compare_3way(__first1, __last1, __first2,
|
||||
__last2);
|
||||
}
|
||||
|
||||
// count and count_if: this version, whose return type is void, was present
|
||||
// in the HP STL, and is retained as an extension for backward compatibility.
|
||||
template<typename _InputIterator, typename _Tp, typename _Size>
|
||||
void
|
||||
count(_InputIterator __first, _InputIterator __last,
|
||||
const _Tp& __value,
|
||||
_Size& __n)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
|
||||
__glibcxx_function_requires(_EqualityComparableConcept<
|
||||
typename iterator_traits<_InputIterator>::value_type >)
|
||||
__glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
for ( ; __first != __last; ++__first)
|
||||
if (*__first == __value)
|
||||
++__n;
|
||||
}
|
||||
|
||||
template<typename _InputIterator, typename _Predicate, typename _Size>
|
||||
void
|
||||
count_if(_InputIterator __first, _InputIterator __last,
|
||||
_Predicate __pred,
|
||||
_Size& __n)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
|
||||
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
|
||||
typename iterator_traits<_InputIterator>::value_type>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
for ( ; __first != __last; ++__first)
|
||||
if (__pred(*__first))
|
||||
++__n;
|
||||
}
|
||||
|
||||
// random_sample and random_sample_n (extensions, not part of the standard).
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _ForwardIterator, typename _OutputIterator,
|
||||
typename _Distance>
|
||||
_OutputIterator
|
||||
random_sample_n(_ForwardIterator __first, _ForwardIterator __last,
|
||||
_OutputIterator __out, const _Distance __n)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
|
||||
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
|
||||
typename iterator_traits<_ForwardIterator>::value_type>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
_Distance __remaining = std::distance(__first, __last);
|
||||
_Distance __m = min(__n, __remaining);
|
||||
|
||||
while (__m > 0)
|
||||
{
|
||||
if ((std::rand() % __remaining) < __m)
|
||||
{
|
||||
*__out = *__first;
|
||||
++__out;
|
||||
--__m;
|
||||
}
|
||||
--__remaining;
|
||||
++__first;
|
||||
}
|
||||
return __out;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _ForwardIterator, typename _OutputIterator,
|
||||
typename _Distance, typename _RandomNumberGenerator>
|
||||
_OutputIterator
|
||||
random_sample_n(_ForwardIterator __first, _ForwardIterator __last,
|
||||
_OutputIterator __out, const _Distance __n,
|
||||
_RandomNumberGenerator& __rand)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
|
||||
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
|
||||
typename iterator_traits<_ForwardIterator>::value_type>)
|
||||
__glibcxx_function_requires(_UnaryFunctionConcept<
|
||||
_RandomNumberGenerator, _Distance, _Distance>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
_Distance __remaining = std::distance(__first, __last);
|
||||
_Distance __m = min(__n, __remaining);
|
||||
|
||||
while (__m > 0)
|
||||
{
|
||||
if (__rand(__remaining) < __m)
|
||||
{
|
||||
*__out = *__first;
|
||||
++__out;
|
||||
--__m;
|
||||
}
|
||||
--__remaining;
|
||||
++__first;
|
||||
}
|
||||
return __out;
|
||||
}
|
||||
|
||||
template<typename _InputIterator, typename _RandomAccessIterator,
|
||||
typename _Distance>
|
||||
_RandomAccessIterator
|
||||
__random_sample(_InputIterator __first, _InputIterator __last,
|
||||
_RandomAccessIterator __out,
|
||||
const _Distance __n)
|
||||
{
|
||||
_Distance __m = 0;
|
||||
_Distance __t = __n;
|
||||
for ( ; __first != __last && __m < __n; ++__m, ++__first)
|
||||
__out[__m] = *__first;
|
||||
|
||||
while (__first != __last)
|
||||
{
|
||||
++__t;
|
||||
_Distance __M = std::rand() % (__t);
|
||||
if (__M < __n)
|
||||
__out[__M] = *__first;
|
||||
++__first;
|
||||
}
|
||||
return __out + __m;
|
||||
}
|
||||
|
||||
template<typename _InputIterator, typename _RandomAccessIterator,
|
||||
typename _RandomNumberGenerator, typename _Distance>
|
||||
_RandomAccessIterator
|
||||
__random_sample(_InputIterator __first, _InputIterator __last,
|
||||
_RandomAccessIterator __out,
|
||||
_RandomNumberGenerator& __rand,
|
||||
const _Distance __n)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_UnaryFunctionConcept<
|
||||
_RandomNumberGenerator, _Distance, _Distance>)
|
||||
|
||||
_Distance __m = 0;
|
||||
_Distance __t = __n;
|
||||
for ( ; __first != __last && __m < __n; ++__m, ++__first)
|
||||
__out[__m] = *__first;
|
||||
|
||||
while (__first != __last)
|
||||
{
|
||||
++__t;
|
||||
_Distance __M = __rand(__t);
|
||||
if (__M < __n)
|
||||
__out[__M] = *__first;
|
||||
++__first;
|
||||
}
|
||||
return __out + __m;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _InputIterator, typename _RandomAccessIterator>
|
||||
inline _RandomAccessIterator
|
||||
random_sample(_InputIterator __first, _InputIterator __last,
|
||||
_RandomAccessIterator __out_first,
|
||||
_RandomAccessIterator __out_last)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
|
||||
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
__glibcxx_requires_valid_range(__out_first, __out_last);
|
||||
|
||||
return __random_sample(__first, __last,
|
||||
__out_first, __out_last - __out_first);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _InputIterator, typename _RandomAccessIterator,
|
||||
typename _RandomNumberGenerator>
|
||||
inline _RandomAccessIterator
|
||||
random_sample(_InputIterator __first, _InputIterator __last,
|
||||
_RandomAccessIterator __out_first,
|
||||
_RandomAccessIterator __out_last,
|
||||
_RandomNumberGenerator& __rand)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
|
||||
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
__glibcxx_requires_valid_range(__out_first, __out_last);
|
||||
|
||||
return __random_sample(__first, __last,
|
||||
__out_first, __rand,
|
||||
__out_last - __out_first);
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
using std::is_heap;
|
||||
#else
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _RandomAccessIterator>
|
||||
inline bool
|
||||
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>)
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<
|
||||
typename iterator_traits<_RandomAccessIterator>::value_type>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
return std::__is_heap(__first, __last - __first);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _RandomAccessIterator, typename _StrictWeakOrdering>
|
||||
inline bool
|
||||
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_StrictWeakOrdering __comp)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>)
|
||||
__glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
|
||||
typename iterator_traits<_RandomAccessIterator>::value_type,
|
||||
typename iterator_traits<_RandomAccessIterator>::value_type>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
return std::__is_heap(__first, __comp, __last - __first);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
using std::is_sorted;
|
||||
#else
|
||||
// is_sorted, a predicated testing whether a range is sorted in
|
||||
// nondescending order. This is an extension, not part of the C++
|
||||
// standard.
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _ForwardIterator>
|
||||
bool
|
||||
is_sorted(_ForwardIterator __first, _ForwardIterator __last)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<
|
||||
typename iterator_traits<_ForwardIterator>::value_type>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
if (__first == __last)
|
||||
return true;
|
||||
|
||||
_ForwardIterator __next = __first;
|
||||
for (++__next; __next != __last; __first = __next, ++__next)
|
||||
if (*__next < *__first)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _ForwardIterator, typename _StrictWeakOrdering>
|
||||
bool
|
||||
is_sorted(_ForwardIterator __first, _ForwardIterator __last,
|
||||
_StrictWeakOrdering __comp)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
|
||||
__glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
|
||||
typename iterator_traits<_ForwardIterator>::value_type,
|
||||
typename iterator_traits<_ForwardIterator>::value_type>)
|
||||
__glibcxx_requires_valid_range(__first, __last);
|
||||
|
||||
if (__first == __last)
|
||||
return true;
|
||||
|
||||
_ForwardIterator __next = __first;
|
||||
for (++__next; __next != __last; __first = __next, ++__next)
|
||||
if (__comp(*__next, *__first))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#endif // C++11
|
||||
|
||||
/**
|
||||
* @brief Find the median of three values.
|
||||
* @param __a A value.
|
||||
* @param __b A value.
|
||||
* @param __c A value.
|
||||
* @return One of @p a, @p b or @p c.
|
||||
*
|
||||
* If @c {l,m,n} is some convolution of @p {a,b,c} such that @c l<=m<=n
|
||||
* then the value returned will be @c m.
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
*/
|
||||
template<typename _Tp>
|
||||
const _Tp&
|
||||
__median(const _Tp& __a, const _Tp& __b, const _Tp& __c)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_LessThanComparableConcept<_Tp>)
|
||||
if (__a < __b)
|
||||
if (__b < __c)
|
||||
return __b;
|
||||
else if (__a < __c)
|
||||
return __c;
|
||||
else
|
||||
return __a;
|
||||
else if (__a < __c)
|
||||
return __a;
|
||||
else if (__b < __c)
|
||||
return __c;
|
||||
else
|
||||
return __b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find the median of three values using a predicate for comparison.
|
||||
* @param __a A value.
|
||||
* @param __b A value.
|
||||
* @param __c A value.
|
||||
* @param __comp A binary predicate.
|
||||
* @return One of @p a, @p b or @p c.
|
||||
*
|
||||
* If @c {l,m,n} is some convolution of @p {a,b,c} such that @p comp(l,m)
|
||||
* and @p comp(m,n) are both true then the value returned will be @c m.
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
*/
|
||||
template<typename _Tp, typename _Compare>
|
||||
const _Tp&
|
||||
__median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_BinaryFunctionConcept<_Compare, bool,
|
||||
_Tp, _Tp>)
|
||||
if (__comp(__a, __b))
|
||||
if (__comp(__b, __c))
|
||||
return __b;
|
||||
else if (__comp(__a, __c))
|
||||
return __c;
|
||||
else
|
||||
return __a;
|
||||
else if (__comp(__a, __c))
|
||||
return __a;
|
||||
else if (__comp(__b, __c))
|
||||
return __c;
|
||||
else
|
||||
return __b;
|
||||
}
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif /* _EXT_ALGORITHM */
|
||||
119
openflow/usr/include/c++/5/ext/aligned_buffer.h
Normal file
119
openflow/usr/include/c++/5/ext/aligned_buffer.h
Normal file
@@ -0,0 +1,119 @@
|
||||
// Aligned memory buffer -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2013-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/aligned_buffer.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _ALIGNED_BUFFER_H
|
||||
#define _ALIGNED_BUFFER_H 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <bits/c++0x_warning.h>
|
||||
#endif
|
||||
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
// A utility type containing a POD object that can hold an object of type
|
||||
// _Tp initialized via placement new or allocator_traits::construct.
|
||||
// Intended for use as a data member subobject, use __aligned_buffer for
|
||||
// complete objects.
|
||||
template<typename _Tp>
|
||||
struct __aligned_membuf
|
||||
{
|
||||
// Target macro ADJUST_FIELD_ALIGN can produce different alignment for
|
||||
// types when used as class members. __aligned_membuf is intended
|
||||
// for use as a class member, so align the buffer as for a class member.
|
||||
struct _Tp2 { _Tp _M_t; };
|
||||
|
||||
alignas(__alignof__(_Tp2::_M_t)) unsigned char _M_storage[sizeof(_Tp)];
|
||||
|
||||
__aligned_membuf() = default;
|
||||
|
||||
// Can be used to avoid value-initialization zeroing _M_storage.
|
||||
__aligned_membuf(std::nullptr_t) { }
|
||||
|
||||
void*
|
||||
_M_addr() noexcept
|
||||
{ return static_cast<void*>(&_M_storage); }
|
||||
|
||||
const void*
|
||||
_M_addr() const noexcept
|
||||
{ return static_cast<const void*>(&_M_storage); }
|
||||
|
||||
_Tp*
|
||||
_M_ptr() noexcept
|
||||
{ return static_cast<_Tp*>(_M_addr()); }
|
||||
|
||||
const _Tp*
|
||||
_M_ptr() const noexcept
|
||||
{ return static_cast<const _Tp*>(_M_addr()); }
|
||||
};
|
||||
|
||||
// Similar to __aligned_membuf but aligned for complete objects, not members.
|
||||
// This type is used in <forward_list>, <future>, <bits/shared_ptr_base.h>
|
||||
// and <bits/hashtable_policy.h>, but ideally they would use __aligned_membuf
|
||||
// instead, as it has smaller size for some types on some targets.
|
||||
// This type is still used to avoid an ABI change.
|
||||
template<typename _Tp>
|
||||
struct __aligned_buffer
|
||||
: std::aligned_storage<sizeof(_Tp), std::alignment_of<_Tp>::value>
|
||||
{
|
||||
typename
|
||||
std::aligned_storage<sizeof(_Tp), std::alignment_of<_Tp>::value>::type
|
||||
_M_storage;
|
||||
|
||||
__aligned_buffer() = default;
|
||||
|
||||
// Can be used to avoid value-initialization
|
||||
__aligned_buffer(std::nullptr_t) { }
|
||||
|
||||
void*
|
||||
_M_addr() noexcept
|
||||
{
|
||||
return static_cast<void*>(&_M_storage);
|
||||
}
|
||||
|
||||
const void*
|
||||
_M_addr() const noexcept
|
||||
{
|
||||
return static_cast<const void*>(&_M_storage);
|
||||
}
|
||||
|
||||
_Tp*
|
||||
_M_ptr() noexcept
|
||||
{ return static_cast<_Tp*>(_M_addr()); }
|
||||
|
||||
const _Tp*
|
||||
_M_ptr() const noexcept
|
||||
{ return static_cast<const _Tp*>(_M_addr()); }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif /* _ALIGNED_BUFFER_H */
|
||||
215
openflow/usr/include/c++/5/ext/alloc_traits.h
Normal file
215
openflow/usr/include/c++/5/ext/alloc_traits.h
Normal file
@@ -0,0 +1,215 @@
|
||||
// Allocator traits -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2011-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/alloc_traits.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _EXT_ALLOC_TRAITS_H
|
||||
#define _EXT_ALLOC_TRAITS_H 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# include <bits/move.h>
|
||||
# include <bits/alloc_traits.h>
|
||||
#else
|
||||
# include <bits/allocator.h> // for __alloc_swap
|
||||
#endif
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _Alloc>
|
||||
struct __allocator_always_compares_equal : std::false_type { };
|
||||
|
||||
template<typename _Tp>
|
||||
struct __allocator_always_compares_equal<std::allocator<_Tp>>
|
||||
: std::true_type { };
|
||||
|
||||
template<typename, typename> struct array_allocator;
|
||||
|
||||
template<typename _Tp, typename _Array>
|
||||
struct __allocator_always_compares_equal<array_allocator<_Tp, _Array>>
|
||||
: std::true_type { };
|
||||
|
||||
template<typename> struct bitmap_allocator;
|
||||
|
||||
template<typename _Tp>
|
||||
struct __allocator_always_compares_equal<bitmap_allocator<_Tp>>
|
||||
: std::true_type { };
|
||||
|
||||
template<typename> struct malloc_allocator;
|
||||
|
||||
template<typename _Tp>
|
||||
struct __allocator_always_compares_equal<malloc_allocator<_Tp>>
|
||||
: std::true_type { };
|
||||
|
||||
template<typename> struct mt_allocator;
|
||||
|
||||
template<typename _Tp>
|
||||
struct __allocator_always_compares_equal<mt_allocator<_Tp>>
|
||||
: std::true_type { };
|
||||
|
||||
template<typename> struct new_allocator;
|
||||
|
||||
template<typename _Tp>
|
||||
struct __allocator_always_compares_equal<new_allocator<_Tp>>
|
||||
: std::true_type { };
|
||||
|
||||
template<typename> struct pool_allocator;
|
||||
|
||||
template<typename _Tp>
|
||||
struct __allocator_always_compares_equal<pool_allocator<_Tp>>
|
||||
: std::true_type { };
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Uniform interface to C++98 and C++0x allocators.
|
||||
* @ingroup allocators
|
||||
*/
|
||||
template<typename _Alloc>
|
||||
struct __alloc_traits
|
||||
#if __cplusplus >= 201103L
|
||||
: std::allocator_traits<_Alloc>
|
||||
#endif
|
||||
{
|
||||
typedef _Alloc allocator_type;
|
||||
#if __cplusplus >= 201103L
|
||||
typedef std::allocator_traits<_Alloc> _Base_type;
|
||||
typedef typename _Base_type::value_type value_type;
|
||||
typedef typename _Base_type::pointer pointer;
|
||||
typedef typename _Base_type::const_pointer const_pointer;
|
||||
typedef typename _Base_type::size_type size_type;
|
||||
typedef typename _Base_type::difference_type difference_type;
|
||||
// C++11 allocators do not define reference or const_reference
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
using _Base_type::allocate;
|
||||
using _Base_type::deallocate;
|
||||
using _Base_type::construct;
|
||||
using _Base_type::destroy;
|
||||
using _Base_type::max_size;
|
||||
|
||||
private:
|
||||
template<typename _Ptr>
|
||||
using __is_custom_pointer
|
||||
= std::__and_<std::is_same<pointer, _Ptr>,
|
||||
std::__not_<std::is_pointer<_Ptr>>>;
|
||||
|
||||
public:
|
||||
// overload construct for non-standard pointer types
|
||||
template<typename _Ptr, typename... _Args>
|
||||
static typename std::enable_if<__is_custom_pointer<_Ptr>::value>::type
|
||||
construct(_Alloc& __a, _Ptr __p, _Args&&... __args)
|
||||
{
|
||||
_Base_type::construct(__a, std::addressof(*__p),
|
||||
std::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
// overload destroy for non-standard pointer types
|
||||
template<typename _Ptr>
|
||||
static typename std::enable_if<__is_custom_pointer<_Ptr>::value>::type
|
||||
destroy(_Alloc& __a, _Ptr __p)
|
||||
{ _Base_type::destroy(__a, std::addressof(*__p)); }
|
||||
|
||||
static _Alloc _S_select_on_copy(const _Alloc& __a)
|
||||
{ return _Base_type::select_on_container_copy_construction(__a); }
|
||||
|
||||
static void _S_on_swap(_Alloc& __a, _Alloc& __b)
|
||||
{ std::__alloc_on_swap(__a, __b); }
|
||||
|
||||
static constexpr bool _S_propagate_on_copy_assign()
|
||||
{ return _Base_type::propagate_on_container_copy_assignment::value; }
|
||||
|
||||
static constexpr bool _S_propagate_on_move_assign()
|
||||
{ return _Base_type::propagate_on_container_move_assignment::value; }
|
||||
|
||||
static constexpr bool _S_propagate_on_swap()
|
||||
{ return _Base_type::propagate_on_container_swap::value; }
|
||||
|
||||
static constexpr bool _S_always_equal()
|
||||
{ return __allocator_always_compares_equal<_Alloc>::value; }
|
||||
|
||||
static constexpr bool _S_nothrow_move()
|
||||
{ return _S_propagate_on_move_assign() || _S_always_equal(); }
|
||||
|
||||
static constexpr bool _S_nothrow_swap()
|
||||
{
|
||||
using std::swap;
|
||||
return !_S_propagate_on_swap()
|
||||
|| noexcept(swap(std::declval<_Alloc&>(), std::declval<_Alloc&>()));
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
struct rebind
|
||||
{ typedef typename _Base_type::template rebind_alloc<_Tp> other; };
|
||||
#else
|
||||
|
||||
typedef typename _Alloc::pointer pointer;
|
||||
typedef typename _Alloc::const_pointer const_pointer;
|
||||
typedef typename _Alloc::value_type value_type;
|
||||
typedef typename _Alloc::reference reference;
|
||||
typedef typename _Alloc::const_reference const_reference;
|
||||
typedef typename _Alloc::size_type size_type;
|
||||
typedef typename _Alloc::difference_type difference_type;
|
||||
|
||||
static pointer
|
||||
allocate(_Alloc& __a, size_type __n)
|
||||
{ return __a.allocate(__n); }
|
||||
|
||||
static void deallocate(_Alloc& __a, pointer __p, size_type __n)
|
||||
{ __a.deallocate(__p, __n); }
|
||||
|
||||
template<typename _Tp>
|
||||
static void construct(_Alloc& __a, pointer __p, const _Tp& __arg)
|
||||
{ __a.construct(__p, __arg); }
|
||||
|
||||
static void destroy(_Alloc& __a, pointer __p)
|
||||
{ __a.destroy(__p); }
|
||||
|
||||
static size_type max_size(const _Alloc& __a)
|
||||
{ return __a.max_size(); }
|
||||
|
||||
static const _Alloc& _S_select_on_copy(const _Alloc& __a) { return __a; }
|
||||
|
||||
static void _S_on_swap(_Alloc& __a, _Alloc& __b)
|
||||
{
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 431. Swapping containers with unequal allocators.
|
||||
std::__alloc_swap<_Alloc>::_S_do_it(__a, __b);
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
struct rebind
|
||||
{ typedef typename _Alloc::template rebind<_Tp>::other other; };
|
||||
#endif
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace __gnu_cxx
|
||||
|
||||
#endif
|
||||
180
openflow/usr/include/c++/5/ext/array_allocator.h
Normal file
180
openflow/usr/include/c++/5/ext/array_allocator.h
Normal file
@@ -0,0 +1,180 @@
|
||||
// array allocator -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2004-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/array_allocator.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _ARRAY_ALLOCATOR_H
|
||||
#define _ARRAY_ALLOCATOR_H 1
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#include <new>
|
||||
#include <bits/functexcept.h>
|
||||
#include <tr1/array>
|
||||
#include <bits/move.h>
|
||||
#if __cplusplus >= 201103L
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
// Suppress deprecated warning for this file.
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::size_t;
|
||||
using std::ptrdiff_t;
|
||||
|
||||
/// Base class.
|
||||
template<typename _Tp>
|
||||
class array_allocator_base
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
|
||||
pointer
|
||||
address(reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
const_pointer
|
||||
address(const_reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
void
|
||||
deallocate(pointer, size_type)
|
||||
{
|
||||
// Does nothing.
|
||||
}
|
||||
|
||||
size_type
|
||||
max_size() const _GLIBCXX_USE_NOEXCEPT
|
||||
{ return size_t(-1) / sizeof(_Tp); }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _Up, typename... _Args>
|
||||
void
|
||||
construct(_Up* __p, _Args&&... __args)
|
||||
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
|
||||
|
||||
template<typename _Up>
|
||||
void
|
||||
destroy(_Up* __p) { __p->~_Up(); }
|
||||
#else
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 402. wrong new expression in [some_] allocator::construct
|
||||
void
|
||||
construct(pointer __p, const _Tp& __val)
|
||||
{ ::new((void *)__p) value_type(__val); }
|
||||
|
||||
void
|
||||
destroy(pointer __p) { __p->~_Tp(); }
|
||||
#endif
|
||||
} _GLIBCXX_DEPRECATED;
|
||||
|
||||
/**
|
||||
* @brief An allocator that uses previously allocated memory.
|
||||
* This memory can be externally, globally, or otherwise allocated.
|
||||
* @ingroup allocators
|
||||
*/
|
||||
template<typename _Tp, typename _Array = std::tr1::array<_Tp, 1> >
|
||||
class array_allocator : public array_allocator_base<_Tp>
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
typedef _Array array_type;
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 2103. std::allocator propagate_on_container_move_assignment
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
#endif
|
||||
|
||||
private:
|
||||
array_type* _M_array;
|
||||
size_type _M_used;
|
||||
|
||||
public:
|
||||
template<typename _Tp1, typename _Array1 = _Array>
|
||||
struct rebind
|
||||
{
|
||||
typedef array_allocator<_Tp1, _Array1> other _GLIBCXX_DEPRECATED;
|
||||
} _GLIBCXX_DEPRECATED;
|
||||
|
||||
array_allocator(array_type* __array = 0) _GLIBCXX_USE_NOEXCEPT
|
||||
: _M_array(__array), _M_used(size_type()) { }
|
||||
|
||||
array_allocator(const array_allocator& __o) _GLIBCXX_USE_NOEXCEPT
|
||||
: _M_array(__o._M_array), _M_used(__o._M_used) { }
|
||||
|
||||
template<typename _Tp1, typename _Array1>
|
||||
array_allocator(const array_allocator<_Tp1, _Array1>&)
|
||||
_GLIBCXX_USE_NOEXCEPT
|
||||
: _M_array(0), _M_used(size_type()) { }
|
||||
|
||||
~array_allocator() _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
pointer
|
||||
allocate(size_type __n, const void* = 0)
|
||||
{
|
||||
if (_M_array == 0 || _M_used + __n > _M_array->size())
|
||||
std::__throw_bad_alloc();
|
||||
pointer __ret = _M_array->begin() + _M_used;
|
||||
_M_used += __n;
|
||||
return __ret;
|
||||
}
|
||||
} _GLIBCXX_DEPRECATED;
|
||||
|
||||
template<typename _Tp, typename _Array>
|
||||
inline bool
|
||||
operator==(const array_allocator<_Tp, _Array>&,
|
||||
const array_allocator<_Tp, _Array>&)
|
||||
{ return true; }
|
||||
|
||||
template<typename _Tp, typename _Array>
|
||||
inline bool
|
||||
operator!=(const array_allocator<_Tp, _Array>&,
|
||||
const array_allocator<_Tp, _Array>&)
|
||||
{ return false; }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#endif
|
||||
117
openflow/usr/include/c++/5/ext/atomicity.h
Normal file
117
openflow/usr/include/c++/5/ext/atomicity.h
Normal file
@@ -0,0 +1,117 @@
|
||||
// Support for atomic operations -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2004-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/atomicity.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _GLIBCXX_ATOMICITY_H
|
||||
#define _GLIBCXX_ATOMICITY_H 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#include <bits/gthr.h>
|
||||
#include <bits/atomic_word.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
// Functions for portable atomic access.
|
||||
// To abstract locking primitives across all thread policies, use:
|
||||
// __exchange_and_add_dispatch
|
||||
// __atomic_add_dispatch
|
||||
#ifdef _GLIBCXX_ATOMIC_BUILTINS
|
||||
static inline _Atomic_word
|
||||
__exchange_and_add(volatile _Atomic_word* __mem, int __val)
|
||||
{ return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
|
||||
|
||||
static inline void
|
||||
__atomic_add(volatile _Atomic_word* __mem, int __val)
|
||||
{ __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
|
||||
#else
|
||||
_Atomic_word
|
||||
__attribute__ ((__unused__))
|
||||
__exchange_and_add(volatile _Atomic_word*, int) throw ();
|
||||
|
||||
void
|
||||
__attribute__ ((__unused__))
|
||||
__atomic_add(volatile _Atomic_word*, int) throw ();
|
||||
#endif
|
||||
|
||||
static inline _Atomic_word
|
||||
__exchange_and_add_single(_Atomic_word* __mem, int __val)
|
||||
{
|
||||
_Atomic_word __result = *__mem;
|
||||
*__mem += __val;
|
||||
return __result;
|
||||
}
|
||||
|
||||
static inline void
|
||||
__atomic_add_single(_Atomic_word* __mem, int __val)
|
||||
{ *__mem += __val; }
|
||||
|
||||
static inline _Atomic_word
|
||||
__attribute__ ((__unused__))
|
||||
__exchange_and_add_dispatch(_Atomic_word* __mem, int __val)
|
||||
{
|
||||
#ifdef __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
return __exchange_and_add(__mem, __val);
|
||||
else
|
||||
return __exchange_and_add_single(__mem, __val);
|
||||
#else
|
||||
return __exchange_and_add_single(__mem, __val);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
__attribute__ ((__unused__))
|
||||
__atomic_add_dispatch(_Atomic_word* __mem, int __val)
|
||||
{
|
||||
#ifdef __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
__atomic_add(__mem, __val);
|
||||
else
|
||||
__atomic_add_single(__mem, __val);
|
||||
#else
|
||||
__atomic_add_single(__mem, __val);
|
||||
#endif
|
||||
}
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
// Even if the CPU doesn't need a memory barrier, we need to ensure
|
||||
// that the compiler doesn't reorder memory accesses across the
|
||||
// barriers.
|
||||
#ifndef _GLIBCXX_READ_MEM_BARRIER
|
||||
#define _GLIBCXX_READ_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||
#endif
|
||||
#ifndef _GLIBCXX_WRITE_MEM_BARRIER
|
||||
#define _GLIBCXX_WRITE_MEM_BARRIER __asm __volatile ("":::"memory")
|
||||
#endif
|
||||
|
||||
#endif
|
||||
1119
openflow/usr/include/c++/5/ext/bitmap_allocator.h
Normal file
1119
openflow/usr/include/c++/5/ext/bitmap_allocator.h
Normal file
File diff suppressed because it is too large
Load Diff
121
openflow/usr/include/c++/5/ext/cast.h
Normal file
121
openflow/usr/include/c++/5/ext/cast.h
Normal file
@@ -0,0 +1,121 @@
|
||||
// <cast.h> -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2008-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/cast.h
|
||||
* This is an internal header file, included by other library headers.
|
||||
* Do not attempt to use it directly. @headername{ext/pointer.h}
|
||||
*/
|
||||
|
||||
#ifndef _GLIBCXX_CAST_H
|
||||
#define _GLIBCXX_CAST_H 1
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
/**
|
||||
* These functions are here to allow containers to support non standard
|
||||
* pointer types. For normal pointers, these resolve to the use of the
|
||||
* standard cast operation. For other types the functions will perform
|
||||
* the appropriate cast to/from the custom pointer class so long as that
|
||||
* class meets the following conditions:
|
||||
* 1) has a typedef element_type which names tehe type it points to.
|
||||
* 2) has a get() const method which returns element_type*.
|
||||
* 3) has a constructor which can take one element_type* argument.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This type supports the semantics of the pointer cast operators (below.)
|
||||
*/
|
||||
template<typename _ToType>
|
||||
struct _Caster
|
||||
{ typedef typename _ToType::element_type* type; };
|
||||
|
||||
template<typename _ToType>
|
||||
struct _Caster<_ToType*>
|
||||
{ typedef _ToType* type; };
|
||||
|
||||
/**
|
||||
* Casting operations for cases where _FromType is not a standard pointer.
|
||||
* _ToType can be a standard or non-standard pointer. Given that _FromType
|
||||
* is not a pointer, it must have a get() method that returns the standard
|
||||
* pointer equivalent of the address it points to, and must have an
|
||||
* element_type typedef which names the type it points to.
|
||||
*/
|
||||
template<typename _ToType, typename _FromType>
|
||||
inline _ToType
|
||||
__static_pointer_cast(const _FromType& __arg)
|
||||
{ return _ToType(static_cast<typename _Caster<_ToType>::
|
||||
type>(__arg.get())); }
|
||||
|
||||
template<typename _ToType, typename _FromType>
|
||||
inline _ToType
|
||||
__dynamic_pointer_cast(const _FromType& __arg)
|
||||
{ return _ToType(dynamic_cast<typename _Caster<_ToType>::
|
||||
type>(__arg.get())); }
|
||||
|
||||
template<typename _ToType, typename _FromType>
|
||||
inline _ToType
|
||||
__const_pointer_cast(const _FromType& __arg)
|
||||
{ return _ToType(const_cast<typename _Caster<_ToType>::
|
||||
type>(__arg.get())); }
|
||||
|
||||
template<typename _ToType, typename _FromType>
|
||||
inline _ToType
|
||||
__reinterpret_pointer_cast(const _FromType& __arg)
|
||||
{ return _ToType(reinterpret_cast<typename _Caster<_ToType>::
|
||||
type>(__arg.get())); }
|
||||
|
||||
/**
|
||||
* Casting operations for cases where _FromType is a standard pointer.
|
||||
* _ToType can be a standard or non-standard pointer.
|
||||
*/
|
||||
template<typename _ToType, typename _FromType>
|
||||
inline _ToType
|
||||
__static_pointer_cast(_FromType* __arg)
|
||||
{ return _ToType(static_cast<typename _Caster<_ToType>::
|
||||
type>(__arg)); }
|
||||
|
||||
template<typename _ToType, typename _FromType>
|
||||
inline _ToType
|
||||
__dynamic_pointer_cast(_FromType* __arg)
|
||||
{ return _ToType(dynamic_cast<typename _Caster<_ToType>::
|
||||
type>(__arg)); }
|
||||
|
||||
template<typename _ToType, typename _FromType>
|
||||
inline _ToType
|
||||
__const_pointer_cast(_FromType* __arg)
|
||||
{ return _ToType(const_cast<typename _Caster<_ToType>::
|
||||
type>(__arg)); }
|
||||
|
||||
template<typename _ToType, typename _FromType>
|
||||
inline _ToType
|
||||
__reinterpret_pointer_cast(_FromType* __arg)
|
||||
{ return _ToType(reinterpret_cast<typename _Caster<_ToType>::
|
||||
type>(__arg)); }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif // _GLIBCXX_CAST_H
|
||||
152
openflow/usr/include/c++/5/ext/cmath
Normal file
152
openflow/usr/include/c++/5/ext/cmath
Normal file
@@ -0,0 +1,152 @@
|
||||
// Math extensions -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2013-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/cmath
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _EXT_CMATH
|
||||
#define _EXT_CMATH 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
# include <bits/c++0x_warning.h>
|
||||
#else
|
||||
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
// A class for math constants.
|
||||
template<typename _RealType>
|
||||
struct __math_constants
|
||||
{
|
||||
static_assert(std::is_floating_point<_RealType>::value,
|
||||
"template argument not a floating point type");
|
||||
|
||||
// Constant @f$ \pi @f$.
|
||||
static constexpr _RealType __pi = 3.1415926535897932384626433832795029L;
|
||||
// Constant @f$ \pi / 2 @f$.
|
||||
static constexpr _RealType __pi_half = 1.5707963267948966192313216916397514L;
|
||||
// Constant @f$ \pi / 3 @f$.
|
||||
static constexpr _RealType __pi_third = 1.0471975511965977461542144610931676L;
|
||||
// Constant @f$ \pi / 4 @f$.
|
||||
static constexpr _RealType __pi_quarter = 0.7853981633974483096156608458198757L;
|
||||
// Constant @f$ \sqrt(\pi / 2) @f$.
|
||||
static constexpr _RealType __root_pi_div_2 = 1.2533141373155002512078826424055226L;
|
||||
// Constant @f$ 1 / \pi @f$.
|
||||
static constexpr _RealType __one_div_pi = 0.3183098861837906715377675267450287L;
|
||||
// Constant @f$ 2 / \pi @f$.
|
||||
static constexpr _RealType __two_div_pi = 0.6366197723675813430755350534900574L;
|
||||
// Constant @f$ 2 / \sqrt(\pi) @f$.
|
||||
static constexpr _RealType __two_div_root_pi = 1.1283791670955125738961589031215452L;
|
||||
|
||||
// Constant Euler's number @f$ e @f$.
|
||||
static constexpr _RealType __e = 2.7182818284590452353602874713526625L;
|
||||
// Constant @f$ 1 / e @f$.
|
||||
static constexpr _RealType __one_div_e = 0.36787944117144232159552377016146087L;
|
||||
// Constant @f$ \log_2(e) @f$.
|
||||
static constexpr _RealType __log2_e = 1.4426950408889634073599246810018921L;
|
||||
// Constant @f$ \log_10(e) @f$.
|
||||
static constexpr _RealType __log10_e = 0.4342944819032518276511289189166051L;
|
||||
// Constant @f$ \ln(2) @f$.
|
||||
static constexpr _RealType __ln_2 = 0.6931471805599453094172321214581766L;
|
||||
// Constant @f$ \ln(3) @f$.
|
||||
static constexpr _RealType __ln_3 = 1.0986122886681096913952452369225257L;
|
||||
// Constant @f$ \ln(10) @f$.
|
||||
static constexpr _RealType __ln_10 = 2.3025850929940456840179914546843642L;
|
||||
|
||||
// Constant Euler-Mascheroni @f$ \gamma_E @f$.
|
||||
static constexpr _RealType __gamma_e = 0.5772156649015328606065120900824024L;
|
||||
// Constant Golden Ratio @f$ \phi @f$.
|
||||
static constexpr _RealType __phi = 1.6180339887498948482045868343656381L;
|
||||
|
||||
// Constant @f$ \sqrt(2) @f$.
|
||||
static constexpr _RealType __root_2 = 1.4142135623730950488016887242096981L;
|
||||
// Constant @f$ \sqrt(3) @f$.
|
||||
static constexpr _RealType __root_3 = 1.7320508075688772935274463415058724L;
|
||||
// Constant @f$ \sqrt(5) @f$.
|
||||
static constexpr _RealType __root_5 = 2.2360679774997896964091736687312762L;
|
||||
// Constant @f$ \sqrt(7) @f$.
|
||||
static constexpr _RealType __root_7 = 2.6457513110645905905016157536392604L;
|
||||
// Constant @f$ 1 / \sqrt(2) @f$.
|
||||
static constexpr _RealType __one_div_root_2 = 0.7071067811865475244008443621048490L;
|
||||
};
|
||||
|
||||
// And the template definitions for the constants.
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__pi;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__pi_half;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__pi_third;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__pi_quarter;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__root_pi_div_2;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__one_div_pi;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__two_div_pi;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__two_div_root_pi;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__e;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__one_div_e;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__log2_e;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__log10_e;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__ln_2;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__ln_3;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__ln_10;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__gamma_e;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__phi;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__root_2;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__root_3;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__root_5;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__root_7;
|
||||
template<typename _RealType>
|
||||
constexpr _RealType __math_constants<_RealType>::__one_div_root_2;
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace __gnu_cxx
|
||||
|
||||
#endif // C++11
|
||||
|
||||
#endif // _EXT_CMATH
|
||||
515
openflow/usr/include/c++/5/ext/codecvt_specializations.h
Normal file
515
openflow/usr/include/c++/5/ext/codecvt_specializations.h
Normal file
@@ -0,0 +1,515 @@
|
||||
// Locale support (codecvt) -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2000-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
//
|
||||
// ISO C++ 14882: 22.2.1.5 Template class codecvt
|
||||
//
|
||||
|
||||
// Written by Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
/** @file ext/codecvt_specializations.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _EXT_CODECVT_SPECIALIZATIONS_H
|
||||
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#include <locale>
|
||||
#include <iconv.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
/// Extension to use iconv for dealing with character encodings.
|
||||
// This includes conversions and comparisons between various character
|
||||
// sets. This object encapsulates data that may need to be shared between
|
||||
// char_traits, codecvt and ctype.
|
||||
class encoding_state
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
// NB: A conversion descriptor subsumes and enhances the
|
||||
// functionality of a simple state type such as mbstate_t.
|
||||
typedef iconv_t descriptor_type;
|
||||
|
||||
protected:
|
||||
// Name of internal character set encoding.
|
||||
std::string _M_int_enc;
|
||||
|
||||
// Name of external character set encoding.
|
||||
std::string _M_ext_enc;
|
||||
|
||||
// Conversion descriptor between external encoding to internal encoding.
|
||||
descriptor_type _M_in_desc;
|
||||
|
||||
// Conversion descriptor between internal encoding to external encoding.
|
||||
descriptor_type _M_out_desc;
|
||||
|
||||
// The byte-order marker for the external encoding, if necessary.
|
||||
int _M_ext_bom;
|
||||
|
||||
// The byte-order marker for the internal encoding, if necessary.
|
||||
int _M_int_bom;
|
||||
|
||||
// Number of external bytes needed to construct one complete
|
||||
// character in the internal encoding.
|
||||
// NB: -1 indicates variable, or stateful, encodings.
|
||||
int _M_bytes;
|
||||
|
||||
public:
|
||||
explicit
|
||||
encoding_state()
|
||||
: _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0), _M_bytes(0)
|
||||
{ }
|
||||
|
||||
explicit
|
||||
encoding_state(const char* __int, const char* __ext,
|
||||
int __ibom = 0, int __ebom = 0, int __bytes = 1)
|
||||
: _M_int_enc(__int), _M_ext_enc(__ext), _M_in_desc(0), _M_out_desc(0),
|
||||
_M_ext_bom(__ebom), _M_int_bom(__ibom), _M_bytes(__bytes)
|
||||
{ init(); }
|
||||
|
||||
// 21.1.2 traits typedefs
|
||||
// p4
|
||||
// typedef STATE_T state_type
|
||||
// requires: state_type shall meet the requirements of
|
||||
// CopyConstructible types (20.1.3)
|
||||
// NB: This does not preserve the actual state of the conversion
|
||||
// descriptor member, but it does duplicate the encoding
|
||||
// information.
|
||||
encoding_state(const encoding_state& __obj) : _M_in_desc(0), _M_out_desc(0)
|
||||
{ construct(__obj); }
|
||||
|
||||
// Need assignment operator as well.
|
||||
encoding_state&
|
||||
operator=(const encoding_state& __obj)
|
||||
{
|
||||
construct(__obj);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~encoding_state()
|
||||
{ destroy(); }
|
||||
|
||||
bool
|
||||
good() const throw()
|
||||
{
|
||||
const descriptor_type __err = (iconv_t)(-1);
|
||||
bool __test = _M_in_desc && _M_in_desc != __err;
|
||||
__test &= _M_out_desc && _M_out_desc != __err;
|
||||
return __test;
|
||||
}
|
||||
|
||||
int
|
||||
character_ratio() const
|
||||
{ return _M_bytes; }
|
||||
|
||||
const std::string
|
||||
internal_encoding() const
|
||||
{ return _M_int_enc; }
|
||||
|
||||
int
|
||||
internal_bom() const
|
||||
{ return _M_int_bom; }
|
||||
|
||||
const std::string
|
||||
external_encoding() const
|
||||
{ return _M_ext_enc; }
|
||||
|
||||
int
|
||||
external_bom() const
|
||||
{ return _M_ext_bom; }
|
||||
|
||||
const descriptor_type&
|
||||
in_descriptor() const
|
||||
{ return _M_in_desc; }
|
||||
|
||||
const descriptor_type&
|
||||
out_descriptor() const
|
||||
{ return _M_out_desc; }
|
||||
|
||||
protected:
|
||||
void
|
||||
init()
|
||||
{
|
||||
const descriptor_type __err = (iconv_t)(-1);
|
||||
const bool __have_encodings = _M_int_enc.size() && _M_ext_enc.size();
|
||||
if (!_M_in_desc && __have_encodings)
|
||||
{
|
||||
_M_in_desc = iconv_open(_M_int_enc.c_str(), _M_ext_enc.c_str());
|
||||
if (_M_in_desc == __err)
|
||||
std::__throw_runtime_error(__N("encoding_state::_M_init "
|
||||
"creating iconv input descriptor failed"));
|
||||
}
|
||||
if (!_M_out_desc && __have_encodings)
|
||||
{
|
||||
_M_out_desc = iconv_open(_M_ext_enc.c_str(), _M_int_enc.c_str());
|
||||
if (_M_out_desc == __err)
|
||||
std::__throw_runtime_error(__N("encoding_state::_M_init "
|
||||
"creating iconv output descriptor failed"));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
construct(const encoding_state& __obj)
|
||||
{
|
||||
destroy();
|
||||
_M_int_enc = __obj._M_int_enc;
|
||||
_M_ext_enc = __obj._M_ext_enc;
|
||||
_M_ext_bom = __obj._M_ext_bom;
|
||||
_M_int_bom = __obj._M_int_bom;
|
||||
_M_bytes = __obj._M_bytes;
|
||||
init();
|
||||
}
|
||||
|
||||
void
|
||||
destroy() throw()
|
||||
{
|
||||
const descriptor_type __err = (iconv_t)(-1);
|
||||
if (_M_in_desc && _M_in_desc != __err)
|
||||
{
|
||||
iconv_close(_M_in_desc);
|
||||
_M_in_desc = 0;
|
||||
}
|
||||
if (_M_out_desc && _M_out_desc != __err)
|
||||
{
|
||||
iconv_close(_M_out_desc);
|
||||
_M_out_desc = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// encoding_char_traits
|
||||
// Custom traits type with encoding_state for the state type, and the
|
||||
// associated fpos<encoding_state> for the position type, all other
|
||||
// bits equivalent to the required char_traits instantiations.
|
||||
template<typename _CharT>
|
||||
struct encoding_char_traits
|
||||
: public std::char_traits<_CharT>
|
||||
{
|
||||
typedef encoding_state state_type;
|
||||
typedef typename std::fpos<state_type> pos_type;
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
_GLIBCXX_END_NAMESPACE_CXX11
|
||||
} // namespace
|
||||
|
||||
|
||||
namespace std _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using __gnu_cxx::encoding_state;
|
||||
|
||||
/// codecvt<InternT, _ExternT, encoding_state> specialization.
|
||||
// This partial specialization takes advantage of iconv to provide
|
||||
// code conversions between a large number of character encodings.
|
||||
template<typename _InternT, typename _ExternT>
|
||||
class codecvt<_InternT, _ExternT, encoding_state>
|
||||
: public __codecvt_abstract_base<_InternT, _ExternT, encoding_state>
|
||||
{
|
||||
public:
|
||||
// Types:
|
||||
typedef codecvt_base::result result;
|
||||
typedef _InternT intern_type;
|
||||
typedef _ExternT extern_type;
|
||||
typedef __gnu_cxx::encoding_state state_type;
|
||||
typedef state_type::descriptor_type descriptor_type;
|
||||
|
||||
// Data Members:
|
||||
static locale::id id;
|
||||
|
||||
explicit
|
||||
codecvt(size_t __refs = 0)
|
||||
: __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs)
|
||||
{ }
|
||||
|
||||
explicit
|
||||
codecvt(state_type& __enc, size_t __refs = 0)
|
||||
: __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
virtual
|
||||
~codecvt() { }
|
||||
|
||||
virtual result
|
||||
do_out(state_type& __state, const intern_type* __from,
|
||||
const intern_type* __from_end, const intern_type*& __from_next,
|
||||
extern_type* __to, extern_type* __to_end,
|
||||
extern_type*& __to_next) const;
|
||||
|
||||
virtual result
|
||||
do_unshift(state_type& __state, extern_type* __to,
|
||||
extern_type* __to_end, extern_type*& __to_next) const;
|
||||
|
||||
virtual result
|
||||
do_in(state_type& __state, const extern_type* __from,
|
||||
const extern_type* __from_end, const extern_type*& __from_next,
|
||||
intern_type* __to, intern_type* __to_end,
|
||||
intern_type*& __to_next) const;
|
||||
|
||||
virtual int
|
||||
do_encoding() const throw();
|
||||
|
||||
virtual bool
|
||||
do_always_noconv() const throw();
|
||||
|
||||
virtual int
|
||||
do_length(state_type&, const extern_type* __from,
|
||||
const extern_type* __end, size_t __max) const;
|
||||
|
||||
virtual int
|
||||
do_max_length() const throw();
|
||||
};
|
||||
|
||||
template<typename _InternT, typename _ExternT>
|
||||
locale::id
|
||||
codecvt<_InternT, _ExternT, encoding_state>::id;
|
||||
|
||||
// This adaptor works around the signature problems of the second
|
||||
// argument to iconv(): SUSv2 and others use 'const char**', but glibc 2.2
|
||||
// uses 'char**', which matches the POSIX 1003.1-2001 standard.
|
||||
// Using this adaptor, g++ will do the work for us.
|
||||
template<typename _Tp>
|
||||
inline size_t
|
||||
__iconv_adaptor(size_t(*__func)(iconv_t, _Tp, size_t*, char**, size_t*),
|
||||
iconv_t __cd, char** __inbuf, size_t* __inbytes,
|
||||
char** __outbuf, size_t* __outbytes)
|
||||
{ return __func(__cd, (_Tp)__inbuf, __inbytes, __outbuf, __outbytes); }
|
||||
|
||||
template<typename _InternT, typename _ExternT>
|
||||
codecvt_base::result
|
||||
codecvt<_InternT, _ExternT, encoding_state>::
|
||||
do_out(state_type& __state, const intern_type* __from,
|
||||
const intern_type* __from_end, const intern_type*& __from_next,
|
||||
extern_type* __to, extern_type* __to_end,
|
||||
extern_type*& __to_next) const
|
||||
{
|
||||
result __ret = codecvt_base::error;
|
||||
if (__state.good())
|
||||
{
|
||||
const descriptor_type& __desc = __state.out_descriptor();
|
||||
const size_t __fmultiple = sizeof(intern_type);
|
||||
size_t __fbytes = __fmultiple * (__from_end - __from);
|
||||
const size_t __tmultiple = sizeof(extern_type);
|
||||
size_t __tbytes = __tmultiple * (__to_end - __to);
|
||||
|
||||
// Argument list for iconv specifies a byte sequence. Thus,
|
||||
// all to/from arrays must be brutally casted to char*.
|
||||
char* __cto = reinterpret_cast<char*>(__to);
|
||||
char* __cfrom;
|
||||
size_t __conv;
|
||||
|
||||
// Some encodings need a byte order marker as the first item
|
||||
// in the byte stream, to designate endian-ness. The default
|
||||
// value for the byte order marker is NULL, so if this is
|
||||
// the case, it's not necessary and we can just go on our
|
||||
// merry way.
|
||||
int __int_bom = __state.internal_bom();
|
||||
if (__int_bom)
|
||||
{
|
||||
size_t __size = __from_end - __from;
|
||||
intern_type* __cfixed = static_cast<intern_type*>
|
||||
(__builtin_alloca(sizeof(intern_type) * (__size + 1)));
|
||||
__cfixed[0] = static_cast<intern_type>(__int_bom);
|
||||
char_traits<intern_type>::copy(__cfixed + 1, __from, __size);
|
||||
__cfrom = reinterpret_cast<char*>(__cfixed);
|
||||
__conv = __iconv_adaptor(iconv, __desc, &__cfrom,
|
||||
&__fbytes, &__cto, &__tbytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
intern_type* __cfixed = const_cast<intern_type*>(__from);
|
||||
__cfrom = reinterpret_cast<char*>(__cfixed);
|
||||
__conv = __iconv_adaptor(iconv, __desc, &__cfrom, &__fbytes,
|
||||
&__cto, &__tbytes);
|
||||
}
|
||||
|
||||
if (__conv != size_t(-1))
|
||||
{
|
||||
__from_next = reinterpret_cast<const intern_type*>(__cfrom);
|
||||
__to_next = reinterpret_cast<extern_type*>(__cto);
|
||||
__ret = codecvt_base::ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__fbytes < __fmultiple * (__from_end - __from))
|
||||
{
|
||||
__from_next = reinterpret_cast<const intern_type*>(__cfrom);
|
||||
__to_next = reinterpret_cast<extern_type*>(__cto);
|
||||
__ret = codecvt_base::partial;
|
||||
}
|
||||
else
|
||||
__ret = codecvt_base::error;
|
||||
}
|
||||
}
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template<typename _InternT, typename _ExternT>
|
||||
codecvt_base::result
|
||||
codecvt<_InternT, _ExternT, encoding_state>::
|
||||
do_unshift(state_type& __state, extern_type* __to,
|
||||
extern_type* __to_end, extern_type*& __to_next) const
|
||||
{
|
||||
result __ret = codecvt_base::error;
|
||||
if (__state.good())
|
||||
{
|
||||
const descriptor_type& __desc = __state.in_descriptor();
|
||||
const size_t __tmultiple = sizeof(intern_type);
|
||||
size_t __tlen = __tmultiple * (__to_end - __to);
|
||||
|
||||
// Argument list for iconv specifies a byte sequence. Thus,
|
||||
// all to/from arrays must be brutally casted to char*.
|
||||
char* __cto = reinterpret_cast<char*>(__to);
|
||||
size_t __conv = __iconv_adaptor(iconv,__desc, 0, 0,
|
||||
&__cto, &__tlen);
|
||||
|
||||
if (__conv != size_t(-1))
|
||||
{
|
||||
__to_next = reinterpret_cast<extern_type*>(__cto);
|
||||
if (__tlen == __tmultiple * (__to_end - __to))
|
||||
__ret = codecvt_base::noconv;
|
||||
else if (__tlen == 0)
|
||||
__ret = codecvt_base::ok;
|
||||
else
|
||||
__ret = codecvt_base::partial;
|
||||
}
|
||||
else
|
||||
__ret = codecvt_base::error;
|
||||
}
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template<typename _InternT, typename _ExternT>
|
||||
codecvt_base::result
|
||||
codecvt<_InternT, _ExternT, encoding_state>::
|
||||
do_in(state_type& __state, const extern_type* __from,
|
||||
const extern_type* __from_end, const extern_type*& __from_next,
|
||||
intern_type* __to, intern_type* __to_end,
|
||||
intern_type*& __to_next) const
|
||||
{
|
||||
result __ret = codecvt_base::error;
|
||||
if (__state.good())
|
||||
{
|
||||
const descriptor_type& __desc = __state.in_descriptor();
|
||||
const size_t __fmultiple = sizeof(extern_type);
|
||||
size_t __flen = __fmultiple * (__from_end - __from);
|
||||
const size_t __tmultiple = sizeof(intern_type);
|
||||
size_t __tlen = __tmultiple * (__to_end - __to);
|
||||
|
||||
// Argument list for iconv specifies a byte sequence. Thus,
|
||||
// all to/from arrays must be brutally casted to char*.
|
||||
char* __cto = reinterpret_cast<char*>(__to);
|
||||
char* __cfrom;
|
||||
size_t __conv;
|
||||
|
||||
// Some encodings need a byte order marker as the first item
|
||||
// in the byte stream, to designate endian-ness. The default
|
||||
// value for the byte order marker is NULL, so if this is
|
||||
// the case, it's not necessary and we can just go on our
|
||||
// merry way.
|
||||
int __ext_bom = __state.external_bom();
|
||||
if (__ext_bom)
|
||||
{
|
||||
size_t __size = __from_end - __from;
|
||||
extern_type* __cfixed = static_cast<extern_type*>
|
||||
(__builtin_alloca(sizeof(extern_type) * (__size + 1)));
|
||||
__cfixed[0] = static_cast<extern_type>(__ext_bom);
|
||||
char_traits<extern_type>::copy(__cfixed + 1, __from, __size);
|
||||
__cfrom = reinterpret_cast<char*>(__cfixed);
|
||||
__conv = __iconv_adaptor(iconv, __desc, &__cfrom,
|
||||
&__flen, &__cto, &__tlen);
|
||||
}
|
||||
else
|
||||
{
|
||||
extern_type* __cfixed = const_cast<extern_type*>(__from);
|
||||
__cfrom = reinterpret_cast<char*>(__cfixed);
|
||||
__conv = __iconv_adaptor(iconv, __desc, &__cfrom,
|
||||
&__flen, &__cto, &__tlen);
|
||||
}
|
||||
|
||||
|
||||
if (__conv != size_t(-1))
|
||||
{
|
||||
__from_next = reinterpret_cast<const extern_type*>(__cfrom);
|
||||
__to_next = reinterpret_cast<intern_type*>(__cto);
|
||||
__ret = codecvt_base::ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (__flen < static_cast<size_t>(__from_end - __from))
|
||||
{
|
||||
__from_next = reinterpret_cast<const extern_type*>(__cfrom);
|
||||
__to_next = reinterpret_cast<intern_type*>(__cto);
|
||||
__ret = codecvt_base::partial;
|
||||
}
|
||||
else
|
||||
__ret = codecvt_base::error;
|
||||
}
|
||||
}
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template<typename _InternT, typename _ExternT>
|
||||
int
|
||||
codecvt<_InternT, _ExternT, encoding_state>::
|
||||
do_encoding() const throw()
|
||||
{
|
||||
int __ret = 0;
|
||||
if (sizeof(_ExternT) <= sizeof(_InternT))
|
||||
__ret = sizeof(_InternT) / sizeof(_ExternT);
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template<typename _InternT, typename _ExternT>
|
||||
bool
|
||||
codecvt<_InternT, _ExternT, encoding_state>::
|
||||
do_always_noconv() const throw()
|
||||
{ return false; }
|
||||
|
||||
template<typename _InternT, typename _ExternT>
|
||||
int
|
||||
codecvt<_InternT, _ExternT, encoding_state>::
|
||||
do_length(state_type&, const extern_type* __from,
|
||||
const extern_type* __end, size_t __max) const
|
||||
{ return std::min(__max, static_cast<size_t>(__end - __from)); }
|
||||
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 74. Garbled text for codecvt::do_max_length
|
||||
template<typename _InternT, typename _ExternT>
|
||||
int
|
||||
codecvt<_InternT, _ExternT, encoding_state>::
|
||||
do_max_length() const throw()
|
||||
{ return 1; }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
318
openflow/usr/include/c++/5/ext/concurrence.h
Normal file
318
openflow/usr/include/c++/5/ext/concurrence.h
Normal file
@@ -0,0 +1,318 @@
|
||||
// Support for concurrent programing -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2003-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/concurrence.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _CONCURRENCE_H
|
||||
#define _CONCURRENCE_H 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <exception>
|
||||
#include <bits/gthr.h>
|
||||
#include <bits/functexcept.h>
|
||||
#include <bits/cpp_type_traits.h>
|
||||
#include <ext/type_traits.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
// Available locking policies:
|
||||
// _S_single single-threaded code that doesn't need to be locked.
|
||||
// _S_mutex multi-threaded code that requires additional support
|
||||
// from gthr.h or abstraction layers in concurrence.h.
|
||||
// _S_atomic multi-threaded code using atomic operations.
|
||||
enum _Lock_policy { _S_single, _S_mutex, _S_atomic };
|
||||
|
||||
// Compile time constant that indicates prefered locking policy in
|
||||
// the current configuration.
|
||||
static const _Lock_policy __default_lock_policy =
|
||||
#ifdef __GTHREADS
|
||||
#if (defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) \
|
||||
&& defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4))
|
||||
_S_atomic;
|
||||
#else
|
||||
_S_mutex;
|
||||
#endif
|
||||
#else
|
||||
_S_single;
|
||||
#endif
|
||||
|
||||
// NB: As this is used in libsupc++, need to only depend on
|
||||
// exception. No stdexception classes, no use of std::string.
|
||||
class __concurrence_lock_error : public std::exception
|
||||
{
|
||||
public:
|
||||
virtual char const*
|
||||
what() const throw()
|
||||
{ return "__gnu_cxx::__concurrence_lock_error"; }
|
||||
};
|
||||
|
||||
class __concurrence_unlock_error : public std::exception
|
||||
{
|
||||
public:
|
||||
virtual char const*
|
||||
what() const throw()
|
||||
{ return "__gnu_cxx::__concurrence_unlock_error"; }
|
||||
};
|
||||
|
||||
class __concurrence_broadcast_error : public std::exception
|
||||
{
|
||||
public:
|
||||
virtual char const*
|
||||
what() const throw()
|
||||
{ return "__gnu_cxx::__concurrence_broadcast_error"; }
|
||||
};
|
||||
|
||||
class __concurrence_wait_error : public std::exception
|
||||
{
|
||||
public:
|
||||
virtual char const*
|
||||
what() const throw()
|
||||
{ return "__gnu_cxx::__concurrence_wait_error"; }
|
||||
};
|
||||
|
||||
// Substitute for concurrence_error object in the case of -fno-exceptions.
|
||||
inline void
|
||||
__throw_concurrence_lock_error()
|
||||
{ _GLIBCXX_THROW_OR_ABORT(__concurrence_lock_error()); }
|
||||
|
||||
inline void
|
||||
__throw_concurrence_unlock_error()
|
||||
{ _GLIBCXX_THROW_OR_ABORT(__concurrence_unlock_error()); }
|
||||
|
||||
#ifdef __GTHREAD_HAS_COND
|
||||
inline void
|
||||
__throw_concurrence_broadcast_error()
|
||||
{ _GLIBCXX_THROW_OR_ABORT(__concurrence_broadcast_error()); }
|
||||
|
||||
inline void
|
||||
__throw_concurrence_wait_error()
|
||||
{ _GLIBCXX_THROW_OR_ABORT(__concurrence_wait_error()); }
|
||||
#endif
|
||||
|
||||
class __mutex
|
||||
{
|
||||
private:
|
||||
#if __GTHREADS && defined __GTHREAD_MUTEX_INIT
|
||||
__gthread_mutex_t _M_mutex = __GTHREAD_MUTEX_INIT;
|
||||
#else
|
||||
__gthread_mutex_t _M_mutex;
|
||||
#endif
|
||||
|
||||
__mutex(const __mutex&);
|
||||
__mutex& operator=(const __mutex&);
|
||||
|
||||
public:
|
||||
__mutex()
|
||||
{
|
||||
#if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT
|
||||
if (__gthread_active_p())
|
||||
__GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if __GTHREADS && ! defined __GTHREAD_MUTEX_INIT
|
||||
~__mutex()
|
||||
{
|
||||
if (__gthread_active_p())
|
||||
__gthread_mutex_destroy(&_M_mutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
void lock()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
if (__gthread_mutex_lock(&_M_mutex) != 0)
|
||||
__throw_concurrence_lock_error();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
if (__gthread_mutex_unlock(&_M_mutex) != 0)
|
||||
__throw_concurrence_unlock_error();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
__gthread_mutex_t* gthread_mutex(void)
|
||||
{ return &_M_mutex; }
|
||||
};
|
||||
|
||||
class __recursive_mutex
|
||||
{
|
||||
private:
|
||||
#if __GTHREADS && defined __GTHREAD_RECURSIVE_MUTEX_INIT
|
||||
__gthread_recursive_mutex_t _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT;
|
||||
#else
|
||||
__gthread_recursive_mutex_t _M_mutex;
|
||||
#endif
|
||||
|
||||
__recursive_mutex(const __recursive_mutex&);
|
||||
__recursive_mutex& operator=(const __recursive_mutex&);
|
||||
|
||||
public:
|
||||
__recursive_mutex()
|
||||
{
|
||||
#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
|
||||
if (__gthread_active_p())
|
||||
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if __GTHREADS && ! defined __GTHREAD_RECURSIVE_MUTEX_INIT
|
||||
~__recursive_mutex()
|
||||
{
|
||||
if (__gthread_active_p())
|
||||
__gthread_recursive_mutex_destroy(&_M_mutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
void lock()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
if (__gthread_recursive_mutex_lock(&_M_mutex) != 0)
|
||||
__throw_concurrence_lock_error();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
if (__gthread_recursive_mutex_unlock(&_M_mutex) != 0)
|
||||
__throw_concurrence_unlock_error();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
__gthread_recursive_mutex_t* gthread_recursive_mutex(void)
|
||||
{ return &_M_mutex; }
|
||||
};
|
||||
|
||||
/// Scoped lock idiom.
|
||||
// Acquire the mutex here with a constructor call, then release with
|
||||
// the destructor call in accordance with RAII style.
|
||||
class __scoped_lock
|
||||
{
|
||||
public:
|
||||
typedef __mutex __mutex_type;
|
||||
|
||||
private:
|
||||
__mutex_type& _M_device;
|
||||
|
||||
__scoped_lock(const __scoped_lock&);
|
||||
__scoped_lock& operator=(const __scoped_lock&);
|
||||
|
||||
public:
|
||||
explicit __scoped_lock(__mutex_type& __name) : _M_device(__name)
|
||||
{ _M_device.lock(); }
|
||||
|
||||
~__scoped_lock() throw()
|
||||
{ _M_device.unlock(); }
|
||||
};
|
||||
|
||||
#ifdef __GTHREAD_HAS_COND
|
||||
class __cond
|
||||
{
|
||||
private:
|
||||
#if __GTHREADS && defined __GTHREAD_COND_INIT
|
||||
__gthread_cond_t _M_cond = __GTHREAD_COND_INIT;
|
||||
#else
|
||||
__gthread_cond_t _M_cond;
|
||||
#endif
|
||||
|
||||
__cond(const __cond&);
|
||||
__cond& operator=(const __cond&);
|
||||
|
||||
public:
|
||||
__cond()
|
||||
{
|
||||
#if __GTHREADS && ! defined __GTHREAD_COND_INIT
|
||||
if (__gthread_active_p())
|
||||
__GTHREAD_COND_INIT_FUNCTION(&_M_cond);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if __GTHREADS && ! defined __GTHREAD_COND_INIT
|
||||
~__cond()
|
||||
{
|
||||
if (__gthread_active_p())
|
||||
__gthread_cond_destroy(&_M_cond);
|
||||
}
|
||||
#endif
|
||||
|
||||
void broadcast()
|
||||
{
|
||||
#if __GTHREADS
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
if (__gthread_cond_broadcast(&_M_cond) != 0)
|
||||
__throw_concurrence_broadcast_error();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void wait(__mutex *mutex)
|
||||
{
|
||||
#if __GTHREADS
|
||||
{
|
||||
if (__gthread_cond_wait(&_M_cond, mutex->gthread_mutex()) != 0)
|
||||
__throw_concurrence_wait_error();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void wait_recursive(__recursive_mutex *mutex)
|
||||
{
|
||||
#if __GTHREADS
|
||||
{
|
||||
if (__gthread_cond_wait_recursive(&_M_cond,
|
||||
mutex->gthread_recursive_mutex())
|
||||
!= 0)
|
||||
__throw_concurrence_wait_error();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
191
openflow/usr/include/c++/5/ext/debug_allocator.h
Normal file
191
openflow/usr/include/c++/5/ext/debug_allocator.h
Normal file
@@ -0,0 +1,191 @@
|
||||
// Allocators -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/** @file ext/debug_allocator.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _DEBUG_ALLOCATOR_H
|
||||
#define _DEBUG_ALLOCATOR_H 1
|
||||
|
||||
#include <stdexcept>
|
||||
#include <bits/functexcept.h>
|
||||
#include <ext/alloc_traits.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::size_t;
|
||||
|
||||
/**
|
||||
* @brief A meta-allocator with debugging bits.
|
||||
* @ingroup allocators
|
||||
*
|
||||
* This is precisely the allocator defined in the C++03 Standard.
|
||||
*/
|
||||
template<typename _Alloc>
|
||||
class debug_allocator
|
||||
{
|
||||
template<typename> friend class debug_allocator;
|
||||
|
||||
typedef __alloc_traits<_Alloc> _Traits;
|
||||
|
||||
public:
|
||||
typedef typename _Traits::size_type size_type;
|
||||
typedef typename _Traits::difference_type difference_type;
|
||||
typedef typename _Traits::pointer pointer;
|
||||
typedef typename _Traits::const_pointer const_pointer;
|
||||
typedef typename _Traits::reference reference;
|
||||
typedef typename _Traits::const_reference const_reference;
|
||||
typedef typename _Traits::value_type value_type;
|
||||
|
||||
template<typename _Up>
|
||||
class rebind
|
||||
{
|
||||
typedef typename _Traits::template rebind<_Up>::other __other;
|
||||
|
||||
public:
|
||||
typedef debug_allocator<__other> other;
|
||||
};
|
||||
|
||||
private:
|
||||
// _M_extra is the number of objects that correspond to the
|
||||
// extra space where debug information is stored.
|
||||
size_type _M_extra;
|
||||
|
||||
_Alloc _M_allocator;
|
||||
|
||||
template<typename _Alloc2,
|
||||
typename = typename _Alloc2::template rebind<value_type>::other>
|
||||
struct __convertible
|
||||
{ };
|
||||
|
||||
template<typename _Alloc2>
|
||||
struct __convertible<_Alloc2, _Alloc>
|
||||
{
|
||||
typedef void* __type;
|
||||
};
|
||||
|
||||
size_type _S_extra()
|
||||
{
|
||||
const size_t __obj_size = sizeof(value_type);
|
||||
return (sizeof(size_type) + __obj_size - 1) / __obj_size;
|
||||
}
|
||||
|
||||
public:
|
||||
debug_allocator() : _M_extra(_S_extra()) { }
|
||||
|
||||
template<typename _Alloc2>
|
||||
debug_allocator(const debug_allocator<_Alloc2>& __a2,
|
||||
typename __convertible<_Alloc2>::__type = 0)
|
||||
: _M_allocator(__a2._M_allocator), _M_extra(_S_extra()) { }
|
||||
|
||||
debug_allocator(const _Alloc& __a)
|
||||
: _M_allocator(__a), _M_extra(_S_extra()) { }
|
||||
|
||||
pointer
|
||||
allocate(size_type __n)
|
||||
{
|
||||
pointer __res = _M_allocator.allocate(__n + _M_extra);
|
||||
size_type* __ps = reinterpret_cast<size_type*>(__res);
|
||||
*__ps = __n;
|
||||
return __res + _M_extra;
|
||||
}
|
||||
|
||||
pointer
|
||||
allocate(size_type __n, const void* __hint)
|
||||
{
|
||||
pointer __res = _M_allocator.allocate(__n + _M_extra, __hint);
|
||||
size_type* __ps = reinterpret_cast<size_type*>(__res);
|
||||
*__ps = __n;
|
||||
return __res + _M_extra;
|
||||
}
|
||||
|
||||
void
|
||||
deallocate(pointer __p, size_type __n)
|
||||
{
|
||||
using std::__throw_runtime_error;
|
||||
if (__p)
|
||||
{
|
||||
pointer __real_p = __p - _M_extra;
|
||||
if (*reinterpret_cast<size_type*>(__real_p) != __n)
|
||||
__throw_runtime_error("debug_allocator::deallocate wrong size");
|
||||
_M_allocator.deallocate(__real_p, __n + _M_extra);
|
||||
}
|
||||
else
|
||||
__throw_runtime_error("debug_allocator::deallocate null pointer");
|
||||
}
|
||||
|
||||
void
|
||||
construct(pointer __p, const value_type& __val)
|
||||
{ _Traits::construct(_M_allocator, __p, __val); }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _Tp, typename... _Args>
|
||||
void
|
||||
construct(_Tp* __p, _Args&&... __args)
|
||||
{
|
||||
_Traits::construct(_M_allocator, __p,
|
||||
std::forward<_Args>(__args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Tp>
|
||||
void
|
||||
destroy(_Tp* __p)
|
||||
{ _Traits::destroy(_M_allocator, __p); }
|
||||
|
||||
size_type
|
||||
max_size() const throw()
|
||||
{ return _Traits::max_size(_M_allocator) - _M_extra; }
|
||||
|
||||
friend bool
|
||||
operator==(const debug_allocator& __lhs, const debug_allocator& __rhs)
|
||||
{ return __lhs._M_allocator == __rhs._M_allocator; }
|
||||
};
|
||||
|
||||
template<typename _Alloc>
|
||||
inline bool
|
||||
operator!=(const debug_allocator<_Alloc>& __lhs,
|
||||
const debug_allocator<_Alloc>& __rhs)
|
||||
{ return !(__lhs == __rhs); }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
65
openflow/usr/include/c++/5/ext/enc_filebuf.h
Normal file
65
openflow/usr/include/c++/5/ext/enc_filebuf.h
Normal file
@@ -0,0 +1,65 @@
|
||||
// filebuf with encoding state type -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/enc_filebuf.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _EXT_ENC_FILEBUF_H
|
||||
#define _EXT_ENC_FILEBUF_H 1
|
||||
|
||||
#include <fstream>
|
||||
#include <locale>
|
||||
#include <ext/codecvt_specializations.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
/// class enc_filebuf.
|
||||
template<typename _CharT>
|
||||
class enc_filebuf
|
||||
: public std::basic_filebuf<_CharT, encoding_char_traits<_CharT> >
|
||||
{
|
||||
public:
|
||||
typedef encoding_char_traits<_CharT> traits_type;
|
||||
typedef typename traits_type::state_type state_type;
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
|
||||
enc_filebuf(state_type& __state)
|
||||
: std::basic_filebuf<_CharT, encoding_char_traits<_CharT> >()
|
||||
{ this->_M_state_beg = __state; }
|
||||
|
||||
private:
|
||||
// concept requirements:
|
||||
// Set state type to something useful.
|
||||
// Something more than copyconstructible is needed here, so
|
||||
// require default and copy constructible + assignment operator.
|
||||
__glibcxx_class_requires(state_type, _SGIAssignableConcept)
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
197
openflow/usr/include/c++/5/ext/extptr_allocator.h
Normal file
197
openflow/usr/include/c++/5/ext/extptr_allocator.h
Normal file
@@ -0,0 +1,197 @@
|
||||
// <extptr_allocator.h> -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2008-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* @file ext/extptr_allocator.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*
|
||||
* @author Bob Walters
|
||||
*
|
||||
* An example allocator which uses an alternative pointer type from
|
||||
* bits/pointer.h. Supports test cases which confirm container support
|
||||
* for alternative pointers.
|
||||
*/
|
||||
|
||||
#ifndef _EXTPTR_ALLOCATOR_H
|
||||
#define _EXTPTR_ALLOCATOR_H 1
|
||||
|
||||
#include <memory>
|
||||
#include <ext/numeric_traits.h>
|
||||
#include <ext/pointer.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
/**
|
||||
* @brief An example allocator which uses a non-standard pointer type.
|
||||
* @ingroup allocators
|
||||
*
|
||||
* This allocator specifies that containers use a 'relative pointer' as it's
|
||||
* pointer type. (See ext/pointer.h) Memory allocation in this example
|
||||
* is still performed using std::allocator.
|
||||
*/
|
||||
template<typename _Tp>
|
||||
class _ExtPtr_allocator
|
||||
{
|
||||
public:
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
// Note the non-standard pointer types.
|
||||
typedef _Pointer_adapter<_Relative_pointer_impl<_Tp> > pointer;
|
||||
typedef _Pointer_adapter<_Relative_pointer_impl<const _Tp> >
|
||||
const_pointer;
|
||||
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
|
||||
template<typename _Up>
|
||||
struct rebind
|
||||
{ typedef _ExtPtr_allocator<_Up> other; };
|
||||
|
||||
_ExtPtr_allocator() _GLIBCXX_USE_NOEXCEPT
|
||||
: _M_real_alloc() { }
|
||||
|
||||
_ExtPtr_allocator(const _ExtPtr_allocator& __rarg) _GLIBCXX_USE_NOEXCEPT
|
||||
: _M_real_alloc(__rarg._M_real_alloc) { }
|
||||
|
||||
template<typename _Up>
|
||||
_ExtPtr_allocator(const _ExtPtr_allocator<_Up>& __rarg)
|
||||
_GLIBCXX_USE_NOEXCEPT
|
||||
: _M_real_alloc(__rarg._M_getUnderlyingImp()) { }
|
||||
|
||||
~_ExtPtr_allocator() _GLIBCXX_USE_NOEXCEPT
|
||||
{ }
|
||||
|
||||
pointer address(reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
const_pointer address(const_reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
pointer allocate(size_type __n, void* __hint = 0)
|
||||
{ return _M_real_alloc.allocate(__n,__hint); }
|
||||
|
||||
void deallocate(pointer __p, size_type __n)
|
||||
{ _M_real_alloc.deallocate(__p.get(), __n); }
|
||||
|
||||
size_type max_size() const _GLIBCXX_USE_NOEXCEPT
|
||||
{ return __numeric_traits<size_type>::__max / sizeof(_Tp); }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _Up, typename... _Args>
|
||||
void
|
||||
construct(_Up* __p, _Args&&... __args)
|
||||
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
|
||||
|
||||
template<typename... _Args>
|
||||
void
|
||||
construct(pointer __p, _Args&&... __args)
|
||||
{ construct(__p.get(), std::forward<_Args>(__args)...); }
|
||||
|
||||
template<typename _Up>
|
||||
void
|
||||
destroy(_Up* __p)
|
||||
{ __p->~_Up(); }
|
||||
|
||||
void destroy(pointer __p)
|
||||
{ destroy(__p.get()); }
|
||||
|
||||
#else
|
||||
|
||||
void construct(pointer __p, const _Tp& __val)
|
||||
{ ::new(__p.get()) _Tp(__val); }
|
||||
|
||||
void destroy(pointer __p)
|
||||
{ __p->~_Tp(); }
|
||||
#endif
|
||||
|
||||
template<typename _Up>
|
||||
inline bool
|
||||
operator==(const _ExtPtr_allocator<_Up>& __rarg)
|
||||
{ return _M_real_alloc == __rarg._M_getUnderlyingImp(); }
|
||||
|
||||
inline bool
|
||||
operator==(const _ExtPtr_allocator& __rarg)
|
||||
{ return _M_real_alloc == __rarg._M_real_alloc; }
|
||||
|
||||
template<typename _Up>
|
||||
inline bool
|
||||
operator!=(const _ExtPtr_allocator<_Up>& __rarg)
|
||||
{ return _M_real_alloc != __rarg._M_getUnderlyingImp(); }
|
||||
|
||||
inline bool
|
||||
operator!=(const _ExtPtr_allocator& __rarg)
|
||||
{ return _M_real_alloc != __rarg._M_real_alloc; }
|
||||
|
||||
template<typename _Up>
|
||||
inline friend void
|
||||
swap(_ExtPtr_allocator<_Up>&, _ExtPtr_allocator<_Up>&);
|
||||
|
||||
// A method specific to this implementation.
|
||||
const std::allocator<_Tp>&
|
||||
_M_getUnderlyingImp() const
|
||||
{ return _M_real_alloc; }
|
||||
|
||||
private:
|
||||
std::allocator<_Tp> _M_real_alloc;
|
||||
};
|
||||
|
||||
// _ExtPtr_allocator<void> specialization.
|
||||
template<>
|
||||
class _ExtPtr_allocator<void>
|
||||
{
|
||||
public:
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef void value_type;
|
||||
|
||||
// Note the non-standard pointer types
|
||||
typedef _Pointer_adapter<_Relative_pointer_impl<void> > pointer;
|
||||
typedef _Pointer_adapter<_Relative_pointer_impl<const void> >
|
||||
const_pointer;
|
||||
|
||||
template<typename _Up>
|
||||
struct rebind
|
||||
{ typedef _ExtPtr_allocator<_Up> other; };
|
||||
|
||||
private:
|
||||
std::allocator<void> _M_real_alloc;
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
swap(_ExtPtr_allocator<_Tp>& __larg, _ExtPtr_allocator<_Tp>& __rarg)
|
||||
{
|
||||
std::allocator<_Tp> __tmp( __rarg._M_real_alloc );
|
||||
__rarg._M_real_alloc = __larg._M_real_alloc;
|
||||
__larg._M_real_alloc = __tmp;
|
||||
}
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif /* _EXTPTR_ALLOCATOR_H */
|
||||
430
openflow/usr/include/c++/5/ext/functional
Normal file
430
openflow/usr/include/c++/5/ext/functional
Normal file
@@ -0,0 +1,430 @@
|
||||
// Functional extensions -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Hewlett-Packard Company makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1996
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/** @file ext/functional
|
||||
* This file is a GNU extension to the Standard C++ Library (possibly
|
||||
* containing extensions from the HP/SGI STL subset).
|
||||
*/
|
||||
|
||||
#ifndef _EXT_FUNCTIONAL
|
||||
#define _EXT_FUNCTIONAL 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::size_t;
|
||||
using std::unary_function;
|
||||
using std::binary_function;
|
||||
using std::mem_fun1_t;
|
||||
using std::const_mem_fun1_t;
|
||||
using std::mem_fun1_ref_t;
|
||||
using std::const_mem_fun1_ref_t;
|
||||
|
||||
/** The @c identity_element functions are not part of the C++
|
||||
* standard; SGI provided them as an extension. Its argument is an
|
||||
* operation, and its return value is the identity element for that
|
||||
* operation. It is overloaded for addition and multiplication,
|
||||
* and you can overload it for your own nefarious operations.
|
||||
*
|
||||
* @addtogroup SGIextensions
|
||||
* @{
|
||||
*/
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Tp>
|
||||
inline _Tp
|
||||
identity_element(std::plus<_Tp>)
|
||||
{ return _Tp(0); }
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Tp>
|
||||
inline _Tp
|
||||
identity_element(std::multiplies<_Tp>)
|
||||
{ return _Tp(1); }
|
||||
/** @} */
|
||||
|
||||
/** As an extension to the binders, SGI provided composition functors and
|
||||
* wrapper functions to aid in their creation. The @c unary_compose
|
||||
* functor is constructed from two functions/functors, @c f and @c g.
|
||||
* Calling @c operator() with a single argument @c x returns @c f(g(x)).
|
||||
* The function @c compose1 takes the two functions and constructs a
|
||||
* @c unary_compose variable for you.
|
||||
*
|
||||
* @c binary_compose is constructed from three functors, @c f, @c g1,
|
||||
* and @c g2. Its @c operator() returns @c f(g1(x),g2(x)). The function
|
||||
* compose2 takes f, g1, and g2, and constructs the @c binary_compose
|
||||
* instance for you. For example, if @c f returns an int, then
|
||||
* \code
|
||||
* int answer = (compose2(f,g1,g2))(x);
|
||||
* \endcode
|
||||
* is equivalent to
|
||||
* \code
|
||||
* int temp1 = g1(x);
|
||||
* int temp2 = g2(x);
|
||||
* int answer = f(temp1,temp2);
|
||||
* \endcode
|
||||
* But the first form is more compact, and can be passed around as a
|
||||
* functor to other algorithms.
|
||||
*
|
||||
* @addtogroup SGIextensions
|
||||
* @{
|
||||
*/
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Operation1, class _Operation2>
|
||||
class unary_compose
|
||||
: public unary_function<typename _Operation2::argument_type,
|
||||
typename _Operation1::result_type>
|
||||
{
|
||||
protected:
|
||||
_Operation1 _M_fn1;
|
||||
_Operation2 _M_fn2;
|
||||
|
||||
public:
|
||||
unary_compose(const _Operation1& __x, const _Operation2& __y)
|
||||
: _M_fn1(__x), _M_fn2(__y) {}
|
||||
|
||||
typename _Operation1::result_type
|
||||
operator()(const typename _Operation2::argument_type& __x) const
|
||||
{ return _M_fn1(_M_fn2(__x)); }
|
||||
};
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Operation1, class _Operation2>
|
||||
inline unary_compose<_Operation1, _Operation2>
|
||||
compose1(const _Operation1& __fn1, const _Operation2& __fn2)
|
||||
{ return unary_compose<_Operation1,_Operation2>(__fn1, __fn2); }
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Operation1, class _Operation2, class _Operation3>
|
||||
class binary_compose
|
||||
: public unary_function<typename _Operation2::argument_type,
|
||||
typename _Operation1::result_type>
|
||||
{
|
||||
protected:
|
||||
_Operation1 _M_fn1;
|
||||
_Operation2 _M_fn2;
|
||||
_Operation3 _M_fn3;
|
||||
|
||||
public:
|
||||
binary_compose(const _Operation1& __x, const _Operation2& __y,
|
||||
const _Operation3& __z)
|
||||
: _M_fn1(__x), _M_fn2(__y), _M_fn3(__z) { }
|
||||
|
||||
typename _Operation1::result_type
|
||||
operator()(const typename _Operation2::argument_type& __x) const
|
||||
{ return _M_fn1(_M_fn2(__x), _M_fn3(__x)); }
|
||||
};
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Operation1, class _Operation2, class _Operation3>
|
||||
inline binary_compose<_Operation1, _Operation2, _Operation3>
|
||||
compose2(const _Operation1& __fn1, const _Operation2& __fn2,
|
||||
const _Operation3& __fn3)
|
||||
{ return binary_compose<_Operation1, _Operation2, _Operation3>
|
||||
(__fn1, __fn2, __fn3); }
|
||||
/** @} */
|
||||
|
||||
/** As an extension, SGI provided a functor called @c identity. When a
|
||||
* functor is required but no operations are desired, this can be used as a
|
||||
* pass-through. Its @c operator() returns its argument unchanged.
|
||||
*
|
||||
* @addtogroup SGIextensions
|
||||
*/
|
||||
template <class _Tp>
|
||||
struct identity
|
||||
: public std::_Identity<_Tp> {};
|
||||
|
||||
/** @c select1st and @c select2nd are extensions provided by SGI. Their
|
||||
* @c operator()s
|
||||
* take a @c std::pair as an argument, and return either the first member
|
||||
* or the second member, respectively. They can be used (especially with
|
||||
* the composition functors) to @a strip data from a sequence before
|
||||
* performing the remainder of an algorithm.
|
||||
*
|
||||
* @addtogroup SGIextensions
|
||||
* @{
|
||||
*/
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Pair>
|
||||
struct select1st
|
||||
: public std::_Select1st<_Pair> {};
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Pair>
|
||||
struct select2nd
|
||||
: public std::_Select2nd<_Pair> {};
|
||||
|
||||
/** @} */
|
||||
|
||||
// extension documented next
|
||||
template <class _Arg1, class _Arg2>
|
||||
struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1>
|
||||
{
|
||||
_Arg1
|
||||
operator()(const _Arg1& __x, const _Arg2&) const
|
||||
{ return __x; }
|
||||
};
|
||||
|
||||
template <class _Arg1, class _Arg2>
|
||||
struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2>
|
||||
{
|
||||
_Arg2
|
||||
operator()(const _Arg1&, const _Arg2& __y) const
|
||||
{ return __y; }
|
||||
};
|
||||
|
||||
/** The @c operator() of the @c project1st functor takes two arbitrary
|
||||
* arguments and returns the first one, while @c project2nd returns the
|
||||
* second one. They are extensions provided by SGI.
|
||||
*
|
||||
* @addtogroup SGIextensions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Arg1, class _Arg2>
|
||||
struct project1st : public _Project1st<_Arg1, _Arg2> {};
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Arg1, class _Arg2>
|
||||
struct project2nd : public _Project2nd<_Arg1, _Arg2> {};
|
||||
/** @} */
|
||||
|
||||
// extension documented next
|
||||
template <class _Result>
|
||||
struct _Constant_void_fun
|
||||
{
|
||||
typedef _Result result_type;
|
||||
result_type _M_val;
|
||||
|
||||
_Constant_void_fun(const result_type& __v) : _M_val(__v) {}
|
||||
|
||||
const result_type&
|
||||
operator()() const
|
||||
{ return _M_val; }
|
||||
};
|
||||
|
||||
template <class _Result, class _Argument>
|
||||
struct _Constant_unary_fun
|
||||
{
|
||||
typedef _Argument argument_type;
|
||||
typedef _Result result_type;
|
||||
result_type _M_val;
|
||||
|
||||
_Constant_unary_fun(const result_type& __v) : _M_val(__v) {}
|
||||
|
||||
const result_type&
|
||||
operator()(const _Argument&) const
|
||||
{ return _M_val; }
|
||||
};
|
||||
|
||||
template <class _Result, class _Arg1, class _Arg2>
|
||||
struct _Constant_binary_fun
|
||||
{
|
||||
typedef _Arg1 first_argument_type;
|
||||
typedef _Arg2 second_argument_type;
|
||||
typedef _Result result_type;
|
||||
_Result _M_val;
|
||||
|
||||
_Constant_binary_fun(const _Result& __v) : _M_val(__v) {}
|
||||
|
||||
const result_type&
|
||||
operator()(const _Arg1&, const _Arg2&) const
|
||||
{ return _M_val; }
|
||||
};
|
||||
|
||||
/** These three functors are each constructed from a single arbitrary
|
||||
* variable/value. Later, their @c operator()s completely ignore any
|
||||
* arguments passed, and return the stored value.
|
||||
* - @c constant_void_fun's @c operator() takes no arguments
|
||||
* - @c constant_unary_fun's @c operator() takes one argument (ignored)
|
||||
* - @c constant_binary_fun's @c operator() takes two arguments (ignored)
|
||||
*
|
||||
* The helper creator functions @c constant0, @c constant1, and
|
||||
* @c constant2 each take a @a result argument and construct variables of
|
||||
* the appropriate functor type.
|
||||
*
|
||||
* @addtogroup SGIextensions
|
||||
* @{
|
||||
*/
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Result>
|
||||
struct constant_void_fun
|
||||
: public _Constant_void_fun<_Result>
|
||||
{
|
||||
constant_void_fun(const _Result& __v)
|
||||
: _Constant_void_fun<_Result>(__v) {}
|
||||
};
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Result, class _Argument = _Result>
|
||||
struct constant_unary_fun : public _Constant_unary_fun<_Result, _Argument>
|
||||
{
|
||||
constant_unary_fun(const _Result& __v)
|
||||
: _Constant_unary_fun<_Result, _Argument>(__v) {}
|
||||
};
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Result, class _Arg1 = _Result, class _Arg2 = _Arg1>
|
||||
struct constant_binary_fun
|
||||
: public _Constant_binary_fun<_Result, _Arg1, _Arg2>
|
||||
{
|
||||
constant_binary_fun(const _Result& __v)
|
||||
: _Constant_binary_fun<_Result, _Arg1, _Arg2>(__v) {}
|
||||
};
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Result>
|
||||
inline constant_void_fun<_Result>
|
||||
constant0(const _Result& __val)
|
||||
{ return constant_void_fun<_Result>(__val); }
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Result>
|
||||
inline constant_unary_fun<_Result, _Result>
|
||||
constant1(const _Result& __val)
|
||||
{ return constant_unary_fun<_Result, _Result>(__val); }
|
||||
|
||||
/// An \link SGIextensions SGI extension \endlink.
|
||||
template <class _Result>
|
||||
inline constant_binary_fun<_Result,_Result,_Result>
|
||||
constant2(const _Result& __val)
|
||||
{ return constant_binary_fun<_Result, _Result, _Result>(__val); }
|
||||
/** @} */
|
||||
|
||||
/** The @c subtractive_rng class is documented on
|
||||
* <a href="http://www.sgi.com/tech/stl/">SGI's site</a>.
|
||||
* Note that this code assumes that @c int is 32 bits.
|
||||
*
|
||||
* @ingroup SGIextensions
|
||||
*/
|
||||
class subtractive_rng
|
||||
: public unary_function<unsigned int, unsigned int>
|
||||
{
|
||||
private:
|
||||
unsigned int _M_table[55];
|
||||
size_t _M_index1;
|
||||
size_t _M_index2;
|
||||
|
||||
public:
|
||||
/// Returns a number less than the argument.
|
||||
unsigned int
|
||||
operator()(unsigned int __limit)
|
||||
{
|
||||
_M_index1 = (_M_index1 + 1) % 55;
|
||||
_M_index2 = (_M_index2 + 1) % 55;
|
||||
_M_table[_M_index1] = _M_table[_M_index1] - _M_table[_M_index2];
|
||||
return _M_table[_M_index1] % __limit;
|
||||
}
|
||||
|
||||
void
|
||||
_M_initialize(unsigned int __seed)
|
||||
{
|
||||
unsigned int __k = 1;
|
||||
_M_table[54] = __seed;
|
||||
size_t __i;
|
||||
for (__i = 0; __i < 54; __i++)
|
||||
{
|
||||
size_t __ii = (21 * (__i + 1) % 55) - 1;
|
||||
_M_table[__ii] = __k;
|
||||
__k = __seed - __k;
|
||||
__seed = _M_table[__ii];
|
||||
}
|
||||
for (int __loop = 0; __loop < 4; __loop++)
|
||||
{
|
||||
for (__i = 0; __i < 55; __i++)
|
||||
_M_table[__i] = _M_table[__i] - _M_table[(1 + __i + 30) % 55];
|
||||
}
|
||||
_M_index1 = 0;
|
||||
_M_index2 = 31;
|
||||
}
|
||||
|
||||
/// Ctor allowing you to initialize the seed.
|
||||
subtractive_rng(unsigned int __seed)
|
||||
{ _M_initialize(__seed); }
|
||||
|
||||
/// Default ctor; initializes its state with some number you don't see.
|
||||
subtractive_rng()
|
||||
{ _M_initialize(161803398u); }
|
||||
};
|
||||
|
||||
// Mem_fun adaptor helper functions mem_fun1 and mem_fun1_ref,
|
||||
// provided for backward compatibility, they are no longer part of
|
||||
// the C++ standard.
|
||||
|
||||
template <class _Ret, class _Tp, class _Arg>
|
||||
inline mem_fun1_t<_Ret, _Tp, _Arg>
|
||||
mem_fun1(_Ret (_Tp::*__f)(_Arg))
|
||||
{ return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
|
||||
|
||||
template <class _Ret, class _Tp, class _Arg>
|
||||
inline const_mem_fun1_t<_Ret, _Tp, _Arg>
|
||||
mem_fun1(_Ret (_Tp::*__f)(_Arg) const)
|
||||
{ return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
|
||||
|
||||
template <class _Ret, class _Tp, class _Arg>
|
||||
inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
|
||||
mem_fun1_ref(_Ret (_Tp::*__f)(_Arg))
|
||||
{ return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
|
||||
|
||||
template <class _Ret, class _Tp, class _Arg>
|
||||
inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
|
||||
mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const)
|
||||
{ return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
599
openflow/usr/include/c++/5/ext/hash_map
Normal file
599
openflow/usr/include/c++/5/ext/hash_map
Normal file
@@ -0,0 +1,599 @@
|
||||
// Hashing map implementation -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Hewlett-Packard Company makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file backward/hash_map
|
||||
* This file is a GNU extension to the Standard C++ Library (possibly
|
||||
* containing extensions from the HP/SGI STL subset).
|
||||
*/
|
||||
|
||||
#ifndef _BACKWARD_HASH_MAP
|
||||
#define _BACKWARD_HASH_MAP 1
|
||||
|
||||
#ifndef _GLIBCXX_PERMIT_BACKWARD_HASH
|
||||
#include "backward_warning.h"
|
||||
#endif
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#include <backward/hashtable.h>
|
||||
#include <bits/concept_check.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::equal_to;
|
||||
using std::allocator;
|
||||
using std::pair;
|
||||
using std::_Select1st;
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<class _Key, class _Tp, class _HashFn = hash<_Key>,
|
||||
class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> >
|
||||
class hash_map
|
||||
{
|
||||
private:
|
||||
typedef hashtable<pair<const _Key, _Tp>,_Key, _HashFn,
|
||||
_Select1st<pair<const _Key, _Tp> >,
|
||||
_EqualKey, _Alloc> _Ht;
|
||||
|
||||
_Ht _M_ht;
|
||||
|
||||
public:
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename _Ht::iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher
|
||||
hash_funct() const
|
||||
{ return _M_ht.hash_funct(); }
|
||||
|
||||
key_equal
|
||||
key_eq() const
|
||||
{ return _M_ht.key_eq(); }
|
||||
|
||||
allocator_type
|
||||
get_allocator() const
|
||||
{ return _M_ht.get_allocator(); }
|
||||
|
||||
hash_map()
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
|
||||
|
||||
explicit
|
||||
hash_map(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
|
||||
hash_map(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
|
||||
hash_map(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_map(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
size_type
|
||||
size() const
|
||||
{ return _M_ht.size(); }
|
||||
|
||||
size_type
|
||||
max_size() const
|
||||
{ return _M_ht.max_size(); }
|
||||
|
||||
bool
|
||||
empty() const
|
||||
{ return _M_ht.empty(); }
|
||||
|
||||
void
|
||||
swap(hash_map& __hs)
|
||||
{ _M_ht.swap(__hs._M_ht); }
|
||||
|
||||
template<class _K1, class _T1, class _HF, class _EqK, class _Al>
|
||||
friend bool
|
||||
operator== (const hash_map<_K1, _T1, _HF, _EqK, _Al>&,
|
||||
const hash_map<_K1, _T1, _HF, _EqK, _Al>&);
|
||||
|
||||
iterator
|
||||
begin()
|
||||
{ return _M_ht.begin(); }
|
||||
|
||||
iterator
|
||||
end()
|
||||
{ return _M_ht.end(); }
|
||||
|
||||
const_iterator
|
||||
begin() const
|
||||
{ return _M_ht.begin(); }
|
||||
|
||||
const_iterator
|
||||
end() const
|
||||
{ return _M_ht.end(); }
|
||||
|
||||
pair<iterator, bool>
|
||||
insert(const value_type& __obj)
|
||||
{ return _M_ht.insert_unique(__obj); }
|
||||
|
||||
template<class _InputIterator>
|
||||
void
|
||||
insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
pair<iterator, bool>
|
||||
insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_unique_noresize(__obj); }
|
||||
|
||||
iterator
|
||||
find(const key_type& __key)
|
||||
{ return _M_ht.find(__key); }
|
||||
|
||||
const_iterator
|
||||
find(const key_type& __key) const
|
||||
{ return _M_ht.find(__key); }
|
||||
|
||||
_Tp&
|
||||
operator[](const key_type& __key)
|
||||
{ return _M_ht.find_or_insert(value_type(__key, _Tp())).second; }
|
||||
|
||||
size_type
|
||||
count(const key_type& __key) const
|
||||
{ return _M_ht.count(__key); }
|
||||
|
||||
pair<iterator, iterator>
|
||||
equal_range(const key_type& __key)
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
pair<const_iterator, const_iterator>
|
||||
equal_range(const key_type& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
size_type
|
||||
erase(const key_type& __key)
|
||||
{return _M_ht.erase(__key); }
|
||||
|
||||
void
|
||||
erase(iterator __it)
|
||||
{ _M_ht.erase(__it); }
|
||||
|
||||
void
|
||||
erase(iterator __f, iterator __l)
|
||||
{ _M_ht.erase(__f, __l); }
|
||||
|
||||
void
|
||||
clear()
|
||||
{ _M_ht.clear(); }
|
||||
|
||||
void
|
||||
resize(size_type __hint)
|
||||
{ _M_ht.resize(__hint); }
|
||||
|
||||
size_type
|
||||
bucket_count() const
|
||||
{ return _M_ht.bucket_count(); }
|
||||
|
||||
size_type
|
||||
max_bucket_count() const
|
||||
{ return _M_ht.max_bucket_count(); }
|
||||
|
||||
size_type
|
||||
elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
|
||||
inline bool
|
||||
operator==(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
|
||||
const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
|
||||
{ return __hm1._M_ht == __hm2._M_ht; }
|
||||
|
||||
template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
|
||||
inline bool
|
||||
operator!=(const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
|
||||
const hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
|
||||
{ return !(__hm1 == __hm2); }
|
||||
|
||||
template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
|
||||
inline void
|
||||
swap(hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
|
||||
hash_map<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
|
||||
{ __hm1.swap(__hm2); }
|
||||
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<class _Key, class _Tp,
|
||||
class _HashFn = hash<_Key>,
|
||||
class _EqualKey = equal_to<_Key>,
|
||||
class _Alloc = allocator<_Tp> >
|
||||
class hash_multimap
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_class_requires(_Key, _SGIAssignableConcept)
|
||||
__glibcxx_class_requires(_Tp, _SGIAssignableConcept)
|
||||
__glibcxx_class_requires3(_HashFn, size_t, _Key, _UnaryFunctionConcept)
|
||||
__glibcxx_class_requires3(_EqualKey, _Key, _Key, _BinaryPredicateConcept)
|
||||
|
||||
private:
|
||||
typedef hashtable<pair<const _Key, _Tp>, _Key, _HashFn,
|
||||
_Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc>
|
||||
_Ht;
|
||||
|
||||
_Ht _M_ht;
|
||||
|
||||
public:
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef _Tp data_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Ht::pointer pointer;
|
||||
typedef typename _Ht::const_pointer const_pointer;
|
||||
typedef typename _Ht::reference reference;
|
||||
typedef typename _Ht::const_reference const_reference;
|
||||
|
||||
typedef typename _Ht::iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher
|
||||
hash_funct() const
|
||||
{ return _M_ht.hash_funct(); }
|
||||
|
||||
key_equal
|
||||
key_eq() const
|
||||
{ return _M_ht.key_eq(); }
|
||||
|
||||
allocator_type
|
||||
get_allocator() const
|
||||
{ return _M_ht.get_allocator(); }
|
||||
|
||||
hash_multimap()
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
|
||||
|
||||
explicit
|
||||
hash_multimap(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
|
||||
hash_multimap(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
|
||||
hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
size_type
|
||||
size() const
|
||||
{ return _M_ht.size(); }
|
||||
|
||||
size_type
|
||||
max_size() const
|
||||
{ return _M_ht.max_size(); }
|
||||
|
||||
bool
|
||||
empty() const
|
||||
{ return _M_ht.empty(); }
|
||||
|
||||
void
|
||||
swap(hash_multimap& __hs)
|
||||
{ _M_ht.swap(__hs._M_ht); }
|
||||
|
||||
template<class _K1, class _T1, class _HF, class _EqK, class _Al>
|
||||
friend bool
|
||||
operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,
|
||||
const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);
|
||||
|
||||
iterator
|
||||
begin()
|
||||
{ return _M_ht.begin(); }
|
||||
|
||||
iterator
|
||||
end()
|
||||
{ return _M_ht.end(); }
|
||||
|
||||
const_iterator
|
||||
begin() const
|
||||
{ return _M_ht.begin(); }
|
||||
|
||||
const_iterator
|
||||
end() const
|
||||
{ return _M_ht.end(); }
|
||||
|
||||
iterator
|
||||
insert(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal(__obj); }
|
||||
|
||||
template<class _InputIterator>
|
||||
void
|
||||
insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_equal(__f,__l); }
|
||||
|
||||
iterator
|
||||
insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal_noresize(__obj); }
|
||||
|
||||
iterator
|
||||
find(const key_type& __key)
|
||||
{ return _M_ht.find(__key); }
|
||||
|
||||
const_iterator
|
||||
find(const key_type& __key) const
|
||||
{ return _M_ht.find(__key); }
|
||||
|
||||
size_type
|
||||
count(const key_type& __key) const
|
||||
{ return _M_ht.count(__key); }
|
||||
|
||||
pair<iterator, iterator>
|
||||
equal_range(const key_type& __key)
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
pair<const_iterator, const_iterator>
|
||||
equal_range(const key_type& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
size_type
|
||||
erase(const key_type& __key)
|
||||
{ return _M_ht.erase(__key); }
|
||||
|
||||
void
|
||||
erase(iterator __it)
|
||||
{ _M_ht.erase(__it); }
|
||||
|
||||
void
|
||||
erase(iterator __f, iterator __l)
|
||||
{ _M_ht.erase(__f, __l); }
|
||||
|
||||
void
|
||||
clear()
|
||||
{ _M_ht.clear(); }
|
||||
|
||||
void
|
||||
resize(size_type __hint)
|
||||
{ _M_ht.resize(__hint); }
|
||||
|
||||
size_type
|
||||
bucket_count() const
|
||||
{ return _M_ht.bucket_count(); }
|
||||
|
||||
size_type
|
||||
max_bucket_count() const
|
||||
{ return _M_ht.max_bucket_count(); }
|
||||
|
||||
size_type
|
||||
elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
template<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
|
||||
inline bool
|
||||
operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
|
||||
const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
|
||||
{ return __hm1._M_ht == __hm2._M_ht; }
|
||||
|
||||
template<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
|
||||
inline bool
|
||||
operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
|
||||
const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
|
||||
{ return !(__hm1 == __hm2); }
|
||||
|
||||
template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
|
||||
inline void
|
||||
swap(hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
|
||||
hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
|
||||
{ __hm1.swap(__hm2); }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
namespace std _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
// Specialization of insert_iterator so that it will work for hash_map
|
||||
// and hash_multimap.
|
||||
template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
||||
class insert_iterator<__gnu_cxx::hash_map<_Key, _Tp, _HashFn,
|
||||
_EqKey, _Alloc> >
|
||||
{
|
||||
protected:
|
||||
typedef __gnu_cxx::hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>
|
||||
_Container;
|
||||
_Container* container;
|
||||
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
insert_iterator(_Container& __x)
|
||||
: container(&__x) {}
|
||||
|
||||
insert_iterator(_Container& __x, typename _Container::iterator)
|
||||
: container(&__x) {}
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator=(const typename _Container::value_type& __value)
|
||||
{
|
||||
container->insert(__value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator*()
|
||||
{ return *this; }
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator++() { return *this; }
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator++(int)
|
||||
{ return *this; }
|
||||
};
|
||||
|
||||
template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
|
||||
class insert_iterator<__gnu_cxx::hash_multimap<_Key, _Tp, _HashFn,
|
||||
_EqKey, _Alloc> >
|
||||
{
|
||||
protected:
|
||||
typedef __gnu_cxx::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc>
|
||||
_Container;
|
||||
_Container* container;
|
||||
typename _Container::iterator iter;
|
||||
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
insert_iterator(_Container& __x)
|
||||
: container(&__x) {}
|
||||
|
||||
insert_iterator(_Container& __x, typename _Container::iterator)
|
||||
: container(&__x) {}
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator=(const typename _Container::value_type& __value)
|
||||
{
|
||||
container->insert(__value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator*()
|
||||
{ return *this; }
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator++()
|
||||
{ return *this; }
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator++(int)
|
||||
{ return *this; }
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
567
openflow/usr/include/c++/5/ext/hash_set
Normal file
567
openflow/usr/include/c++/5/ext/hash_set
Normal file
@@ -0,0 +1,567 @@
|
||||
// Hashing set implementation -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Hewlett-Packard Company makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file backward/hash_set
|
||||
* This file is a GNU extension to the Standard C++ Library (possibly
|
||||
* containing extensions from the HP/SGI STL subset).
|
||||
*/
|
||||
|
||||
#ifndef _BACKWARD_HASH_SET
|
||||
#define _BACKWARD_HASH_SET 1
|
||||
|
||||
#ifndef _GLIBCXX_PERMIT_BACKWARD_HASH
|
||||
#include "backward_warning.h"
|
||||
#endif
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#include <backward/hashtable.h>
|
||||
#include <bits/concept_check.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::equal_to;
|
||||
using std::allocator;
|
||||
using std::pair;
|
||||
using std::_Identity;
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<class _Value, class _HashFcn = hash<_Value>,
|
||||
class _EqualKey = equal_to<_Value>,
|
||||
class _Alloc = allocator<_Value> >
|
||||
class hash_set
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_class_requires(_Value, _SGIAssignableConcept)
|
||||
__glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept)
|
||||
__glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
|
||||
|
||||
private:
|
||||
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
|
||||
_EqualKey, _Alloc> _Ht;
|
||||
_Ht _M_ht;
|
||||
|
||||
public:
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Alloc::pointer pointer;
|
||||
typedef typename _Alloc::const_pointer const_pointer;
|
||||
typedef typename _Alloc::reference reference;
|
||||
typedef typename _Alloc::const_reference const_reference;
|
||||
|
||||
typedef typename _Ht::const_iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher
|
||||
hash_funct() const
|
||||
{ return _M_ht.hash_funct(); }
|
||||
|
||||
key_equal
|
||||
key_eq() const
|
||||
{ return _M_ht.key_eq(); }
|
||||
|
||||
allocator_type
|
||||
get_allocator() const
|
||||
{ return _M_ht.get_allocator(); }
|
||||
|
||||
hash_set()
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
|
||||
|
||||
explicit
|
||||
hash_set(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
|
||||
hash_set(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
|
||||
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
size_type
|
||||
size() const
|
||||
{ return _M_ht.size(); }
|
||||
|
||||
size_type
|
||||
max_size() const
|
||||
{ return _M_ht.max_size(); }
|
||||
|
||||
bool
|
||||
empty() const
|
||||
{ return _M_ht.empty(); }
|
||||
|
||||
void
|
||||
swap(hash_set& __hs)
|
||||
{ _M_ht.swap(__hs._M_ht); }
|
||||
|
||||
template<class _Val, class _HF, class _EqK, class _Al>
|
||||
friend bool
|
||||
operator==(const hash_set<_Val, _HF, _EqK, _Al>&,
|
||||
const hash_set<_Val, _HF, _EqK, _Al>&);
|
||||
|
||||
iterator
|
||||
begin() const
|
||||
{ return _M_ht.begin(); }
|
||||
|
||||
iterator
|
||||
end() const
|
||||
{ return _M_ht.end(); }
|
||||
|
||||
pair<iterator, bool>
|
||||
insert(const value_type& __obj)
|
||||
{
|
||||
pair<typename _Ht::iterator, bool> __p = _M_ht.insert_unique(__obj);
|
||||
return pair<iterator,bool>(__p.first, __p.second);
|
||||
}
|
||||
|
||||
template<class _InputIterator>
|
||||
void
|
||||
insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_unique(__f, __l); }
|
||||
|
||||
pair<iterator, bool>
|
||||
insert_noresize(const value_type& __obj)
|
||||
{
|
||||
pair<typename _Ht::iterator, bool> __p
|
||||
= _M_ht.insert_unique_noresize(__obj);
|
||||
return pair<iterator, bool>(__p.first, __p.second);
|
||||
}
|
||||
|
||||
iterator
|
||||
find(const key_type& __key) const
|
||||
{ return _M_ht.find(__key); }
|
||||
|
||||
size_type
|
||||
count(const key_type& __key) const
|
||||
{ return _M_ht.count(__key); }
|
||||
|
||||
pair<iterator, iterator>
|
||||
equal_range(const key_type& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
size_type
|
||||
erase(const key_type& __key)
|
||||
{return _M_ht.erase(__key); }
|
||||
|
||||
void
|
||||
erase(iterator __it)
|
||||
{ _M_ht.erase(__it); }
|
||||
|
||||
void
|
||||
erase(iterator __f, iterator __l)
|
||||
{ _M_ht.erase(__f, __l); }
|
||||
|
||||
void
|
||||
clear()
|
||||
{ _M_ht.clear(); }
|
||||
|
||||
void
|
||||
resize(size_type __hint)
|
||||
{ _M_ht.resize(__hint); }
|
||||
|
||||
size_type
|
||||
bucket_count() const
|
||||
{ return _M_ht.bucket_count(); }
|
||||
|
||||
size_type
|
||||
max_bucket_count() const
|
||||
{ return _M_ht.max_bucket_count(); }
|
||||
|
||||
size_type
|
||||
elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
template<class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline bool
|
||||
operator==(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
|
||||
const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
|
||||
{ return __hs1._M_ht == __hs2._M_ht; }
|
||||
|
||||
template<class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline bool
|
||||
operator!=(const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
|
||||
const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
|
||||
{ return !(__hs1 == __hs2); }
|
||||
|
||||
template<class _Val, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline void
|
||||
swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
|
||||
hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
|
||||
{ __hs1.swap(__hs2); }
|
||||
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<class _Value,
|
||||
class _HashFcn = hash<_Value>,
|
||||
class _EqualKey = equal_to<_Value>,
|
||||
class _Alloc = allocator<_Value> >
|
||||
class hash_multiset
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_class_requires(_Value, _SGIAssignableConcept)
|
||||
__glibcxx_class_requires3(_HashFcn, size_t, _Value, _UnaryFunctionConcept)
|
||||
__glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
|
||||
|
||||
private:
|
||||
typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
|
||||
_EqualKey, _Alloc> _Ht;
|
||||
_Ht _M_ht;
|
||||
|
||||
public:
|
||||
typedef typename _Ht::key_type key_type;
|
||||
typedef typename _Ht::value_type value_type;
|
||||
typedef typename _Ht::hasher hasher;
|
||||
typedef typename _Ht::key_equal key_equal;
|
||||
|
||||
typedef typename _Ht::size_type size_type;
|
||||
typedef typename _Ht::difference_type difference_type;
|
||||
typedef typename _Alloc::pointer pointer;
|
||||
typedef typename _Alloc::const_pointer const_pointer;
|
||||
typedef typename _Alloc::reference reference;
|
||||
typedef typename _Alloc::const_reference const_reference;
|
||||
|
||||
typedef typename _Ht::const_iterator iterator;
|
||||
typedef typename _Ht::const_iterator const_iterator;
|
||||
|
||||
typedef typename _Ht::allocator_type allocator_type;
|
||||
|
||||
hasher
|
||||
hash_funct() const
|
||||
{ return _M_ht.hash_funct(); }
|
||||
|
||||
key_equal
|
||||
key_eq() const
|
||||
{ return _M_ht.key_eq(); }
|
||||
|
||||
allocator_type
|
||||
get_allocator() const
|
||||
{ return _M_ht.get_allocator(); }
|
||||
|
||||
hash_multiset()
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type()) {}
|
||||
|
||||
explicit
|
||||
hash_multiset(size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
|
||||
|
||||
hash_multiset(size_type __n, const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type()) {}
|
||||
|
||||
hash_multiset(size_type __n, const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a) {}
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l)
|
||||
: _M_ht(100, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
|
||||
: _M_ht(__n, hasher(), key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf)
|
||||
: _M_ht(__n, __hf, key_equal(), allocator_type())
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
template<class _InputIterator>
|
||||
hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
|
||||
const hasher& __hf, const key_equal& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_ht(__n, __hf, __eql, __a)
|
||||
{ _M_ht.insert_equal(__f, __l); }
|
||||
|
||||
size_type
|
||||
size() const
|
||||
{ return _M_ht.size(); }
|
||||
|
||||
size_type
|
||||
max_size() const
|
||||
{ return _M_ht.max_size(); }
|
||||
|
||||
bool
|
||||
empty() const
|
||||
{ return _M_ht.empty(); }
|
||||
|
||||
void
|
||||
swap(hash_multiset& hs)
|
||||
{ _M_ht.swap(hs._M_ht); }
|
||||
|
||||
template<class _Val, class _HF, class _EqK, class _Al>
|
||||
friend bool
|
||||
operator==(const hash_multiset<_Val, _HF, _EqK, _Al>&,
|
||||
const hash_multiset<_Val, _HF, _EqK, _Al>&);
|
||||
|
||||
iterator
|
||||
begin() const
|
||||
{ return _M_ht.begin(); }
|
||||
|
||||
iterator
|
||||
end() const
|
||||
{ return _M_ht.end(); }
|
||||
|
||||
iterator
|
||||
insert(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal(__obj); }
|
||||
|
||||
template<class _InputIterator>
|
||||
void
|
||||
insert(_InputIterator __f, _InputIterator __l)
|
||||
{ _M_ht.insert_equal(__f,__l); }
|
||||
|
||||
iterator
|
||||
insert_noresize(const value_type& __obj)
|
||||
{ return _M_ht.insert_equal_noresize(__obj); }
|
||||
|
||||
iterator
|
||||
find(const key_type& __key) const
|
||||
{ return _M_ht.find(__key); }
|
||||
|
||||
size_type
|
||||
count(const key_type& __key) const
|
||||
{ return _M_ht.count(__key); }
|
||||
|
||||
pair<iterator, iterator>
|
||||
equal_range(const key_type& __key) const
|
||||
{ return _M_ht.equal_range(__key); }
|
||||
|
||||
size_type
|
||||
erase(const key_type& __key)
|
||||
{ return _M_ht.erase(__key); }
|
||||
|
||||
void
|
||||
erase(iterator __it)
|
||||
{ _M_ht.erase(__it); }
|
||||
|
||||
void
|
||||
erase(iterator __f, iterator __l)
|
||||
{ _M_ht.erase(__f, __l); }
|
||||
|
||||
void
|
||||
clear()
|
||||
{ _M_ht.clear(); }
|
||||
|
||||
void
|
||||
resize(size_type __hint)
|
||||
{ _M_ht.resize(__hint); }
|
||||
|
||||
size_type
|
||||
bucket_count() const
|
||||
{ return _M_ht.bucket_count(); }
|
||||
|
||||
size_type
|
||||
max_bucket_count() const
|
||||
{ return _M_ht.max_bucket_count(); }
|
||||
|
||||
size_type
|
||||
elems_in_bucket(size_type __n) const
|
||||
{ return _M_ht.elems_in_bucket(__n); }
|
||||
};
|
||||
|
||||
template<class _Val, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline bool
|
||||
operator==(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
|
||||
const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
|
||||
{ return __hs1._M_ht == __hs2._M_ht; }
|
||||
|
||||
template<class _Val, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline bool
|
||||
operator!=(const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
|
||||
const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
|
||||
{ return !(__hs1 == __hs2); }
|
||||
|
||||
template<class _Val, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
inline void
|
||||
swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
|
||||
hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
|
||||
{ __hs1.swap(__hs2); }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
namespace std _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
// Specialization of insert_iterator so that it will work for hash_set
|
||||
// and hash_multiset.
|
||||
template<class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn,
|
||||
_EqualKey, _Alloc> >
|
||||
{
|
||||
protected:
|
||||
typedef __gnu_cxx::hash_set<_Value, _HashFcn, _EqualKey, _Alloc>
|
||||
_Container;
|
||||
_Container* container;
|
||||
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
insert_iterator(_Container& __x)
|
||||
: container(&__x) {}
|
||||
|
||||
insert_iterator(_Container& __x, typename _Container::iterator)
|
||||
: container(&__x) {}
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator=(const typename _Container::value_type& __value)
|
||||
{
|
||||
container->insert(__value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator*()
|
||||
{ return *this; }
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator++()
|
||||
{ return *this; }
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator++(int)
|
||||
{ return *this; }
|
||||
};
|
||||
|
||||
template<class _Value, class _HashFcn, class _EqualKey, class _Alloc>
|
||||
class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn,
|
||||
_EqualKey, _Alloc> >
|
||||
{
|
||||
protected:
|
||||
typedef __gnu_cxx::hash_multiset<_Value, _HashFcn, _EqualKey, _Alloc>
|
||||
_Container;
|
||||
_Container* container;
|
||||
typename _Container::iterator iter;
|
||||
|
||||
public:
|
||||
typedef _Container container_type;
|
||||
typedef output_iterator_tag iterator_category;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
|
||||
insert_iterator(_Container& __x)
|
||||
: container(&__x) {}
|
||||
|
||||
insert_iterator(_Container& __x, typename _Container::iterator)
|
||||
: container(&__x) {}
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator=(const typename _Container::value_type& __value)
|
||||
{
|
||||
container->insert(__value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator*()
|
||||
{ return *this; }
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator++()
|
||||
{ return *this; }
|
||||
|
||||
insert_iterator<_Container>&
|
||||
operator++(int) { return *this; }
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
116
openflow/usr/include/c++/5/ext/iterator
Normal file
116
openflow/usr/include/c++/5/ext/iterator
Normal file
@@ -0,0 +1,116 @@
|
||||
// HP/SGI iterator extensions -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Hewlett-Packard Company makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1996-1998
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/** @file ext/iterator
|
||||
* This file is a GNU extension to the Standard C++ Library (possibly
|
||||
* containing extensions from the HP/SGI STL subset).
|
||||
*/
|
||||
|
||||
#ifndef _EXT_ITERATOR
|
||||
#define _EXT_ITERATOR 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <bits/concept_check.h>
|
||||
#include <iterator>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
// There are two signatures for distance. In addition to the one
|
||||
// taking two iterators and returning a result, there is another
|
||||
// taking two iterators and a reference-to-result variable, and
|
||||
// returning nothing. The latter seems to be an SGI extension.
|
||||
// -- pedwards
|
||||
template<typename _InputIterator, typename _Distance>
|
||||
inline void
|
||||
__distance(_InputIterator __first, _InputIterator __last,
|
||||
_Distance& __n, std::input_iterator_tag)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
|
||||
while (__first != __last)
|
||||
{
|
||||
++__first;
|
||||
++__n;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _RandomAccessIterator, typename _Distance>
|
||||
inline void
|
||||
__distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
_Distance& __n, std::random_access_iterator_tag)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_RandomAccessIteratorConcept<
|
||||
_RandomAccessIterator>)
|
||||
__n += __last - __first;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _InputIterator, typename _Distance>
|
||||
inline void
|
||||
distance(_InputIterator __first, _InputIterator __last,
|
||||
_Distance& __n)
|
||||
{
|
||||
// concept requirements -- taken care of in __distance
|
||||
__distance(__first, __last, __n, std::__iterator_category(__first));
|
||||
}
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
152
openflow/usr/include/c++/5/ext/malloc_allocator.h
Normal file
152
openflow/usr/include/c++/5/ext/malloc_allocator.h
Normal file
@@ -0,0 +1,152 @@
|
||||
// Allocator that wraps "C" malloc -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/malloc_allocator.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _MALLOC_ALLOCATOR_H
|
||||
#define _MALLOC_ALLOCATOR_H 1
|
||||
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
#include <bits/functexcept.h>
|
||||
#include <bits/move.h>
|
||||
#if __cplusplus >= 201103L
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::size_t;
|
||||
using std::ptrdiff_t;
|
||||
|
||||
/**
|
||||
* @brief An allocator that uses malloc.
|
||||
* @ingroup allocators
|
||||
*
|
||||
* This is precisely the allocator defined in the C++ Standard.
|
||||
* - all allocation calls malloc
|
||||
* - all deallocation calls free
|
||||
*/
|
||||
template<typename _Tp>
|
||||
class malloc_allocator
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
|
||||
template<typename _Tp1>
|
||||
struct rebind
|
||||
{ typedef malloc_allocator<_Tp1> other; };
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 2103. propagate_on_container_move_assignment
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
#endif
|
||||
|
||||
malloc_allocator() _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
malloc_allocator(const malloc_allocator&) _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
template<typename _Tp1>
|
||||
malloc_allocator(const malloc_allocator<_Tp1>&)
|
||||
_GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
~malloc_allocator() _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
pointer
|
||||
address(reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
const_pointer
|
||||
address(const_reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
// NB: __n is permitted to be 0. The C++ standard says nothing
|
||||
// about what the return value is when __n == 0.
|
||||
pointer
|
||||
allocate(size_type __n, const void* = 0)
|
||||
{
|
||||
if (__n > this->max_size())
|
||||
std::__throw_bad_alloc();
|
||||
|
||||
pointer __ret = static_cast<_Tp*>(std::malloc(__n * sizeof(_Tp)));
|
||||
if (!__ret)
|
||||
std::__throw_bad_alloc();
|
||||
return __ret;
|
||||
}
|
||||
|
||||
// __p is not permitted to be a null pointer.
|
||||
void
|
||||
deallocate(pointer __p, size_type)
|
||||
{ std::free(static_cast<void*>(__p)); }
|
||||
|
||||
size_type
|
||||
max_size() const _GLIBCXX_USE_NOEXCEPT
|
||||
{ return size_t(-1) / sizeof(_Tp); }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _Up, typename... _Args>
|
||||
void
|
||||
construct(_Up* __p, _Args&&... __args)
|
||||
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
|
||||
|
||||
template<typename _Up>
|
||||
void
|
||||
destroy(_Up* __p) { __p->~_Up(); }
|
||||
#else
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 402. wrong new expression in [some_] allocator::construct
|
||||
void
|
||||
construct(pointer __p, const _Tp& __val)
|
||||
{ ::new((void *)__p) value_type(__val); }
|
||||
|
||||
void
|
||||
destroy(pointer __p) { __p->~_Tp(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
inline bool
|
||||
operator==(const malloc_allocator<_Tp>&, const malloc_allocator<_Tp>&)
|
||||
{ return true; }
|
||||
|
||||
template<typename _Tp>
|
||||
inline bool
|
||||
operator!=(const malloc_allocator<_Tp>&, const malloc_allocator<_Tp>&)
|
||||
{ return false; }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
197
openflow/usr/include/c++/5/ext/memory
Normal file
197
openflow/usr/include/c++/5/ext/memory
Normal file
@@ -0,0 +1,197 @@
|
||||
// Memory extensions -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Hewlett-Packard Company makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1996
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/** @file ext/memory
|
||||
* This file is a GNU extension to the Standard C++ Library (possibly
|
||||
* containing extensions from the HP/SGI STL subset).
|
||||
*/
|
||||
|
||||
#ifndef _EXT_MEMORY
|
||||
#define _EXT_MEMORY 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <memory>
|
||||
#include <bits/stl_tempbuf.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::ptrdiff_t;
|
||||
using std::pair;
|
||||
using std::__iterator_category;
|
||||
using std::_Temporary_buffer;
|
||||
|
||||
template<typename _InputIter, typename _Size, typename _ForwardIter>
|
||||
pair<_InputIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
_ForwardIter __result, std::input_iterator_tag)
|
||||
{
|
||||
_ForwardIter __cur = __result;
|
||||
__try
|
||||
{
|
||||
for (; __count > 0 ; --__count, ++__first, ++__cur)
|
||||
std::_Construct(&*__cur, *__first);
|
||||
return pair<_InputIter, _ForwardIter>(__first, __cur);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
std::_Destroy(__result, __cur);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
|
||||
inline pair<_RandomAccessIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
|
||||
_ForwardIter __result,
|
||||
std::random_access_iterator_tag)
|
||||
{
|
||||
_RandomAccessIter __last = __first + __count;
|
||||
return (pair<_RandomAccessIter, _ForwardIter>
|
||||
(__last, std::uninitialized_copy(__first, __last, __result)));
|
||||
}
|
||||
|
||||
template<typename _InputIter, typename _Size, typename _ForwardIter>
|
||||
inline pair<_InputIter, _ForwardIter>
|
||||
__uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
_ForwardIter __result)
|
||||
{ return __gnu_cxx::__uninitialized_copy_n(__first, __count, __result,
|
||||
__iterator_category(__first)); }
|
||||
|
||||
/**
|
||||
* @brief Copies the range [first,last) into result.
|
||||
* @param __first An input iterator.
|
||||
* @param __count Length
|
||||
* @param __result An output iterator.
|
||||
* @return __result + (__first + __count)
|
||||
* @ingroup SGIextensions
|
||||
*
|
||||
* Like copy(), but does not require an initialized output range.
|
||||
*/
|
||||
template<typename _InputIter, typename _Size, typename _ForwardIter>
|
||||
inline pair<_InputIter, _ForwardIter>
|
||||
uninitialized_copy_n(_InputIter __first, _Size __count,
|
||||
_ForwardIter __result)
|
||||
{ return __gnu_cxx::__uninitialized_copy_n(__first, __count, __result,
|
||||
__iterator_category(__first)); }
|
||||
|
||||
|
||||
// An alternative version of uninitialized_copy_n that constructs
|
||||
// and destroys objects with a user-provided allocator.
|
||||
template<typename _InputIter, typename _Size, typename _ForwardIter,
|
||||
typename _Allocator>
|
||||
pair<_InputIter, _ForwardIter>
|
||||
__uninitialized_copy_n_a(_InputIter __first, _Size __count,
|
||||
_ForwardIter __result,
|
||||
_Allocator __alloc)
|
||||
{
|
||||
_ForwardIter __cur = __result;
|
||||
__try
|
||||
{
|
||||
for (; __count > 0 ; --__count, ++__first, ++__cur)
|
||||
__alloc.construct(&*__cur, *__first);
|
||||
return pair<_InputIter, _ForwardIter>(__first, __cur);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
std::_Destroy(__result, __cur, __alloc);
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _InputIter, typename _Size, typename _ForwardIter,
|
||||
typename _Tp>
|
||||
inline pair<_InputIter, _ForwardIter>
|
||||
__uninitialized_copy_n_a(_InputIter __first, _Size __count,
|
||||
_ForwardIter __result,
|
||||
std::allocator<_Tp>)
|
||||
{
|
||||
return __gnu_cxx::uninitialized_copy_n(__first, __count, __result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides similar behavior and semantics of the standard
|
||||
* functions get_temporary_buffer() and return_temporary_buffer(), but
|
||||
* encapsulated in a type vaguely resembling a standard container.
|
||||
*
|
||||
* By default, a temporary_buffer<Iter> stores space for objects of
|
||||
* whatever type the Iter iterator points to. It is constructed from a
|
||||
* typical [first,last) range, and provides the begin(), end(), size()
|
||||
* functions, as well as requested_size(). For non-trivial types, copies
|
||||
* of *first will be used to initialize the storage.
|
||||
*
|
||||
* @c malloc is used to obtain underlying storage.
|
||||
*
|
||||
* Like get_temporary_buffer(), not all the requested memory may be
|
||||
* available. Ideally, the created buffer will be large enough to hold a
|
||||
* copy of [first,last), but if size() is less than requested_size(),
|
||||
* then this didn't happen.
|
||||
*
|
||||
* @ingroup SGIextensions
|
||||
*/
|
||||
template <class _ForwardIterator, class _Tp
|
||||
= typename std::iterator_traits<_ForwardIterator>::value_type >
|
||||
struct temporary_buffer : public _Temporary_buffer<_ForwardIterator, _Tp>
|
||||
{
|
||||
/// Requests storage large enough to hold a copy of [first,last).
|
||||
temporary_buffer(_ForwardIterator __first, _ForwardIterator __last)
|
||||
: _Temporary_buffer<_ForwardIterator, _Tp>(__first, __last) { }
|
||||
|
||||
/// Destroys objects and frees storage.
|
||||
~temporary_buffer() { }
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
||||
766
openflow/usr/include/c++/5/ext/mt_allocator.h
Normal file
766
openflow/usr/include/c++/5/ext/mt_allocator.h
Normal file
@@ -0,0 +1,766 @@
|
||||
// MT-optimized allocator -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2003-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/mt_allocator.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _MT_ALLOCATOR_H
|
||||
#define _MT_ALLOCATOR_H 1
|
||||
|
||||
#include <new>
|
||||
#include <cstdlib>
|
||||
#include <bits/functexcept.h>
|
||||
#include <ext/atomicity.h>
|
||||
#include <bits/move.h>
|
||||
#if __cplusplus >= 201103L
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::size_t;
|
||||
using std::ptrdiff_t;
|
||||
|
||||
typedef void (*__destroy_handler)(void*);
|
||||
|
||||
/// Base class for pool object.
|
||||
struct __pool_base
|
||||
{
|
||||
// Using short int as type for the binmap implies we are never
|
||||
// caching blocks larger than 32768 with this allocator.
|
||||
typedef unsigned short int _Binmap_type;
|
||||
|
||||
// Variables used to configure the behavior of the allocator,
|
||||
// assigned and explained in detail below.
|
||||
struct _Tune
|
||||
{
|
||||
// Compile time constants for the default _Tune values.
|
||||
enum { _S_align = 8 };
|
||||
enum { _S_max_bytes = 128 };
|
||||
enum { _S_min_bin = 8 };
|
||||
enum { _S_chunk_size = 4096 - 4 * sizeof(void*) };
|
||||
enum { _S_max_threads = 4096 };
|
||||
enum { _S_freelist_headroom = 10 };
|
||||
|
||||
// Alignment needed.
|
||||
// NB: In any case must be >= sizeof(_Block_record), that
|
||||
// is 4 on 32 bit machines and 8 on 64 bit machines.
|
||||
size_t _M_align;
|
||||
|
||||
// Allocation requests (after round-up to power of 2) below
|
||||
// this value will be handled by the allocator. A raw new/
|
||||
// call will be used for requests larger than this value.
|
||||
// NB: Must be much smaller than _M_chunk_size and in any
|
||||
// case <= 32768.
|
||||
size_t _M_max_bytes;
|
||||
|
||||
// Size in bytes of the smallest bin.
|
||||
// NB: Must be a power of 2 and >= _M_align (and of course
|
||||
// much smaller than _M_max_bytes).
|
||||
size_t _M_min_bin;
|
||||
|
||||
// In order to avoid fragmenting and minimize the number of
|
||||
// new() calls we always request new memory using this
|
||||
// value. Based on previous discussions on the libstdc++
|
||||
// mailing list we have chosen the value below.
|
||||
// See http://gcc.gnu.org/ml/libstdc++/2001-07/msg00077.html
|
||||
// NB: At least one order of magnitude > _M_max_bytes.
|
||||
size_t _M_chunk_size;
|
||||
|
||||
// The maximum number of supported threads. For
|
||||
// single-threaded operation, use one. Maximum values will
|
||||
// vary depending on details of the underlying system. (For
|
||||
// instance, Linux 2.4.18 reports 4070 in
|
||||
// /proc/sys/kernel/threads-max, while Linux 2.6.6 reports
|
||||
// 65534)
|
||||
size_t _M_max_threads;
|
||||
|
||||
// Each time a deallocation occurs in a threaded application
|
||||
// we make sure that there are no more than
|
||||
// _M_freelist_headroom % of used memory on the freelist. If
|
||||
// the number of additional records is more than
|
||||
// _M_freelist_headroom % of the freelist, we move these
|
||||
// records back to the global pool.
|
||||
size_t _M_freelist_headroom;
|
||||
|
||||
// Set to true forces all allocations to use new().
|
||||
bool _M_force_new;
|
||||
|
||||
explicit
|
||||
_Tune()
|
||||
: _M_align(_S_align), _M_max_bytes(_S_max_bytes), _M_min_bin(_S_min_bin),
|
||||
_M_chunk_size(_S_chunk_size), _M_max_threads(_S_max_threads),
|
||||
_M_freelist_headroom(_S_freelist_headroom),
|
||||
_M_force_new(std::getenv("GLIBCXX_FORCE_NEW") ? true : false)
|
||||
{ }
|
||||
|
||||
explicit
|
||||
_Tune(size_t __align, size_t __maxb, size_t __minbin, size_t __chunk,
|
||||
size_t __maxthreads, size_t __headroom, bool __force)
|
||||
: _M_align(__align), _M_max_bytes(__maxb), _M_min_bin(__minbin),
|
||||
_M_chunk_size(__chunk), _M_max_threads(__maxthreads),
|
||||
_M_freelist_headroom(__headroom), _M_force_new(__force)
|
||||
{ }
|
||||
};
|
||||
|
||||
struct _Block_address
|
||||
{
|
||||
void* _M_initial;
|
||||
_Block_address* _M_next;
|
||||
};
|
||||
|
||||
const _Tune&
|
||||
_M_get_options() const
|
||||
{ return _M_options; }
|
||||
|
||||
void
|
||||
_M_set_options(_Tune __t)
|
||||
{
|
||||
if (!_M_init)
|
||||
_M_options = __t;
|
||||
}
|
||||
|
||||
bool
|
||||
_M_check_threshold(size_t __bytes)
|
||||
{ return __bytes > _M_options._M_max_bytes || _M_options._M_force_new; }
|
||||
|
||||
size_t
|
||||
_M_get_binmap(size_t __bytes)
|
||||
{ return _M_binmap[__bytes]; }
|
||||
|
||||
size_t
|
||||
_M_get_align()
|
||||
{ return _M_options._M_align; }
|
||||
|
||||
explicit
|
||||
__pool_base()
|
||||
: _M_options(_Tune()), _M_binmap(0), _M_init(false) { }
|
||||
|
||||
explicit
|
||||
__pool_base(const _Tune& __options)
|
||||
: _M_options(__options), _M_binmap(0), _M_init(false) { }
|
||||
|
||||
private:
|
||||
explicit
|
||||
__pool_base(const __pool_base&);
|
||||
|
||||
__pool_base&
|
||||
operator=(const __pool_base&);
|
||||
|
||||
protected:
|
||||
// Configuration options.
|
||||
_Tune _M_options;
|
||||
|
||||
_Binmap_type* _M_binmap;
|
||||
|
||||
// Configuration of the pool object via _M_options can happen
|
||||
// after construction but before initialization. After
|
||||
// initialization is complete, this variable is set to true.
|
||||
bool _M_init;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Data describing the underlying memory pool, parameterized on
|
||||
* threading support.
|
||||
*/
|
||||
template<bool _Thread>
|
||||
class __pool;
|
||||
|
||||
/// Specialization for single thread.
|
||||
template<>
|
||||
class __pool<false> : public __pool_base
|
||||
{
|
||||
public:
|
||||
union _Block_record
|
||||
{
|
||||
// Points to the block_record of the next free block.
|
||||
_Block_record* _M_next;
|
||||
};
|
||||
|
||||
struct _Bin_record
|
||||
{
|
||||
// An "array" of pointers to the first free block.
|
||||
_Block_record** _M_first;
|
||||
|
||||
// A list of the initial addresses of all allocated blocks.
|
||||
_Block_address* _M_address;
|
||||
};
|
||||
|
||||
void
|
||||
_M_initialize_once()
|
||||
{
|
||||
if (__builtin_expect(_M_init == false, false))
|
||||
_M_initialize();
|
||||
}
|
||||
|
||||
void
|
||||
_M_destroy() throw();
|
||||
|
||||
char*
|
||||
_M_reserve_block(size_t __bytes, const size_t __thread_id);
|
||||
|
||||
void
|
||||
_M_reclaim_block(char* __p, size_t __bytes) throw ();
|
||||
|
||||
size_t
|
||||
_M_get_thread_id() { return 0; }
|
||||
|
||||
const _Bin_record&
|
||||
_M_get_bin(size_t __which)
|
||||
{ return _M_bin[__which]; }
|
||||
|
||||
void
|
||||
_M_adjust_freelist(const _Bin_record&, _Block_record*, size_t)
|
||||
{ }
|
||||
|
||||
explicit __pool()
|
||||
: _M_bin(0), _M_bin_size(1) { }
|
||||
|
||||
explicit __pool(const __pool_base::_Tune& __tune)
|
||||
: __pool_base(__tune), _M_bin(0), _M_bin_size(1) { }
|
||||
|
||||
private:
|
||||
// An "array" of bin_records each of which represents a specific
|
||||
// power of 2 size. Memory to this "array" is allocated in
|
||||
// _M_initialize().
|
||||
_Bin_record* _M_bin;
|
||||
|
||||
// Actual value calculated in _M_initialize().
|
||||
size_t _M_bin_size;
|
||||
|
||||
void
|
||||
_M_initialize();
|
||||
};
|
||||
|
||||
#ifdef __GTHREADS
|
||||
/// Specialization for thread enabled, via gthreads.h.
|
||||
template<>
|
||||
class __pool<true> : public __pool_base
|
||||
{
|
||||
public:
|
||||
// Each requesting thread is assigned an id ranging from 1 to
|
||||
// _S_max_threads. Thread id 0 is used as a global memory pool.
|
||||
// In order to get constant performance on the thread assignment
|
||||
// routine, we keep a list of free ids. When a thread first
|
||||
// requests memory we remove the first record in this list and
|
||||
// stores the address in a __gthread_key. When initializing the
|
||||
// __gthread_key we specify a destructor. When this destructor
|
||||
// (i.e. the thread dies) is called, we return the thread id to
|
||||
// the front of this list.
|
||||
struct _Thread_record
|
||||
{
|
||||
// Points to next free thread id record. NULL if last record in list.
|
||||
_Thread_record* _M_next;
|
||||
|
||||
// Thread id ranging from 1 to _S_max_threads.
|
||||
size_t _M_id;
|
||||
};
|
||||
|
||||
union _Block_record
|
||||
{
|
||||
// Points to the block_record of the next free block.
|
||||
_Block_record* _M_next;
|
||||
|
||||
// The thread id of the thread which has requested this block.
|
||||
size_t _M_thread_id;
|
||||
};
|
||||
|
||||
struct _Bin_record
|
||||
{
|
||||
// An "array" of pointers to the first free block for each
|
||||
// thread id. Memory to this "array" is allocated in
|
||||
// _S_initialize() for _S_max_threads + global pool 0.
|
||||
_Block_record** _M_first;
|
||||
|
||||
// A list of the initial addresses of all allocated blocks.
|
||||
_Block_address* _M_address;
|
||||
|
||||
// An "array" of counters used to keep track of the amount of
|
||||
// blocks that are on the freelist/used for each thread id.
|
||||
// - Note that the second part of the allocated _M_used "array"
|
||||
// actually hosts (atomic) counters of reclaimed blocks: in
|
||||
// _M_reserve_block and in _M_reclaim_block those numbers are
|
||||
// subtracted from the first ones to obtain the actual size
|
||||
// of the "working set" of the given thread.
|
||||
// - Memory to these "arrays" is allocated in _S_initialize()
|
||||
// for _S_max_threads + global pool 0.
|
||||
size_t* _M_free;
|
||||
size_t* _M_used;
|
||||
|
||||
// Each bin has its own mutex which is used to ensure data
|
||||
// integrity while changing "ownership" on a block. The mutex
|
||||
// is initialized in _S_initialize().
|
||||
__gthread_mutex_t* _M_mutex;
|
||||
};
|
||||
|
||||
// XXX GLIBCXX_ABI Deprecated
|
||||
void
|
||||
_M_initialize(__destroy_handler);
|
||||
|
||||
void
|
||||
_M_initialize_once()
|
||||
{
|
||||
if (__builtin_expect(_M_init == false, false))
|
||||
_M_initialize();
|
||||
}
|
||||
|
||||
void
|
||||
_M_destroy() throw();
|
||||
|
||||
char*
|
||||
_M_reserve_block(size_t __bytes, const size_t __thread_id);
|
||||
|
||||
void
|
||||
_M_reclaim_block(char* __p, size_t __bytes) throw ();
|
||||
|
||||
const _Bin_record&
|
||||
_M_get_bin(size_t __which)
|
||||
{ return _M_bin[__which]; }
|
||||
|
||||
void
|
||||
_M_adjust_freelist(const _Bin_record& __bin, _Block_record* __block,
|
||||
size_t __thread_id)
|
||||
{
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
__block->_M_thread_id = __thread_id;
|
||||
--__bin._M_free[__thread_id];
|
||||
++__bin._M_used[__thread_id];
|
||||
}
|
||||
}
|
||||
|
||||
// XXX GLIBCXX_ABI Deprecated
|
||||
_GLIBCXX_CONST void
|
||||
_M_destroy_thread_key(void*) throw ();
|
||||
|
||||
size_t
|
||||
_M_get_thread_id();
|
||||
|
||||
explicit __pool()
|
||||
: _M_bin(0), _M_bin_size(1), _M_thread_freelist(0)
|
||||
{ }
|
||||
|
||||
explicit __pool(const __pool_base::_Tune& __tune)
|
||||
: __pool_base(__tune), _M_bin(0), _M_bin_size(1),
|
||||
_M_thread_freelist(0)
|
||||
{ }
|
||||
|
||||
private:
|
||||
// An "array" of bin_records each of which represents a specific
|
||||
// power of 2 size. Memory to this "array" is allocated in
|
||||
// _M_initialize().
|
||||
_Bin_record* _M_bin;
|
||||
|
||||
// Actual value calculated in _M_initialize().
|
||||
size_t _M_bin_size;
|
||||
|
||||
_Thread_record* _M_thread_freelist;
|
||||
void* _M_thread_freelist_initial;
|
||||
|
||||
void
|
||||
_M_initialize();
|
||||
};
|
||||
#endif
|
||||
|
||||
template<template <bool> class _PoolTp, bool _Thread>
|
||||
struct __common_pool
|
||||
{
|
||||
typedef _PoolTp<_Thread> pool_type;
|
||||
|
||||
static pool_type&
|
||||
_S_get_pool()
|
||||
{
|
||||
static pool_type _S_pool;
|
||||
return _S_pool;
|
||||
}
|
||||
};
|
||||
|
||||
template<template <bool> class _PoolTp, bool _Thread>
|
||||
struct __common_pool_base;
|
||||
|
||||
template<template <bool> class _PoolTp>
|
||||
struct __common_pool_base<_PoolTp, false>
|
||||
: public __common_pool<_PoolTp, false>
|
||||
{
|
||||
using __common_pool<_PoolTp, false>::_S_get_pool;
|
||||
|
||||
static void
|
||||
_S_initialize_once()
|
||||
{
|
||||
static bool __init;
|
||||
if (__builtin_expect(__init == false, false))
|
||||
{
|
||||
_S_get_pool()._M_initialize_once();
|
||||
__init = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __GTHREADS
|
||||
template<template <bool> class _PoolTp>
|
||||
struct __common_pool_base<_PoolTp, true>
|
||||
: public __common_pool<_PoolTp, true>
|
||||
{
|
||||
using __common_pool<_PoolTp, true>::_S_get_pool;
|
||||
|
||||
static void
|
||||
_S_initialize()
|
||||
{ _S_get_pool()._M_initialize_once(); }
|
||||
|
||||
static void
|
||||
_S_initialize_once()
|
||||
{
|
||||
static bool __init;
|
||||
if (__builtin_expect(__init == false, false))
|
||||
{
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
// On some platforms, __gthread_once_t is an aggregate.
|
||||
static __gthread_once_t __once = __GTHREAD_ONCE_INIT;
|
||||
__gthread_once(&__once, _S_initialize);
|
||||
}
|
||||
|
||||
// Double check initialization. May be necessary on some
|
||||
// systems for proper construction when not compiling with
|
||||
// thread flags.
|
||||
_S_get_pool()._M_initialize_once();
|
||||
__init = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/// Policy for shared __pool objects.
|
||||
template<template <bool> class _PoolTp, bool _Thread>
|
||||
struct __common_pool_policy : public __common_pool_base<_PoolTp, _Thread>
|
||||
{
|
||||
template<typename _Tp1, template <bool> class _PoolTp1 = _PoolTp,
|
||||
bool _Thread1 = _Thread>
|
||||
struct _M_rebind
|
||||
{ typedef __common_pool_policy<_PoolTp1, _Thread1> other; };
|
||||
|
||||
using __common_pool_base<_PoolTp, _Thread>::_S_get_pool;
|
||||
using __common_pool_base<_PoolTp, _Thread>::_S_initialize_once;
|
||||
};
|
||||
|
||||
|
||||
template<typename _Tp, template <bool> class _PoolTp, bool _Thread>
|
||||
struct __per_type_pool
|
||||
{
|
||||
typedef _Tp value_type;
|
||||
typedef _PoolTp<_Thread> pool_type;
|
||||
|
||||
static pool_type&
|
||||
_S_get_pool()
|
||||
{
|
||||
// Sane defaults for the _PoolTp.
|
||||
typedef typename pool_type::_Block_record _Block_record;
|
||||
const static size_t __a = (__alignof__(_Tp) >= sizeof(_Block_record)
|
||||
? __alignof__(_Tp) : sizeof(_Block_record));
|
||||
|
||||
typedef typename __pool_base::_Tune _Tune;
|
||||
static _Tune _S_tune(__a, sizeof(_Tp) * 64,
|
||||
sizeof(_Tp) * 2 >= __a ? sizeof(_Tp) * 2 : __a,
|
||||
sizeof(_Tp) * size_t(_Tune::_S_chunk_size),
|
||||
_Tune::_S_max_threads,
|
||||
_Tune::_S_freelist_headroom,
|
||||
std::getenv("GLIBCXX_FORCE_NEW") ? true : false);
|
||||
static pool_type _S_pool(_S_tune);
|
||||
return _S_pool;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename _Tp, template <bool> class _PoolTp, bool _Thread>
|
||||
struct __per_type_pool_base;
|
||||
|
||||
template<typename _Tp, template <bool> class _PoolTp>
|
||||
struct __per_type_pool_base<_Tp, _PoolTp, false>
|
||||
: public __per_type_pool<_Tp, _PoolTp, false>
|
||||
{
|
||||
using __per_type_pool<_Tp, _PoolTp, false>::_S_get_pool;
|
||||
|
||||
static void
|
||||
_S_initialize_once()
|
||||
{
|
||||
static bool __init;
|
||||
if (__builtin_expect(__init == false, false))
|
||||
{
|
||||
_S_get_pool()._M_initialize_once();
|
||||
__init = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef __GTHREADS
|
||||
template<typename _Tp, template <bool> class _PoolTp>
|
||||
struct __per_type_pool_base<_Tp, _PoolTp, true>
|
||||
: public __per_type_pool<_Tp, _PoolTp, true>
|
||||
{
|
||||
using __per_type_pool<_Tp, _PoolTp, true>::_S_get_pool;
|
||||
|
||||
static void
|
||||
_S_initialize()
|
||||
{ _S_get_pool()._M_initialize_once(); }
|
||||
|
||||
static void
|
||||
_S_initialize_once()
|
||||
{
|
||||
static bool __init;
|
||||
if (__builtin_expect(__init == false, false))
|
||||
{
|
||||
if (__gthread_active_p())
|
||||
{
|
||||
// On some platforms, __gthread_once_t is an aggregate.
|
||||
static __gthread_once_t __once = __GTHREAD_ONCE_INIT;
|
||||
__gthread_once(&__once, _S_initialize);
|
||||
}
|
||||
|
||||
// Double check initialization. May be necessary on some
|
||||
// systems for proper construction when not compiling with
|
||||
// thread flags.
|
||||
_S_get_pool()._M_initialize_once();
|
||||
__init = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/// Policy for individual __pool objects.
|
||||
template<typename _Tp, template <bool> class _PoolTp, bool _Thread>
|
||||
struct __per_type_pool_policy
|
||||
: public __per_type_pool_base<_Tp, _PoolTp, _Thread>
|
||||
{
|
||||
template<typename _Tp1, template <bool> class _PoolTp1 = _PoolTp,
|
||||
bool _Thread1 = _Thread>
|
||||
struct _M_rebind
|
||||
{ typedef __per_type_pool_policy<_Tp1, _PoolTp1, _Thread1> other; };
|
||||
|
||||
using __per_type_pool_base<_Tp, _PoolTp, _Thread>::_S_get_pool;
|
||||
using __per_type_pool_base<_Tp, _PoolTp, _Thread>::_S_initialize_once;
|
||||
};
|
||||
|
||||
|
||||
/// Base class for _Tp dependent member functions.
|
||||
template<typename _Tp>
|
||||
class __mt_alloc_base
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 2103. propagate_on_container_move_assignment
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
#endif
|
||||
|
||||
pointer
|
||||
address(reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
const_pointer
|
||||
address(const_reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
size_type
|
||||
max_size() const _GLIBCXX_USE_NOEXCEPT
|
||||
{ return size_t(-1) / sizeof(_Tp); }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _Up, typename... _Args>
|
||||
void
|
||||
construct(_Up* __p, _Args&&... __args)
|
||||
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
|
||||
|
||||
template<typename _Up>
|
||||
void
|
||||
destroy(_Up* __p) { __p->~_Up(); }
|
||||
#else
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 402. wrong new expression in [some_] allocator::construct
|
||||
void
|
||||
construct(pointer __p, const _Tp& __val)
|
||||
{ ::new((void *)__p) _Tp(__val); }
|
||||
|
||||
void
|
||||
destroy(pointer __p) { __p->~_Tp(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __GTHREADS
|
||||
#define __thread_default true
|
||||
#else
|
||||
#define __thread_default false
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This is a fixed size (power of 2) allocator which - when
|
||||
* compiled with thread support - will maintain one freelist per
|
||||
* size per thread plus a @a global one. Steps are taken to limit
|
||||
* the per thread freelist sizes (by returning excess back to
|
||||
* the @a global list).
|
||||
* @ingroup allocators
|
||||
*
|
||||
* Further details:
|
||||
* https://gcc.gnu.org/onlinedocs/libstdc++/manual/mt_allocator.html
|
||||
*/
|
||||
template<typename _Tp,
|
||||
typename _Poolp = __common_pool_policy<__pool, __thread_default> >
|
||||
class __mt_alloc : public __mt_alloc_base<_Tp>
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
typedef _Poolp __policy_type;
|
||||
typedef typename _Poolp::pool_type __pool_type;
|
||||
|
||||
template<typename _Tp1, typename _Poolp1 = _Poolp>
|
||||
struct rebind
|
||||
{
|
||||
typedef typename _Poolp1::template _M_rebind<_Tp1>::other pol_type;
|
||||
typedef __mt_alloc<_Tp1, pol_type> other;
|
||||
};
|
||||
|
||||
__mt_alloc() _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
__mt_alloc(const __mt_alloc&) _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
template<typename _Tp1, typename _Poolp1>
|
||||
__mt_alloc(const __mt_alloc<_Tp1, _Poolp1>&) _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
~__mt_alloc() _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
pointer
|
||||
allocate(size_type __n, const void* = 0);
|
||||
|
||||
void
|
||||
deallocate(pointer __p, size_type __n);
|
||||
|
||||
const __pool_base::_Tune
|
||||
_M_get_options()
|
||||
{
|
||||
// Return a copy, not a reference, for external consumption.
|
||||
return __policy_type::_S_get_pool()._M_get_options();
|
||||
}
|
||||
|
||||
void
|
||||
_M_set_options(__pool_base::_Tune __t)
|
||||
{ __policy_type::_S_get_pool()._M_set_options(__t); }
|
||||
};
|
||||
|
||||
template<typename _Tp, typename _Poolp>
|
||||
typename __mt_alloc<_Tp, _Poolp>::pointer
|
||||
__mt_alloc<_Tp, _Poolp>::
|
||||
allocate(size_type __n, const void*)
|
||||
{
|
||||
if (__n > this->max_size())
|
||||
std::__throw_bad_alloc();
|
||||
|
||||
__policy_type::_S_initialize_once();
|
||||
|
||||
// Requests larger than _M_max_bytes are handled by operator
|
||||
// new/delete directly.
|
||||
__pool_type& __pool = __policy_type::_S_get_pool();
|
||||
const size_t __bytes = __n * sizeof(_Tp);
|
||||
if (__pool._M_check_threshold(__bytes))
|
||||
{
|
||||
void* __ret = ::operator new(__bytes);
|
||||
return static_cast<_Tp*>(__ret);
|
||||
}
|
||||
|
||||
// Round up to power of 2 and figure out which bin to use.
|
||||
const size_t __which = __pool._M_get_binmap(__bytes);
|
||||
const size_t __thread_id = __pool._M_get_thread_id();
|
||||
|
||||
// Find out if we have blocks on our freelist. If so, go ahead
|
||||
// and use them directly without having to lock anything.
|
||||
char* __c;
|
||||
typedef typename __pool_type::_Bin_record _Bin_record;
|
||||
const _Bin_record& __bin = __pool._M_get_bin(__which);
|
||||
if (__bin._M_first[__thread_id])
|
||||
{
|
||||
// Already reserved.
|
||||
typedef typename __pool_type::_Block_record _Block_record;
|
||||
_Block_record* __block = __bin._M_first[__thread_id];
|
||||
__bin._M_first[__thread_id] = __block->_M_next;
|
||||
|
||||
__pool._M_adjust_freelist(__bin, __block, __thread_id);
|
||||
__c = reinterpret_cast<char*>(__block) + __pool._M_get_align();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Null, reserve.
|
||||
__c = __pool._M_reserve_block(__bytes, __thread_id);
|
||||
}
|
||||
return static_cast<_Tp*>(static_cast<void*>(__c));
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Poolp>
|
||||
void
|
||||
__mt_alloc<_Tp, _Poolp>::
|
||||
deallocate(pointer __p, size_type __n)
|
||||
{
|
||||
if (__builtin_expect(__p != 0, true))
|
||||
{
|
||||
// Requests larger than _M_max_bytes are handled by
|
||||
// operators new/delete directly.
|
||||
__pool_type& __pool = __policy_type::_S_get_pool();
|
||||
const size_t __bytes = __n * sizeof(_Tp);
|
||||
if (__pool._M_check_threshold(__bytes))
|
||||
::operator delete(__p);
|
||||
else
|
||||
__pool._M_reclaim_block(reinterpret_cast<char*>(__p), __bytes);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Poolp>
|
||||
inline bool
|
||||
operator==(const __mt_alloc<_Tp, _Poolp>&, const __mt_alloc<_Tp, _Poolp>&)
|
||||
{ return true; }
|
||||
|
||||
template<typename _Tp, typename _Poolp>
|
||||
inline bool
|
||||
operator!=(const __mt_alloc<_Tp, _Poolp>&, const __mt_alloc<_Tp, _Poolp>&)
|
||||
{ return false; }
|
||||
|
||||
#undef __thread_default
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
150
openflow/usr/include/c++/5/ext/new_allocator.h
Normal file
150
openflow/usr/include/c++/5/ext/new_allocator.h
Normal file
@@ -0,0 +1,150 @@
|
||||
// Allocator that wraps operator new -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/new_allocator.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _NEW_ALLOCATOR_H
|
||||
#define _NEW_ALLOCATOR_H 1
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#include <new>
|
||||
#include <bits/functexcept.h>
|
||||
#include <bits/move.h>
|
||||
#if __cplusplus >= 201103L
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
using std::size_t;
|
||||
using std::ptrdiff_t;
|
||||
|
||||
/**
|
||||
* @brief An allocator that uses global new, as per [20.4].
|
||||
* @ingroup allocators
|
||||
*
|
||||
* This is precisely the allocator defined in the C++ Standard.
|
||||
* - all allocation calls operator new
|
||||
* - all deallocation calls operator delete
|
||||
*
|
||||
* @tparam _Tp Type of allocated object.
|
||||
*/
|
||||
template<typename _Tp>
|
||||
class new_allocator
|
||||
{
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
|
||||
template<typename _Tp1>
|
||||
struct rebind
|
||||
{ typedef new_allocator<_Tp1> other; };
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 2103. propagate_on_container_move_assignment
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
#endif
|
||||
|
||||
new_allocator() _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
new_allocator(const new_allocator&) _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
template<typename _Tp1>
|
||||
new_allocator(const new_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
~new_allocator() _GLIBCXX_USE_NOEXCEPT { }
|
||||
|
||||
pointer
|
||||
address(reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
const_pointer
|
||||
address(const_reference __x) const _GLIBCXX_NOEXCEPT
|
||||
{ return std::__addressof(__x); }
|
||||
|
||||
// NB: __n is permitted to be 0. The C++ standard says nothing
|
||||
// about what the return value is when __n == 0.
|
||||
pointer
|
||||
allocate(size_type __n, const void* = 0)
|
||||
{
|
||||
if (__n > this->max_size())
|
||||
std::__throw_bad_alloc();
|
||||
|
||||
return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
|
||||
}
|
||||
|
||||
// __p is not permitted to be a null pointer.
|
||||
void
|
||||
deallocate(pointer __p, size_type)
|
||||
{ ::operator delete(__p); }
|
||||
|
||||
size_type
|
||||
max_size() const _GLIBCXX_USE_NOEXCEPT
|
||||
{ return size_t(-1) / sizeof(_Tp); }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _Up, typename... _Args>
|
||||
void
|
||||
construct(_Up* __p, _Args&&... __args)
|
||||
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
|
||||
|
||||
template<typename _Up>
|
||||
void
|
||||
destroy(_Up* __p) { __p->~_Up(); }
|
||||
#else
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
// 402. wrong new expression in [some_] allocator::construct
|
||||
void
|
||||
construct(pointer __p, const _Tp& __val)
|
||||
{ ::new((void *)__p) _Tp(__val); }
|
||||
|
||||
void
|
||||
destroy(pointer __p) { __p->~_Tp(); }
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
inline bool
|
||||
operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
|
||||
{ return true; }
|
||||
|
||||
template<typename _Tp>
|
||||
inline bool
|
||||
operator!=(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
|
||||
{ return false; }
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
152
openflow/usr/include/c++/5/ext/numeric
Normal file
152
openflow/usr/include/c++/5/ext/numeric
Normal file
@@ -0,0 +1,152 @@
|
||||
// Numeric extensions -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Hewlett-Packard Company makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1996
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/** @file ext/numeric
|
||||
* This file is a GNU extension to the Standard C++ Library (possibly
|
||||
* containing extensions from the HP/SGI STL subset).
|
||||
*/
|
||||
|
||||
#ifndef _EXT_NUMERIC
|
||||
#define _EXT_NUMERIC 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <bits/concept_check.h>
|
||||
#include <numeric>
|
||||
|
||||
#include <ext/functional> // For identity_element
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
// Returns __x ** __n, where __n >= 0. _Note that "multiplication"
|
||||
// is required to be associative, but not necessarily commutative.
|
||||
template<typename _Tp, typename _Integer, typename _MonoidOperation>
|
||||
_Tp
|
||||
__power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
|
||||
{
|
||||
if (__n == 0)
|
||||
return identity_element(__monoid_op);
|
||||
else
|
||||
{
|
||||
while ((__n & 1) == 0)
|
||||
{
|
||||
__n >>= 1;
|
||||
__x = __monoid_op(__x, __x);
|
||||
}
|
||||
|
||||
_Tp __result = __x;
|
||||
__n >>= 1;
|
||||
while (__n != 0)
|
||||
{
|
||||
__x = __monoid_op(__x, __x);
|
||||
if ((__n & 1) != 0)
|
||||
__result = __monoid_op(__result, __x);
|
||||
__n >>= 1;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _Tp, typename _Integer>
|
||||
inline _Tp
|
||||
__power(_Tp __x, _Integer __n)
|
||||
{ return __power(__x, __n, std::multiplies<_Tp>()); }
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
// Alias for the internal name __power. Note that power is an extension,
|
||||
// not part of the C++ standard.
|
||||
template<typename _Tp, typename _Integer, typename _MonoidOperation>
|
||||
inline _Tp
|
||||
power(_Tp __x, _Integer __n, _MonoidOperation __monoid_op)
|
||||
{ return __power(__x, __n, __monoid_op); }
|
||||
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
template<typename _Tp, typename _Integer>
|
||||
inline _Tp
|
||||
power(_Tp __x, _Integer __n)
|
||||
{ return __power(__x, __n); }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
using std::iota;
|
||||
#else
|
||||
/**
|
||||
* This is an SGI extension.
|
||||
* @ingroup SGIextensions
|
||||
* @doctodo
|
||||
*/
|
||||
// iota is not part of the C++ standard. It is an extension.
|
||||
template<typename _ForwardIter, typename _Tp>
|
||||
void
|
||||
iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
|
||||
{
|
||||
// concept requirements
|
||||
__glibcxx_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter>)
|
||||
__glibcxx_function_requires(_ConvertibleConcept<_Tp,
|
||||
typename std::iterator_traits<_ForwardIter>::value_type>)
|
||||
|
||||
while (__first != __last)
|
||||
*__first++ = __value++;
|
||||
}
|
||||
#endif // C++11
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
138
openflow/usr/include/c++/5/ext/numeric_traits.h
Normal file
138
openflow/usr/include/c++/5/ext/numeric_traits.h
Normal file
@@ -0,0 +1,138 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2007-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file ext/numeric_traits.h
|
||||
* This file is a GNU extension to the Standard C++ Library.
|
||||
*/
|
||||
|
||||
#ifndef _EXT_NUMERIC_TRAITS
|
||||
#define _EXT_NUMERIC_TRAITS 1
|
||||
|
||||
#pragma GCC system_header
|
||||
|
||||
#include <bits/cpp_type_traits.h>
|
||||
#include <ext/type_traits.h>
|
||||
|
||||
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
|
||||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||
|
||||
// Compile time constants for builtin types.
|
||||
// Sadly std::numeric_limits member functions cannot be used for this.
|
||||
#define __glibcxx_signed(_Tp) ((_Tp)(-1) < 0)
|
||||
#define __glibcxx_digits(_Tp) \
|
||||
(sizeof(_Tp) * __CHAR_BIT__ - __glibcxx_signed(_Tp))
|
||||
|
||||
#define __glibcxx_min(_Tp) \
|
||||
(__glibcxx_signed(_Tp) ? (_Tp)1 << __glibcxx_digits(_Tp) : (_Tp)0)
|
||||
|
||||
#define __glibcxx_max(_Tp) \
|
||||
(__glibcxx_signed(_Tp) ? \
|
||||
(((((_Tp)1 << (__glibcxx_digits(_Tp) - 1)) - 1) << 1) + 1) : ~(_Tp)0)
|
||||
|
||||
template<typename _Value>
|
||||
struct __numeric_traits_integer
|
||||
{
|
||||
// Only integers for initialization of member constant.
|
||||
static const _Value __min = __glibcxx_min(_Value);
|
||||
static const _Value __max = __glibcxx_max(_Value);
|
||||
|
||||
// NB: these two also available in std::numeric_limits as compile
|
||||
// time constants, but <limits> is big and we avoid including it.
|
||||
static const bool __is_signed = __glibcxx_signed(_Value);
|
||||
static const int __digits = __glibcxx_digits(_Value);
|
||||
};
|
||||
|
||||
template<typename _Value>
|
||||
const _Value __numeric_traits_integer<_Value>::__min;
|
||||
|
||||
template<typename _Value>
|
||||
const _Value __numeric_traits_integer<_Value>::__max;
|
||||
|
||||
template<typename _Value>
|
||||
const bool __numeric_traits_integer<_Value>::__is_signed;
|
||||
|
||||
template<typename _Value>
|
||||
const int __numeric_traits_integer<_Value>::__digits;
|
||||
|
||||
#undef __glibcxx_signed
|
||||
#undef __glibcxx_digits
|
||||
#undef __glibcxx_min
|
||||
#undef __glibcxx_max
|
||||
|
||||
#define __glibcxx_floating(_Tp, _Fval, _Dval, _LDval) \
|
||||
(std::__are_same<_Tp, float>::__value ? _Fval \
|
||||
: std::__are_same<_Tp, double>::__value ? _Dval : _LDval)
|
||||
|
||||
#define __glibcxx_max_digits10(_Tp) \
|
||||
(2 + __glibcxx_floating(_Tp, __FLT_MANT_DIG__, __DBL_MANT_DIG__, \
|
||||
__LDBL_MANT_DIG__) * 643L / 2136)
|
||||
|
||||
#define __glibcxx_digits10(_Tp) \
|
||||
__glibcxx_floating(_Tp, __FLT_DIG__, __DBL_DIG__, __LDBL_DIG__)
|
||||
|
||||
#define __glibcxx_max_exponent10(_Tp) \
|
||||
__glibcxx_floating(_Tp, __FLT_MAX_10_EXP__, __DBL_MAX_10_EXP__, \
|
||||
__LDBL_MAX_10_EXP__)
|
||||
|
||||
template<typename _Value>
|
||||
struct __numeric_traits_floating
|
||||
{
|
||||
// Only floating point types. See N1822.
|
||||
static const int __max_digits10 = __glibcxx_max_digits10(_Value);
|
||||
|
||||
// See above comment...
|
||||
static const bool __is_signed = true;
|
||||
static const int __digits10 = __glibcxx_digits10(_Value);
|
||||
static const int __max_exponent10 = __glibcxx_max_exponent10(_Value);
|
||||
};
|
||||
|
||||
template<typename _Value>
|
||||
const int __numeric_traits_floating<_Value>::__max_digits10;
|
||||
|
||||
template<typename _Value>
|
||||
const bool __numeric_traits_floating<_Value>::__is_signed;
|
||||
|
||||
template<typename _Value>
|
||||
const int __numeric_traits_floating<_Value>::__digits10;
|
||||
|
||||
template<typename _Value>
|
||||
const int __numeric_traits_floating<_Value>::__max_exponent10;
|
||||
|
||||
template<typename _Value>
|
||||
struct __numeric_traits
|
||||
: public __conditional_type<std::__is_integer<_Value>::__value,
|
||||
__numeric_traits_integer<_Value>,
|
||||
__numeric_traits_floating<_Value> >::__type
|
||||
{ };
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
#undef __glibcxx_floating
|
||||
#undef __glibcxx_max_digits10
|
||||
#undef __glibcxx_digits10
|
||||
#undef __glibcxx_max_exponent10
|
||||
|
||||
#endif
|
||||
861
openflow/usr/include/c++/5/ext/pb_ds/assoc_container.hpp
Normal file
861
openflow/usr/include/c++/5/ext/pb_ds/assoc_container.hpp
Normal file
@@ -0,0 +1,861 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file assoc_container.hpp
|
||||
* Contains associative containers.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_ASSOC_CNTNR_HPP
|
||||
#define PB_DS_ASSOC_CNTNR_HPP
|
||||
|
||||
#include <bits/c++config.h>
|
||||
#include <ext/typelist.h>
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
#include <ext/pb_ds/detail/standard_policies.hpp>
|
||||
#include <ext/pb_ds/detail/container_base_dispatch.hpp>
|
||||
#include <ext/pb_ds/detail/branch_policy/traits.hpp>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
/**
|
||||
* @defgroup containers-pbds Containers
|
||||
* @ingroup pbds
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup hash-based Hash-Based
|
||||
* @ingroup containers-pbds
|
||||
* @{
|
||||
*/
|
||||
#define PB_DS_HASH_BASE \
|
||||
detail::container_base_dispatch<Key, Mapped, _Alloc, Tag, \
|
||||
typename __gnu_cxx::typelist::append< \
|
||||
typename __gnu_cxx::typelist::create4<Hash_Fn, Eq_Fn, Resize_Policy, \
|
||||
detail::integral_constant<int, Store_Hash> >::type, Policy_Tl>::type>::type
|
||||
|
||||
/**
|
||||
* @defgroup hash-detail Base and Policy Classes
|
||||
* @ingroup hash-based
|
||||
*/
|
||||
|
||||
/**
|
||||
* A hashed container abstraction.
|
||||
*
|
||||
* @tparam Key Key type.
|
||||
* @tparam Mapped Map type.
|
||||
* @tparam Hash_Fn Hashing functor.
|
||||
* @tparam Eq_Fn Equal functor.
|
||||
* @tparam Resize_Policy Resizes hash.
|
||||
* @tparam Store_Hash Indicates whether the hash value
|
||||
* will be stored along with each key.
|
||||
* @tparam Tag Instantiating data structure type,
|
||||
* see container_tag.
|
||||
* @tparam Policy_TL Policy typelist.
|
||||
* @tparam _Alloc Allocator type.
|
||||
*
|
||||
* Base is dispatched at compile time via Tag, from the following
|
||||
* choices: cc_hash_tag, gp_hash_tag, and descendants of basic_hash_tag.
|
||||
*
|
||||
* Base choices are: detail::cc_ht_map, detail::gp_ht_map
|
||||
*/
|
||||
template<typename Key,
|
||||
typename Mapped,
|
||||
typename Hash_Fn,
|
||||
typename Eq_Fn,
|
||||
typename Resize_Policy,
|
||||
bool Store_Hash,
|
||||
typename Tag,
|
||||
typename Policy_Tl,
|
||||
typename _Alloc>
|
||||
class basic_hash_table : public PB_DS_HASH_BASE
|
||||
{
|
||||
private:
|
||||
typedef typename PB_DS_HASH_BASE base_type;
|
||||
|
||||
public:
|
||||
virtual
|
||||
~basic_hash_table() { }
|
||||
|
||||
protected:
|
||||
basic_hash_table() { }
|
||||
|
||||
basic_hash_table(const basic_hash_table& other)
|
||||
: base_type((const base_type&)other) { }
|
||||
|
||||
template<typename T0>
|
||||
basic_hash_table(T0 t0) : base_type(t0) { }
|
||||
|
||||
template<typename T0, typename T1>
|
||||
basic_hash_table(T0 t0, T1 t1) : base_type(t0, t1) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2>
|
||||
basic_hash_table(T0 t0, T1 t1, T2 t2) : base_type(t0, t1, t2) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3>
|
||||
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3)
|
||||
: base_type(t0, t1, t2, t3) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4>
|
||||
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4)
|
||||
: base_type(t0, t1, t2, t3, t4) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5>
|
||||
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
||||
: base_type(t0, t1, t2, t3, t4, t5) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6>
|
||||
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
|
||||
: base_type(t0, t1, t2, t3, t4, t5, t6) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7>
|
||||
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
|
||||
: base_type(t0, t1, t2, t3, t4, t5, t6, t7) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6, typename T7, typename T8>
|
||||
basic_hash_table(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6,
|
||||
T7 t7, T8 t8)
|
||||
: base_type(t0, t1, t2, t3, t4, t5, t6, t7, t8)
|
||||
{ }
|
||||
|
||||
private:
|
||||
basic_hash_table&
|
||||
operator=(const base_type&);
|
||||
};
|
||||
|
||||
#undef PB_DS_HASH_BASE
|
||||
|
||||
|
||||
#define PB_DS_CC_HASH_BASE \
|
||||
basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
|
||||
cc_hash_tag, \
|
||||
typename __gnu_cxx::typelist::create1<Comb_Hash_Fn>::type, _Alloc>
|
||||
|
||||
|
||||
/**
|
||||
* A collision-chaining hash-based associative container.
|
||||
*
|
||||
* @tparam Key Key type.
|
||||
* @tparam Mapped Map type.
|
||||
* @tparam Hash_Fn Hashing functor.
|
||||
* @tparam Eq_Fn Equal functor.
|
||||
* @tparam Comb_Hash_Fn Combining hash functor.
|
||||
* If Hash_Fn is not null_type, then this
|
||||
* is the ranged-hash functor; otherwise,
|
||||
* this is the range-hashing functor.
|
||||
* XXX(See Design::Hash-Based Containers::Hash Policies.)
|
||||
* @tparam Resize_Policy Resizes hash.
|
||||
* @tparam Store_Hash Indicates whether the hash value
|
||||
* will be stored along with each key.
|
||||
* If Hash_Fn is null_type, then the
|
||||
* container will not compile if this
|
||||
* value is true
|
||||
* @tparam _Alloc Allocator type.
|
||||
*
|
||||
* Base tag choices are: cc_hash_tag.
|
||||
*
|
||||
* Base is basic_hash_table.
|
||||
*/
|
||||
template<typename Key,
|
||||
typename Mapped,
|
||||
typename Hash_Fn = typename detail::default_hash_fn<Key>::type,
|
||||
typename Eq_Fn = typename detail::default_eq_fn<Key>::type,
|
||||
typename Comb_Hash_Fn = detail::default_comb_hash_fn::type,
|
||||
typename Resize_Policy = typename detail::default_resize_policy<Comb_Hash_Fn>::type,
|
||||
bool Store_Hash = detail::default_store_hash,
|
||||
typename _Alloc = std::allocator<char> >
|
||||
class cc_hash_table : public PB_DS_CC_HASH_BASE
|
||||
{
|
||||
private:
|
||||
typedef PB_DS_CC_HASH_BASE base_type;
|
||||
|
||||
public:
|
||||
typedef cc_hash_tag container_category;
|
||||
typedef Hash_Fn hash_fn;
|
||||
typedef Eq_Fn eq_fn;
|
||||
typedef Resize_Policy resize_policy;
|
||||
typedef Comb_Hash_Fn comb_hash_fn;
|
||||
|
||||
/// Default constructor.
|
||||
cc_hash_table() { }
|
||||
|
||||
/// Constructor taking some policy objects. r_hash_fn will be
|
||||
/// copied by the Hash_Fn object of the container object.
|
||||
cc_hash_table(const hash_fn& h)
|
||||
: base_type(h) { }
|
||||
|
||||
/// Constructor taking some policy objects. r_hash_fn will be
|
||||
/// copied by the hash_fn object of the container object, and
|
||||
/// r_eq_fn will be copied by the eq_fn object of the container
|
||||
/// object.
|
||||
cc_hash_table(const hash_fn& h, const eq_fn& e)
|
||||
: base_type(h, e) { }
|
||||
|
||||
/// Constructor taking some policy objects. r_hash_fn will be
|
||||
/// copied by the hash_fn object of the container object, r_eq_fn
|
||||
/// will be copied by the eq_fn object of the container object,
|
||||
/// and r_comb_hash_fn will be copied by the comb_hash_fn object
|
||||
/// of the container object.
|
||||
cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch)
|
||||
: base_type(h, e, ch) { }
|
||||
|
||||
/// Constructor taking some policy objects. r_hash_fn will be
|
||||
/// copied by the hash_fn object of the container object, r_eq_fn
|
||||
/// will be copied by the eq_fn object of the container object,
|
||||
/// r_comb_hash_fn will be copied by the comb_hash_fn object of
|
||||
/// the container object, and r_resize_policy will be copied by
|
||||
/// the resize_policy object of the container object.
|
||||
cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch,
|
||||
const resize_policy& rp)
|
||||
: base_type(h, e, ch, rp) { }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types. The
|
||||
/// value_types between first_it and last_it will be inserted into
|
||||
/// the container object.
|
||||
template<typename It>
|
||||
cc_hash_table(It first, It last)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects. The value_types between first_it and
|
||||
/// last_it will be inserted into the container object.
|
||||
template<typename It>
|
||||
cc_hash_table(It first, It last, const hash_fn& h)
|
||||
: base_type(h)
|
||||
{ this->copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects The value_types between first_it and
|
||||
/// last_it will be inserted into the container object. r_hash_fn
|
||||
/// will be copied by the hash_fn object of the container object,
|
||||
/// and r_eq_fn will be copied by the eq_fn object of the
|
||||
/// container object.
|
||||
template<typename It>
|
||||
cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e)
|
||||
: base_type(h, e)
|
||||
{ this->copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects The value_types between first_it and
|
||||
/// last_it will be inserted into the container object. r_hash_fn
|
||||
/// will be copied by the hash_fn object of the container object,
|
||||
/// r_eq_fn will be copied by the eq_fn object of the container
|
||||
/// object, and r_comb_hash_fn will be copied by the comb_hash_fn
|
||||
/// object of the container object.
|
||||
template<typename It>
|
||||
cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
|
||||
const comb_hash_fn& ch)
|
||||
: base_type(h, e, ch)
|
||||
{ this->copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects The value_types between first_it and
|
||||
/// last_it will be inserted into the container object. r_hash_fn
|
||||
/// will be copied by the hash_fn object of the container object,
|
||||
/// r_eq_fn will be copied by the eq_fn object of the container
|
||||
/// object, r_comb_hash_fn will be copied by the comb_hash_fn
|
||||
/// object of the container object, and r_resize_policy will be
|
||||
/// copied by the resize_policy object of the container object.
|
||||
template<typename It>
|
||||
cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
|
||||
const comb_hash_fn& ch, const resize_policy& rp)
|
||||
: base_type(h, e, ch, rp)
|
||||
{ this->copy_from_range(first, last); }
|
||||
|
||||
cc_hash_table(const cc_hash_table& other)
|
||||
: base_type((const base_type&)other)
|
||||
{ }
|
||||
|
||||
virtual
|
||||
~cc_hash_table() { }
|
||||
|
||||
cc_hash_table&
|
||||
operator=(const cc_hash_table& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
cc_hash_table tmp(other);
|
||||
swap(tmp);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
swap(cc_hash_table& other)
|
||||
{ base_type::swap(other); }
|
||||
};
|
||||
|
||||
#undef PB_DS_CC_HASH_BASE
|
||||
|
||||
|
||||
#define PB_DS_GP_HASH_BASE \
|
||||
basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
|
||||
gp_hash_tag, \
|
||||
typename __gnu_cxx::typelist::create2<Comb_Probe_Fn, Probe_Fn>::type, _Alloc>
|
||||
|
||||
|
||||
/**
|
||||
* A general-probing hash-based associative container.
|
||||
*
|
||||
* @tparam Key Key type.
|
||||
* @tparam Mapped Map type.
|
||||
* @tparam Hash_Fn Hashing functor.
|
||||
* @tparam Eq_Fn Equal functor.
|
||||
* @tparam Comb_Probe_Fn Combining probe functor.
|
||||
* If Hash_Fn is not null_type, then this
|
||||
* is the ranged-probe functor; otherwise,
|
||||
* this is the range-hashing functor.
|
||||
* XXX See Design::Hash-Based Containers::Hash Policies.
|
||||
* @tparam Probe_Fn Probe functor.
|
||||
* @tparam Resize_Policy Resizes hash.
|
||||
* @tparam Store_Hash Indicates whether the hash value
|
||||
* will be stored along with each key.
|
||||
* If Hash_Fn is null_type, then the
|
||||
* container will not compile if this
|
||||
* value is true
|
||||
* @tparam _Alloc Allocator type.
|
||||
*
|
||||
* Base tag choices are: gp_hash_tag.
|
||||
*
|
||||
* Base is basic_hash_table.
|
||||
*/
|
||||
template<typename Key,
|
||||
typename Mapped,
|
||||
typename Hash_Fn = typename detail::default_hash_fn<Key>::type,
|
||||
typename Eq_Fn = typename detail::default_eq_fn<Key>::type,
|
||||
typename Comb_Probe_Fn = detail::default_comb_hash_fn::type,
|
||||
typename Probe_Fn = typename detail::default_probe_fn<Comb_Probe_Fn>::type,
|
||||
typename Resize_Policy = typename detail::default_resize_policy<Comb_Probe_Fn>::type,
|
||||
bool Store_Hash = detail::default_store_hash,
|
||||
typename _Alloc = std::allocator<char> >
|
||||
class gp_hash_table : public PB_DS_GP_HASH_BASE
|
||||
{
|
||||
private:
|
||||
typedef PB_DS_GP_HASH_BASE base_type;
|
||||
|
||||
public:
|
||||
typedef gp_hash_tag container_category;
|
||||
typedef Hash_Fn hash_fn;
|
||||
typedef Eq_Fn eq_fn;
|
||||
typedef Comb_Probe_Fn comb_probe_fn;
|
||||
typedef Probe_Fn probe_fn;
|
||||
typedef Resize_Policy resize_policy;
|
||||
|
||||
/// Default constructor.
|
||||
gp_hash_table() { }
|
||||
|
||||
/// Constructor taking some policy objects. r_hash_fn will be
|
||||
/// copied by the hash_fn object of the container object.
|
||||
gp_hash_table(const hash_fn& h)
|
||||
: base_type(h) { }
|
||||
|
||||
/// Constructor taking some policy objects. r_hash_fn will be
|
||||
/// copied by the hash_fn object of the container object, and
|
||||
/// r_eq_fn will be copied by the eq_fn object of the container
|
||||
/// object.
|
||||
gp_hash_table(const hash_fn& h, const eq_fn& e)
|
||||
: base_type(h, e) { }
|
||||
|
||||
/// Constructor taking some policy objects. r_hash_fn will be
|
||||
/// copied by the hash_fn object of the container object, r_eq_fn
|
||||
/// will be copied by the eq_fn object of the container object,
|
||||
/// and r_comb_probe_fn will be copied by the comb_probe_fn object
|
||||
/// of the container object.
|
||||
gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp)
|
||||
: base_type(h, e, cp) { }
|
||||
|
||||
/// Constructor taking some policy objects. r_hash_fn will be
|
||||
/// copied by the hash_fn object of the container object, r_eq_fn
|
||||
/// will be copied by the eq_fn object of the container object,
|
||||
/// r_comb_probe_fn will be copied by the comb_probe_fn object of
|
||||
/// the container object, and r_probe_fn will be copied by the
|
||||
/// probe_fn object of the container object.
|
||||
gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp,
|
||||
const probe_fn& p)
|
||||
: base_type(h, e, cp, p) { }
|
||||
|
||||
/// Constructor taking some policy objects. r_hash_fn will be
|
||||
/// copied by the hash_fn object of the container object, r_eq_fn
|
||||
/// will be copied by the eq_fn object of the container object,
|
||||
/// r_comb_probe_fn will be copied by the comb_probe_fn object of
|
||||
/// the container object, r_probe_fn will be copied by the
|
||||
/// probe_fn object of the container object, and r_resize_policy
|
||||
/// will be copied by the Resize_Policy object of the container
|
||||
/// object.
|
||||
gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp,
|
||||
const probe_fn& p, const resize_policy& rp)
|
||||
: base_type(h, e, cp, p, rp) { }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types. The
|
||||
/// value_types between first_it and last_it will be inserted into
|
||||
/// the container object.
|
||||
template<typename It>
|
||||
gp_hash_table(It first, It last)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects. The value_types between first_it and
|
||||
/// last_it will be inserted into the container object. r_hash_fn
|
||||
/// will be copied by the hash_fn object of the container object.
|
||||
template<typename It>
|
||||
gp_hash_table(It first, It last, const hash_fn& h)
|
||||
: base_type(h)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects. The value_types between first_it and
|
||||
/// last_it will be inserted into the container object. r_hash_fn
|
||||
/// will be copied by the hash_fn object of the container object,
|
||||
/// and r_eq_fn will be copied by the eq_fn object of the
|
||||
/// container object.
|
||||
template<typename It>
|
||||
gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e)
|
||||
: base_type(h, e)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects. The value_types between first_it and
|
||||
/// last_it will be inserted into the container object. r_hash_fn
|
||||
/// will be copied by the hash_fn object of the container object,
|
||||
/// r_eq_fn will be copied by the eq_fn object of the container
|
||||
/// object, and r_comb_probe_fn will be copied by the
|
||||
/// comb_probe_fn object of the container object.
|
||||
template<typename It>
|
||||
gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
|
||||
const comb_probe_fn& cp)
|
||||
: base_type(h, e, cp)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects. The value_types between first_it and
|
||||
/// last_it will be inserted into the container object. r_hash_fn
|
||||
/// will be copied by the hash_fn object of the container object,
|
||||
/// r_eq_fn will be copied by the eq_fn object of the container
|
||||
/// object, r_comb_probe_fn will be copied by the comb_probe_fn
|
||||
/// object of the container object, and r_probe_fn will be copied
|
||||
/// by the probe_fn object of the container object.
|
||||
template<typename It>
|
||||
gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
|
||||
const comb_probe_fn& cp, const probe_fn& p)
|
||||
: base_type(h, e, cp, p)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects. The value_types between first_it and
|
||||
/// last_it will be inserted into the container object. r_hash_fn
|
||||
/// will be copied by the hash_fn object of the container object,
|
||||
/// r_eq_fn will be copied by the eq_fn object of the container
|
||||
/// object, r_comb_probe_fn will be copied by the comb_probe_fn
|
||||
/// object of the container object, r_probe_fn will be copied by
|
||||
/// the probe_fn object of the container object, and
|
||||
/// r_resize_policy will be copied by the resize_policy object of
|
||||
/// the container object.
|
||||
template<typename It>
|
||||
gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
|
||||
const comb_probe_fn& cp, const probe_fn& p,
|
||||
const resize_policy& rp)
|
||||
: base_type(h, e, cp, p, rp)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
gp_hash_table(const gp_hash_table& other)
|
||||
: base_type((const base_type&)other)
|
||||
{ }
|
||||
|
||||
virtual
|
||||
~gp_hash_table() { }
|
||||
|
||||
gp_hash_table&
|
||||
operator=(const gp_hash_table& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
gp_hash_table tmp(other);
|
||||
swap(tmp);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
swap(gp_hash_table& other)
|
||||
{ base_type::swap(other); }
|
||||
};
|
||||
//@} hash-based
|
||||
#undef PB_DS_GP_HASH_BASE
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup branch-based Branch-Based
|
||||
* @ingroup containers-pbds
|
||||
* @{
|
||||
*/
|
||||
#define PB_DS_BRANCH_BASE \
|
||||
detail::container_base_dispatch<Key, Mapped, _Alloc, Tag, Policy_Tl>::type
|
||||
|
||||
/**
|
||||
* @defgroup branch-detail Base and Policy Classes
|
||||
* @ingroup branch-based
|
||||
*/
|
||||
|
||||
/**
|
||||
* A branched, tree-like (tree, trie) container abstraction.
|
||||
*
|
||||
* @tparam Key Key type.
|
||||
* @tparam Mapped Map type.
|
||||
* @tparam Tag Instantiating data structure type,
|
||||
* see container_tag.
|
||||
* @tparam Node_Update Updates nodes, restores invariants.
|
||||
* @tparam Policy_TL Policy typelist.
|
||||
* @tparam _Alloc Allocator type.
|
||||
*
|
||||
* Base is dispatched at compile time via Tag, from the following
|
||||
* choices: tree_tag, trie_tag, and their descendants.
|
||||
*
|
||||
* Base choices are: detail::ov_tree_map, detail::rb_tree_map,
|
||||
* detail::splay_tree_map, and detail::pat_trie_map.
|
||||
*/
|
||||
template<typename Key, typename Mapped, typename Tag,
|
||||
typename Node_Update, typename Policy_Tl, typename _Alloc>
|
||||
class basic_branch : public PB_DS_BRANCH_BASE
|
||||
{
|
||||
private:
|
||||
typedef typename PB_DS_BRANCH_BASE base_type;
|
||||
|
||||
public:
|
||||
typedef Node_Update node_update;
|
||||
|
||||
virtual
|
||||
~basic_branch() { }
|
||||
|
||||
protected:
|
||||
basic_branch() { }
|
||||
|
||||
basic_branch(const basic_branch& other)
|
||||
: base_type((const base_type&)other) { }
|
||||
|
||||
template<typename T0>
|
||||
basic_branch(T0 t0) : base_type(t0) { }
|
||||
|
||||
template<typename T0, typename T1>
|
||||
basic_branch(T0 t0, T1 t1) : base_type(t0, t1) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2>
|
||||
basic_branch(T0 t0, T1 t1, T2 t2) : base_type(t0, t1, t2) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3>
|
||||
basic_branch(T0 t0, T1 t1, T2 t2, T3 t3)
|
||||
: base_type(t0, t1, t2, t3) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4>
|
||||
basic_branch(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4)
|
||||
: base_type(t0, t1, t2, t3, t4) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5>
|
||||
basic_branch(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
||||
: base_type(t0, t1, t2, t3, t4, t5) { }
|
||||
|
||||
template<typename T0, typename T1, typename T2, typename T3, typename T4,
|
||||
typename T5, typename T6>
|
||||
basic_branch(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
|
||||
: base_type(t0, t1, t2, t3, t4, t5, t6) { }
|
||||
};
|
||||
#undef PB_DS_BRANCH_BASE
|
||||
|
||||
|
||||
#define PB_DS_TREE_NODE_AND_IT_TRAITS \
|
||||
detail::tree_traits<Key, Mapped,Cmp_Fn,Node_Update,Tag,_Alloc>
|
||||
|
||||
#define PB_DS_TREE_BASE \
|
||||
basic_branch<Key,Mapped, Tag, \
|
||||
typename PB_DS_TREE_NODE_AND_IT_TRAITS::node_update, \
|
||||
typename __gnu_cxx::typelist::create2<Cmp_Fn, \
|
||||
PB_DS_TREE_NODE_AND_IT_TRAITS>::type, _Alloc>
|
||||
|
||||
|
||||
/**
|
||||
* A tree-based container.
|
||||
*
|
||||
* @tparam Key Key type.
|
||||
* @tparam Mapped Map type.
|
||||
* @tparam Cmp_Fn Comparison functor.
|
||||
* @tparam Tag Instantiating data structure type,
|
||||
* see container_tag.
|
||||
* @tparam Node_Update Updates tree internal-nodes,
|
||||
* restores invariants when invalidated.
|
||||
* XXX See design::tree-based-containers::node invariants.
|
||||
* @tparam _Alloc Allocator type.
|
||||
*
|
||||
* Base tag choices are: ov_tree_tag, rb_tree_tag, splay_tree_tag.
|
||||
*
|
||||
* Base is basic_branch.
|
||||
*/
|
||||
template<typename Key, typename Mapped, typename Cmp_Fn = std::less<Key>,
|
||||
typename Tag = rb_tree_tag,
|
||||
template<typename Node_CItr, typename Node_Itr,
|
||||
typename Cmp_Fn_, typename _Alloc_>
|
||||
class Node_Update = null_node_update,
|
||||
typename _Alloc = std::allocator<char> >
|
||||
class tree : public PB_DS_TREE_BASE
|
||||
{
|
||||
private:
|
||||
typedef PB_DS_TREE_BASE base_type;
|
||||
|
||||
public:
|
||||
/// Comparison functor type.
|
||||
typedef Cmp_Fn cmp_fn;
|
||||
|
||||
tree() { }
|
||||
|
||||
/// Constructor taking some policy objects. r_cmp_fn will be
|
||||
/// copied by the Cmp_Fn object of the container object.
|
||||
tree(const cmp_fn& c)
|
||||
: base_type(c) { }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types. The
|
||||
/// value_types between first_it and last_it will be inserted into
|
||||
/// the container object.
|
||||
template<typename It>
|
||||
tree(It first, It last)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects The value_types between first_it and
|
||||
/// last_it will be inserted into the container object. r_cmp_fn
|
||||
/// will be copied by the cmp_fn object of the container object.
|
||||
template<typename It>
|
||||
tree(It first, It last, const cmp_fn& c)
|
||||
: base_type(c)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
tree(const tree& other)
|
||||
: base_type((const base_type&)other) { }
|
||||
|
||||
virtual
|
||||
~tree() { }
|
||||
|
||||
tree&
|
||||
operator=(const tree& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
tree tmp(other);
|
||||
swap(tmp);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
swap(tree& other)
|
||||
{ base_type::swap(other); }
|
||||
};
|
||||
|
||||
#undef PB_DS_TREE_BASE
|
||||
#undef PB_DS_TREE_NODE_AND_IT_TRAITS
|
||||
|
||||
|
||||
#define PB_DS_TRIE_NODE_AND_IT_TRAITS \
|
||||
detail::trie_traits<Key,Mapped,_ATraits,Node_Update,Tag,_Alloc>
|
||||
|
||||
#define PB_DS_TRIE_BASE \
|
||||
basic_branch<Key,Mapped,Tag, \
|
||||
typename PB_DS_TRIE_NODE_AND_IT_TRAITS::node_update, \
|
||||
typename __gnu_cxx::typelist::create2<_ATraits, \
|
||||
PB_DS_TRIE_NODE_AND_IT_TRAITS >::type, _Alloc>
|
||||
|
||||
|
||||
/**
|
||||
* A trie-based container.
|
||||
*
|
||||
* @tparam Key Key type.
|
||||
* @tparam Mapped Map type.
|
||||
* @tparam _ATraits Element access traits.
|
||||
* @tparam Tag Instantiating data structure type,
|
||||
* see container_tag.
|
||||
* @tparam Node_Update Updates trie internal-nodes,
|
||||
* restores invariants when invalidated.
|
||||
* XXX See design::tree-based-containers::node invariants.
|
||||
* @tparam _Alloc Allocator type.
|
||||
*
|
||||
* Base tag choice is pat_trie_tag.
|
||||
*
|
||||
* Base is basic_branch.
|
||||
*/
|
||||
template<typename Key,
|
||||
typename Mapped,
|
||||
typename _ATraits = \
|
||||
typename detail::default_trie_access_traits<Key>::type,
|
||||
typename Tag = pat_trie_tag,
|
||||
template<typename Node_CItr,
|
||||
typename Node_Itr,
|
||||
typename _ATraits_,
|
||||
typename _Alloc_>
|
||||
class Node_Update = null_node_update,
|
||||
typename _Alloc = std::allocator<char> >
|
||||
class trie : public PB_DS_TRIE_BASE
|
||||
{
|
||||
private:
|
||||
typedef PB_DS_TRIE_BASE base_type;
|
||||
|
||||
public:
|
||||
/// Element access traits type.
|
||||
typedef _ATraits access_traits;
|
||||
|
||||
trie() { }
|
||||
|
||||
/// Constructor taking some policy objects. r_access_traits will
|
||||
/// be copied by the _ATraits object of the container object.
|
||||
trie(const access_traits& t)
|
||||
: base_type(t) { }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types. The
|
||||
/// value_types between first_it and last_it will be inserted into
|
||||
/// the container object.
|
||||
template<typename It>
|
||||
trie(It first, It last)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types and
|
||||
/// some policy objects. The value_types between first_it and
|
||||
/// last_it will be inserted into the container object.
|
||||
template<typename It>
|
||||
trie(It first, It last, const access_traits& t)
|
||||
: base_type(t)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
trie(const trie& other)
|
||||
: base_type((const base_type&)other) { }
|
||||
|
||||
virtual
|
||||
~trie() { }
|
||||
|
||||
trie&
|
||||
operator=(const trie& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
trie tmp(other);
|
||||
swap(tmp);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
swap(trie& other)
|
||||
{ base_type::swap(other); }
|
||||
};
|
||||
//@} branch-based
|
||||
#undef PB_DS_TRIE_BASE
|
||||
#undef PB_DS_TRIE_NODE_AND_IT_TRAITS
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup list-based List-Based
|
||||
* @ingroup containers-pbds
|
||||
* @{
|
||||
*/
|
||||
#define PB_DS_LU_BASE \
|
||||
detail::container_base_dispatch<Key, Mapped, _Alloc, list_update_tag, \
|
||||
typename __gnu_cxx::typelist::create2<Eq_Fn, Update_Policy>::type>::type
|
||||
|
||||
|
||||
/**
|
||||
* A list-update based associative container.
|
||||
*
|
||||
* @tparam Key Key type.
|
||||
* @tparam Mapped Map type.
|
||||
* @tparam Eq_Fn Equal functor.
|
||||
* @tparam Update_Policy Update policy, determines when an element
|
||||
* will be moved to the front of the list.
|
||||
* @tparam _Alloc Allocator type.
|
||||
*
|
||||
* Base is detail::lu_map.
|
||||
*/
|
||||
template<typename Key,
|
||||
typename Mapped,
|
||||
class Eq_Fn = typename detail::default_eq_fn<Key>::type,
|
||||
class Update_Policy = detail::default_update_policy::type,
|
||||
class _Alloc = std::allocator<char> >
|
||||
class list_update : public PB_DS_LU_BASE
|
||||
{
|
||||
private:
|
||||
typedef typename PB_DS_LU_BASE base_type;
|
||||
|
||||
public:
|
||||
typedef list_update_tag container_category;
|
||||
typedef Eq_Fn eq_fn;
|
||||
typedef Update_Policy update_policy;
|
||||
|
||||
list_update() { }
|
||||
|
||||
/// Constructor taking __iterators to a range of value_types. The
|
||||
/// value_types between first_it and last_it will be inserted into
|
||||
/// the container object.
|
||||
template<typename It>
|
||||
list_update(It first, It last)
|
||||
{ base_type::copy_from_range(first, last); }
|
||||
|
||||
list_update(const list_update& other)
|
||||
: base_type((const base_type&)other) { }
|
||||
|
||||
virtual
|
||||
~list_update() { }
|
||||
|
||||
list_update&
|
||||
operator=(const list_update& other)
|
||||
{
|
||||
if (this !=& other)
|
||||
{
|
||||
list_update tmp(other);
|
||||
swap(tmp);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
swap(list_update& other)
|
||||
{ base_type::swap(other); }
|
||||
};
|
||||
//@} list-based
|
||||
#undef PB_DS_LU_BASE
|
||||
|
||||
// @} group containers-pbds
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,428 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/bin_search_tree_.hpp
|
||||
* Contains an implementation class for binary search tree.
|
||||
*/
|
||||
|
||||
#include <ext/pb_ds/exception.hpp>
|
||||
#include <ext/pb_ds/tree_policy.hpp>
|
||||
#include <ext/pb_ds/detail/eq_fn/eq_by_less.hpp>
|
||||
#include <ext/pb_ds/detail/types_traits.hpp>
|
||||
#include <ext/pb_ds/detail/cond_dealtor.hpp>
|
||||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <ext/pb_ds/detail/tree_trace_base.hpp>
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#include <ext/pb_ds/detail/debug_map_base.hpp>
|
||||
#endif
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_BIN_TREE_NAME bin_search_tree_map
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_BIN_TREE_NAME bin_search_tree_set
|
||||
#endif
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Key, typename Mapped, typename Cmp_Fn, \
|
||||
typename Node_And_It_Traits, typename _Alloc>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_BIN_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc>
|
||||
|
||||
#define PB_DS_BIN_TREE_TRAITS_BASE \
|
||||
types_traits<Key, Mapped, _Alloc, false>
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
|
||||
debug_map_base<Key, eq_by_less<Key, Cmp_Fn>, \
|
||||
typename _Alloc::template rebind<Key>::other::const_reference>
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
#define PB_DS_TREE_TRACE_BASE_C_DEC \
|
||||
tree_trace_base<typename Node_And_It_Traits::node_const_iterator, \
|
||||
typename Node_And_It_Traits::node_iterator, \
|
||||
Cmp_Fn, true, _Alloc>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* @brief Binary search tree (BST).
|
||||
*
|
||||
* This implementation uses an idea from the SGI STL (using a @a
|
||||
* header node which is needed for efficient iteration).
|
||||
*/
|
||||
template<typename Key, typename Mapped, typename Cmp_Fn,
|
||||
typename Node_And_It_Traits, typename _Alloc>
|
||||
class PB_DS_BIN_TREE_NAME :
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
public PB_DS_DEBUG_MAP_BASE_C_DEC,
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
public PB_DS_TREE_TRACE_BASE_C_DEC,
|
||||
#endif
|
||||
public Cmp_Fn,
|
||||
public PB_DS_BIN_TREE_TRAITS_BASE,
|
||||
public Node_And_It_Traits::node_update
|
||||
{
|
||||
typedef Node_And_It_Traits traits_type;
|
||||
|
||||
protected:
|
||||
typedef PB_DS_BIN_TREE_TRAITS_BASE traits_base;
|
||||
|
||||
typedef
|
||||
typename _Alloc::template rebind<typename traits_type::node>::other
|
||||
node_allocator;
|
||||
|
||||
typedef typename node_allocator::value_type node;
|
||||
typedef typename node_allocator::pointer node_pointer;
|
||||
|
||||
typedef typename traits_type::null_node_update_pointer
|
||||
null_node_update_pointer;
|
||||
|
||||
private:
|
||||
typedef cond_dealtor<node, _Alloc> cond_dealtor_t;
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
|
||||
#endif
|
||||
|
||||
public:
|
||||
typedef typename _Alloc::size_type size_type;
|
||||
typedef typename _Alloc::difference_type difference_type;
|
||||
typedef typename traits_base::key_type key_type;
|
||||
typedef typename traits_base::key_pointer key_pointer;
|
||||
typedef typename traits_base::key_const_pointer key_const_pointer;
|
||||
typedef typename traits_base::key_reference key_reference;
|
||||
typedef typename traits_base::key_const_reference key_const_reference;
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
typedef typename traits_base::mapped_type mapped_type;
|
||||
typedef typename traits_base::mapped_pointer mapped_pointer;
|
||||
typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
|
||||
typedef typename traits_base::mapped_reference mapped_reference;
|
||||
typedef typename traits_base::mapped_const_reference mapped_const_reference;
|
||||
#endif
|
||||
|
||||
typedef typename traits_base::value_type value_type;
|
||||
typedef typename traits_base::pointer pointer;
|
||||
typedef typename traits_base::const_pointer const_pointer;
|
||||
typedef typename traits_base::reference reference;
|
||||
typedef typename traits_base::const_reference const_reference;
|
||||
typedef typename traits_type::point_const_iterator point_const_iterator;
|
||||
|
||||
typedef point_const_iterator const_iterator;
|
||||
typedef typename traits_type::point_iterator point_iterator;
|
||||
typedef point_iterator iterator;
|
||||
|
||||
typedef typename traits_type::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
typedef typename traits_type::reverse_iterator reverse_iterator;
|
||||
typedef typename traits_type::node_const_iterator node_const_iterator;
|
||||
typedef typename traits_type::node_iterator node_iterator;
|
||||
typedef typename traits_type::node_update node_update;
|
||||
|
||||
typedef Cmp_Fn cmp_fn;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
PB_DS_BIN_TREE_NAME();
|
||||
|
||||
PB_DS_BIN_TREE_NAME(const Cmp_Fn&);
|
||||
|
||||
PB_DS_BIN_TREE_NAME(const Cmp_Fn&, const node_update&);
|
||||
|
||||
PB_DS_BIN_TREE_NAME(const PB_DS_CLASS_C_DEC&);
|
||||
|
||||
void
|
||||
swap(PB_DS_CLASS_C_DEC&);
|
||||
|
||||
~PB_DS_BIN_TREE_NAME();
|
||||
|
||||
inline bool
|
||||
empty() const;
|
||||
|
||||
inline size_type
|
||||
size() const;
|
||||
|
||||
inline size_type
|
||||
max_size() const;
|
||||
|
||||
Cmp_Fn&
|
||||
get_cmp_fn();
|
||||
|
||||
const Cmp_Fn&
|
||||
get_cmp_fn() const;
|
||||
|
||||
inline point_iterator
|
||||
lower_bound(key_const_reference);
|
||||
|
||||
inline point_const_iterator
|
||||
lower_bound(key_const_reference) const;
|
||||
|
||||
inline point_iterator
|
||||
upper_bound(key_const_reference);
|
||||
|
||||
inline point_const_iterator
|
||||
upper_bound(key_const_reference) const;
|
||||
|
||||
inline point_iterator
|
||||
find(key_const_reference);
|
||||
|
||||
inline point_const_iterator
|
||||
find(key_const_reference) const;
|
||||
|
||||
inline iterator
|
||||
begin();
|
||||
|
||||
inline const_iterator
|
||||
begin() const;
|
||||
|
||||
inline iterator
|
||||
end();
|
||||
|
||||
inline const_iterator
|
||||
end() const;
|
||||
|
||||
inline reverse_iterator
|
||||
rbegin();
|
||||
|
||||
inline const_reverse_iterator
|
||||
rbegin() const;
|
||||
|
||||
inline reverse_iterator
|
||||
rend();
|
||||
|
||||
inline const_reverse_iterator
|
||||
rend() const;
|
||||
|
||||
/// Returns a const node_iterator corresponding to the node at the
|
||||
/// root of the tree.
|
||||
inline node_const_iterator
|
||||
node_begin() const;
|
||||
|
||||
/// Returns a node_iterator corresponding to the node at the
|
||||
/// root of the tree.
|
||||
inline node_iterator
|
||||
node_begin();
|
||||
|
||||
/// Returns a const node_iterator corresponding to a node just
|
||||
/// after a leaf of the tree.
|
||||
inline node_const_iterator
|
||||
node_end() const;
|
||||
|
||||
/// Returns a node_iterator corresponding to a node just
|
||||
/// after a leaf of the tree.
|
||||
inline node_iterator
|
||||
node_end();
|
||||
|
||||
void
|
||||
clear();
|
||||
|
||||
protected:
|
||||
void
|
||||
value_swap(PB_DS_CLASS_C_DEC&);
|
||||
|
||||
void
|
||||
initialize_min_max();
|
||||
|
||||
inline iterator
|
||||
insert_imp_empty(const_reference);
|
||||
|
||||
inline iterator
|
||||
insert_leaf_new(const_reference, node_pointer, bool);
|
||||
|
||||
inline node_pointer
|
||||
get_new_node_for_leaf_insert(const_reference, false_type);
|
||||
|
||||
inline node_pointer
|
||||
get_new_node_for_leaf_insert(const_reference, true_type);
|
||||
|
||||
inline void
|
||||
actual_erase_node(node_pointer);
|
||||
|
||||
inline std::pair<node_pointer, bool>
|
||||
erase(node_pointer);
|
||||
|
||||
inline void
|
||||
update_min_max_for_erased_node(node_pointer);
|
||||
|
||||
static void
|
||||
clear_imp(node_pointer);
|
||||
|
||||
inline std::pair<point_iterator, bool>
|
||||
insert_leaf(const_reference);
|
||||
|
||||
inline void
|
||||
rotate_left(node_pointer);
|
||||
|
||||
inline void
|
||||
rotate_right(node_pointer);
|
||||
|
||||
inline void
|
||||
rotate_parent(node_pointer);
|
||||
|
||||
inline void
|
||||
apply_update(node_pointer, null_node_update_pointer);
|
||||
|
||||
template<typename Node_Update_>
|
||||
inline void
|
||||
apply_update(node_pointer, Node_Update_*);
|
||||
|
||||
inline void
|
||||
update_to_top(node_pointer, null_node_update_pointer);
|
||||
|
||||
template<typename Node_Update_>
|
||||
inline void
|
||||
update_to_top(node_pointer, Node_Update_*);
|
||||
|
||||
bool
|
||||
join_prep(PB_DS_CLASS_C_DEC&);
|
||||
|
||||
void
|
||||
join_finish(PB_DS_CLASS_C_DEC&);
|
||||
|
||||
bool
|
||||
split_prep(key_const_reference, PB_DS_CLASS_C_DEC&);
|
||||
|
||||
void
|
||||
split_finish(PB_DS_CLASS_C_DEC&);
|
||||
|
||||
size_type
|
||||
recursive_count(node_pointer) const;
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid(const char*, int) const;
|
||||
|
||||
void
|
||||
structure_only_assert_valid(const char*, int) const;
|
||||
|
||||
void
|
||||
assert_node_consistent(const node_pointer, const char*, int) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_iterators(const char*, int) const;
|
||||
|
||||
void
|
||||
assert_consistent_with_debug_base(const char*, int) const;
|
||||
|
||||
void
|
||||
assert_node_consistent_with_left(const node_pointer,
|
||||
const char*, int) const;
|
||||
|
||||
void
|
||||
assert_node_consistent_with_right(const node_pointer,
|
||||
const char*, int) const;
|
||||
|
||||
void
|
||||
assert_consistent_with_debug_base(const node_pointer,
|
||||
const char*, int) const;
|
||||
|
||||
void
|
||||
assert_min(const char*, int) const;
|
||||
|
||||
void
|
||||
assert_min_imp(const node_pointer, const char*, int) const;
|
||||
|
||||
void
|
||||
assert_max(const char*, int) const;
|
||||
|
||||
void
|
||||
assert_max_imp(const node_pointer, const char*, int) const;
|
||||
|
||||
void
|
||||
assert_size(const char*, int) const;
|
||||
|
||||
typedef std::pair<const_pointer, const_pointer> node_consistent_t;
|
||||
|
||||
node_consistent_t
|
||||
assert_node_consistent_(const node_pointer, const char*, int) const;
|
||||
#endif
|
||||
|
||||
void
|
||||
initialize();
|
||||
|
||||
node_pointer
|
||||
recursive_copy_node(const node_pointer);
|
||||
|
||||
protected:
|
||||
node_pointer m_p_head;
|
||||
size_type m_size;
|
||||
static node_allocator s_node_allocator;
|
||||
};
|
||||
|
||||
#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \
|
||||
_GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);)
|
||||
|
||||
#define PB_DS_ASSERT_NODE_CONSISTENT(_Node) \
|
||||
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, __FILE__, __LINE__);)
|
||||
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_ASSERT_NODE_CONSISTENT
|
||||
#undef PB_DS_STRUCT_ONLY_ASSERT_VALID
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_BIN_TREE_NAME
|
||||
#undef PB_DS_BIN_TREE_TRAITS_BASE
|
||||
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
|
||||
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
#undef PB_DS_TREE_TRACE_BASE_C_DEC
|
||||
#endif
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
@@ -0,0 +1,218 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/constructors_destructor_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::node_allocator
|
||||
PB_DS_CLASS_C_DEC::s_node_allocator;
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_BIN_TREE_NAME() : m_p_head(s_node_allocator.allocate(1)), m_size(0)
|
||||
{
|
||||
initialize();
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_BIN_TREE_NAME(const Cmp_Fn& r_cmp_fn) :
|
||||
Cmp_Fn(r_cmp_fn), m_p_head(s_node_allocator.allocate(1)), m_size(0)
|
||||
{
|
||||
initialize();
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_BIN_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) :
|
||||
Cmp_Fn(r_cmp_fn),
|
||||
node_update(r_node_update),
|
||||
m_p_head(s_node_allocator.allocate(1)),
|
||||
m_size(0)
|
||||
{
|
||||
initialize();
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_BIN_TREE_NAME(const PB_DS_CLASS_C_DEC& other) :
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
debug_base(other),
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_TRACE
|
||||
PB_DS_TREE_TRACE_BASE_C_DEC(other),
|
||||
#endif
|
||||
Cmp_Fn(other),
|
||||
node_update(other),
|
||||
m_p_head(s_node_allocator.allocate(1)),
|
||||
m_size(0)
|
||||
{
|
||||
initialize();
|
||||
m_size = other.m_size;
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
|
||||
|
||||
__try
|
||||
{
|
||||
m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent);
|
||||
if (m_p_head->m_p_parent != 0)
|
||||
m_p_head->m_p_parent->m_p_parent = m_p_head;
|
||||
m_size = other.m_size;
|
||||
initialize_min_max();
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
|
||||
s_node_allocator.deallocate(m_p_head, 1);
|
||||
__throw_exception_again;
|
||||
}
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
|
||||
value_swap(other);
|
||||
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )other);
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID(other)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
value_swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other);)
|
||||
std::swap(m_p_head, other.m_p_head);
|
||||
std::swap(m_size, other.m_size);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~PB_DS_BIN_TREE_NAME()
|
||||
{
|
||||
clear();
|
||||
s_node_allocator.deallocate(m_p_head, 1);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
initialize()
|
||||
{
|
||||
m_p_head->m_p_parent = 0;
|
||||
m_p_head->m_p_left = m_p_head;
|
||||
m_p_head->m_p_right = m_p_head;
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::node_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
recursive_copy_node(const node_pointer p_nd)
|
||||
{
|
||||
if (p_nd == 0)
|
||||
return (0);
|
||||
|
||||
node_pointer p_ret = s_node_allocator.allocate(1);
|
||||
__try
|
||||
{
|
||||
new (p_ret) node(*p_nd);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
s_node_allocator.deallocate(p_ret, 1);
|
||||
__throw_exception_again;
|
||||
}
|
||||
|
||||
p_ret->m_p_left = p_ret->m_p_right = 0;
|
||||
|
||||
__try
|
||||
{
|
||||
p_ret->m_p_left = recursive_copy_node(p_nd->m_p_left);
|
||||
p_ret->m_p_right = recursive_copy_node(p_nd->m_p_right);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
clear_imp(p_ret);
|
||||
__throw_exception_again;
|
||||
}
|
||||
|
||||
if (p_ret->m_p_left != 0)
|
||||
p_ret->m_p_left->m_p_parent = p_ret;
|
||||
|
||||
if (p_ret->m_p_right != 0)
|
||||
p_ret->m_p_right->m_p_parent = p_ret;
|
||||
|
||||
PB_DS_ASSERT_NODE_CONSISTENT(p_ret)
|
||||
return p_ret;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
initialize_min_max()
|
||||
{
|
||||
if (m_p_head->m_p_parent == 0)
|
||||
{
|
||||
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
node_pointer p_min = m_p_head->m_p_parent;
|
||||
while (p_min->m_p_left != 0)
|
||||
p_min = p_min->m_p_left;
|
||||
m_p_head->m_p_left = p_min;
|
||||
}
|
||||
|
||||
{
|
||||
node_pointer p_max = m_p_head->m_p_parent;
|
||||
while (p_max->m_p_right != 0)
|
||||
p_max = p_max->m_p_right;
|
||||
m_p_head->m_p_right = p_max;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,277 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/debug_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid(const char* __file, int __line) const
|
||||
{
|
||||
structure_only_assert_valid(__file, __line);
|
||||
assert_consistent_with_debug_base(__file, __line);
|
||||
assert_size(__file, __line);
|
||||
assert_iterators(__file, __line);
|
||||
if (m_p_head->m_p_parent == 0)
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(m_size == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(m_size > 0);
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
structure_only_assert_valid(const char* __file, int __line) const
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(m_p_head != 0);
|
||||
if (m_p_head->m_p_parent == 0)
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
|
||||
PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
|
||||
}
|
||||
else
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(m_p_head->m_p_parent->m_p_parent == m_p_head);
|
||||
PB_DS_DEBUG_VERIFY(m_p_head->m_p_left != m_p_head);
|
||||
PB_DS_DEBUG_VERIFY(m_p_head->m_p_right != m_p_head);
|
||||
}
|
||||
|
||||
if (m_p_head->m_p_parent != 0)
|
||||
assert_node_consistent(m_p_head->m_p_parent, __file, __line);
|
||||
assert_min(__file, __line);
|
||||
assert_max(__file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_node_consistent(const node_pointer p_nd,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
assert_node_consistent_(p_nd, __file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::node_consistent_t
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_node_consistent_(const node_pointer p_nd,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
if (p_nd == 0)
|
||||
return (std::make_pair((const_pointer)0,(const_pointer)0));
|
||||
|
||||
assert_node_consistent_with_left(p_nd, __file, __line);
|
||||
assert_node_consistent_with_right(p_nd, __file, __line);
|
||||
|
||||
const std::pair<const_pointer, const_pointer>
|
||||
l_range = assert_node_consistent_(p_nd->m_p_left, __file, __line);
|
||||
|
||||
if (l_range.second != 0)
|
||||
PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*l_range.second),
|
||||
PB_DS_V2F(p_nd->m_value)));
|
||||
|
||||
const std::pair<const_pointer, const_pointer>
|
||||
r_range = assert_node_consistent_(p_nd->m_p_right, __file, __line);
|
||||
|
||||
if (r_range.first != 0)
|
||||
PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
|
||||
PB_DS_V2F(*r_range.first)));
|
||||
|
||||
return std::make_pair((l_range.first != 0) ? l_range.first : &p_nd->m_value,
|
||||
(r_range.second != 0)? r_range.second : &p_nd->m_value);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_node_consistent_with_left(const node_pointer p_nd,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
if (p_nd->m_p_left == 0)
|
||||
return;
|
||||
PB_DS_DEBUG_VERIFY(p_nd->m_p_left->m_p_parent == p_nd);
|
||||
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
|
||||
PB_DS_V2F(p_nd->m_p_left->m_value)));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_node_consistent_with_right(const node_pointer p_nd,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
if (p_nd->m_p_right == 0)
|
||||
return;
|
||||
PB_DS_DEBUG_VERIFY(p_nd->m_p_right->m_p_parent == p_nd);
|
||||
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_p_right->m_value),
|
||||
PB_DS_V2F(p_nd->m_value)));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_min(const char* __file, int __line) const
|
||||
{
|
||||
assert_min_imp(m_p_head->m_p_parent, __file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_min_imp(const node_pointer p_nd, const char* __file, int __line) const
|
||||
{
|
||||
if (p_nd == 0)
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(m_p_head->m_p_left == m_p_head);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_nd->m_p_left == 0)
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_left);
|
||||
return;
|
||||
}
|
||||
assert_min_imp(p_nd->m_p_left, __file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_max(const char* __file, int __line) const
|
||||
{
|
||||
assert_max_imp(m_p_head->m_p_parent, __file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_max_imp(const node_pointer p_nd,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
if (p_nd == 0)
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(m_p_head->m_p_right == m_p_head);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_nd->m_p_right == 0)
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(p_nd == m_p_head->m_p_right);
|
||||
return;
|
||||
}
|
||||
|
||||
assert_max_imp(p_nd->m_p_right, __file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_iterators(const char* __file, int __line) const
|
||||
{
|
||||
size_type iterated_num = 0;
|
||||
const_iterator prev_it = end();
|
||||
for (const_iterator it = begin(); it != end(); ++it)
|
||||
{
|
||||
++iterated_num;
|
||||
PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)).m_p_nd == it.m_p_nd);
|
||||
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it));
|
||||
--upper_bound_it;
|
||||
PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == it.m_p_nd);
|
||||
|
||||
if (prev_it != end())
|
||||
PB_DS_DEBUG_VERIFY(Cmp_Fn::operator()(PB_DS_V2F(*prev_it),
|
||||
PB_DS_V2F(*it)));
|
||||
prev_it = it;
|
||||
}
|
||||
|
||||
PB_DS_DEBUG_VERIFY(iterated_num == m_size);
|
||||
size_type reverse_iterated_num = 0;
|
||||
const_reverse_iterator reverse_prev_it = rend();
|
||||
for (const_reverse_iterator reverse_it = rbegin(); reverse_it != rend();
|
||||
++reverse_it)
|
||||
{
|
||||
++reverse_iterated_num;
|
||||
PB_DS_DEBUG_VERIFY(lower_bound(
|
||||
PB_DS_V2F(*reverse_it)).m_p_nd == reverse_it.m_p_nd);
|
||||
|
||||
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*reverse_it));
|
||||
--upper_bound_it;
|
||||
PB_DS_DEBUG_VERIFY(upper_bound_it.m_p_nd == reverse_it.m_p_nd);
|
||||
if (reverse_prev_it != rend())
|
||||
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(PB_DS_V2F(*reverse_prev_it),
|
||||
PB_DS_V2F(*reverse_it)));
|
||||
reverse_prev_it = reverse_it;
|
||||
}
|
||||
PB_DS_DEBUG_VERIFY(reverse_iterated_num == m_size);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_consistent_with_debug_base(const char* __file, int __line) const
|
||||
{
|
||||
debug_base::check_size(m_size, __file, __line);
|
||||
assert_consistent_with_debug_base(m_p_head->m_p_parent, __file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_consistent_with_debug_base(const node_pointer p_nd,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
if (p_nd == 0)
|
||||
return;
|
||||
debug_base::check_key_exists(PB_DS_V2F(p_nd->m_value), __file, __line);
|
||||
assert_consistent_with_debug_base(p_nd->m_p_left, __file, __line);
|
||||
assert_consistent_with_debug_base(p_nd->m_p_right, __file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_size(const char* __file, int __line) const
|
||||
{ PB_DS_DEBUG_VERIFY(recursive_count(m_p_head->m_p_parent) == m_size); }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,103 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/erase_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
actual_erase_node(node_pointer p_z)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
--m_size;
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_z->m_value));)
|
||||
p_z->~node();
|
||||
s_node_allocator.deallocate(p_z, 1);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
update_min_max_for_erased_node(node_pointer p_z)
|
||||
{
|
||||
if (m_size == 1)
|
||||
{
|
||||
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_p_head->m_p_left == p_z)
|
||||
{
|
||||
iterator it(p_z);
|
||||
++it;
|
||||
m_p_head->m_p_left = it.m_p_nd;
|
||||
}
|
||||
else if (m_p_head->m_p_right == p_z)
|
||||
{
|
||||
iterator it(p_z);
|
||||
--it;
|
||||
m_p_head->m_p_right = it.m_p_nd;
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
clear_imp(m_p_head->m_p_parent);
|
||||
m_size = 0;
|
||||
initialize();
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
clear_imp(node_pointer p_nd)
|
||||
{
|
||||
if (p_nd == 0)
|
||||
return;
|
||||
|
||||
clear_imp(p_nd->m_p_left);
|
||||
clear_imp(p_nd->m_p_right);
|
||||
p_nd->~node();
|
||||
s_node_allocator.deallocate(p_nd, 1);
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/find_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
lower_bound(key_const_reference r_key) const
|
||||
{
|
||||
node_pointer p_pot = m_p_head;
|
||||
node_pointer p_nd = m_p_head->m_p_parent;
|
||||
|
||||
while (p_nd != 0)
|
||||
if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
|
||||
p_nd = p_nd->m_p_right;
|
||||
else
|
||||
{
|
||||
p_pot = p_nd;
|
||||
p_nd = p_nd->m_p_left;
|
||||
}
|
||||
return iterator(p_pot);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
lower_bound(key_const_reference r_key)
|
||||
{
|
||||
node_pointer p_pot = m_p_head;
|
||||
node_pointer p_nd = m_p_head->m_p_parent;
|
||||
|
||||
while (p_nd != 0)
|
||||
if (Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
|
||||
p_nd = p_nd->m_p_right;
|
||||
else
|
||||
{
|
||||
p_pot = p_nd;
|
||||
p_nd = p_nd->m_p_left;
|
||||
}
|
||||
return iterator(p_pot);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
upper_bound(key_const_reference r_key) const
|
||||
{
|
||||
node_pointer p_pot = m_p_head;
|
||||
node_pointer p_nd = m_p_head->m_p_parent;
|
||||
|
||||
while (p_nd != 0)
|
||||
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
|
||||
{
|
||||
p_pot = p_nd;
|
||||
p_nd = p_nd->m_p_left;
|
||||
}
|
||||
else
|
||||
p_nd = p_nd->m_p_right;
|
||||
return const_iterator(p_pot);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
upper_bound(key_const_reference r_key)
|
||||
{
|
||||
node_pointer p_pot = m_p_head;
|
||||
node_pointer p_nd = m_p_head->m_p_parent;
|
||||
|
||||
while (p_nd != 0)
|
||||
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value)))
|
||||
{
|
||||
p_pot = p_nd;
|
||||
p_nd = p_nd->m_p_left;
|
||||
}
|
||||
else
|
||||
p_nd = p_nd->m_p_right;
|
||||
return point_iterator(p_pot);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find(key_const_reference r_key)
|
||||
{
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
node_pointer p_pot = m_p_head;
|
||||
node_pointer p_nd = m_p_head->m_p_parent;
|
||||
|
||||
while (p_nd != 0)
|
||||
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
|
||||
{
|
||||
p_pot = p_nd;
|
||||
p_nd = p_nd->m_p_left;
|
||||
}
|
||||
else
|
||||
p_nd = p_nd->m_p_right;
|
||||
|
||||
node_pointer ret = p_pot;
|
||||
if (p_pot != m_p_head)
|
||||
{
|
||||
const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
|
||||
if (__cmp)
|
||||
ret = m_p_head;
|
||||
}
|
||||
return point_iterator(ret);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find(key_const_reference r_key) const
|
||||
{
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
node_pointer p_pot = m_p_head;
|
||||
node_pointer p_nd = m_p_head->m_p_parent;
|
||||
|
||||
while (p_nd != 0)
|
||||
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key))
|
||||
{
|
||||
p_pot = p_nd;
|
||||
p_nd = p_nd->m_p_left;
|
||||
}
|
||||
else
|
||||
p_nd = p_nd->m_p_right;
|
||||
|
||||
node_pointer ret = p_pot;
|
||||
if (p_pot != m_p_head)
|
||||
{
|
||||
const bool __cmp = Cmp_Fn::operator()(r_key, PB_DS_V2F(p_pot->m_value));
|
||||
if (__cmp)
|
||||
ret = m_p_head;
|
||||
}
|
||||
return point_const_iterator(ret);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/info_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
empty() const
|
||||
{
|
||||
return (m_size == 0);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
size() const
|
||||
{
|
||||
return (m_size);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
max_size() const
|
||||
{
|
||||
return (s_node_allocator.max_size());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/insert_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_leaf(const_reference r_value)
|
||||
{
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
|
||||
if (m_size == 0)
|
||||
return std::make_pair(insert_imp_empty(r_value),
|
||||
true);
|
||||
|
||||
node_pointer p_nd = m_p_head->m_p_parent;
|
||||
node_pointer p_pot = m_p_head;
|
||||
|
||||
while (p_nd != 0)
|
||||
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
|
||||
PB_DS_V2F(r_value)))
|
||||
{
|
||||
p_pot = p_nd;
|
||||
|
||||
p_nd = p_nd->m_p_left;
|
||||
}
|
||||
else
|
||||
p_nd = p_nd->m_p_right;
|
||||
|
||||
if (p_pot == m_p_head)
|
||||
return std::make_pair(insert_leaf_new(r_value, m_p_head->m_p_right, false),
|
||||
true);
|
||||
|
||||
if (!Cmp_Fn::operator()(PB_DS_V2F(r_value),
|
||||
PB_DS_V2F(p_pot->m_value)))
|
||||
{
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_value))
|
||||
return std::make_pair(p_pot, false);
|
||||
}
|
||||
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value))
|
||||
|
||||
p_nd = p_pot->m_p_left;
|
||||
if (p_nd == 0)
|
||||
return std::make_pair(insert_leaf_new(r_value, p_pot, true),
|
||||
true);
|
||||
|
||||
while (p_nd->m_p_right != 0)
|
||||
p_nd = p_nd->m_p_right;
|
||||
|
||||
return std::make_pair(insert_leaf_new(r_value, p_nd, false),
|
||||
true);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_leaf_new(const_reference r_value, node_pointer p_nd, bool left_nd)
|
||||
{
|
||||
node_pointer p_new_nd =
|
||||
get_new_node_for_leaf_insert(r_value,
|
||||
traits_base::m_no_throw_copies_indicator);
|
||||
|
||||
if (left_nd)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(r_value),
|
||||
PB_DS_V2F(p_nd->m_value)));
|
||||
|
||||
p_nd->m_p_left = p_new_nd;
|
||||
if (m_p_head->m_p_left == p_nd)
|
||||
m_p_head->m_p_left = p_new_nd;
|
||||
}
|
||||
else
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_right == 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value),
|
||||
PB_DS_V2F(r_value)));
|
||||
|
||||
p_nd->m_p_right = p_new_nd;
|
||||
if (m_p_head->m_p_right == p_nd)
|
||||
m_p_head->m_p_right = p_new_nd;
|
||||
}
|
||||
|
||||
p_new_nd->m_p_parent = p_nd;
|
||||
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
|
||||
PB_DS_ASSERT_NODE_CONSISTENT(p_nd)
|
||||
|
||||
update_to_top(p_new_nd, (node_update* )this);
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
|
||||
return iterator(p_new_nd);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_imp_empty(const_reference r_value)
|
||||
{
|
||||
node_pointer p_new_node =
|
||||
get_new_node_for_leaf_insert(r_value, traits_base::m_no_throw_copies_indicator);
|
||||
|
||||
m_p_head->m_p_left = m_p_head->m_p_right =
|
||||
m_p_head->m_p_parent = p_new_node;
|
||||
|
||||
p_new_node->m_p_parent = m_p_head;
|
||||
p_new_node->m_p_left = p_new_node->m_p_right = 0;
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value));)
|
||||
|
||||
update_to_top(m_p_head->m_p_parent, (node_update*)this);
|
||||
return iterator(p_new_node);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::node_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_new_node_for_leaf_insert(const_reference r_val, false_type)
|
||||
{
|
||||
node_pointer p_new_nd = s_node_allocator.allocate(1);
|
||||
cond_dealtor_t cond(p_new_nd);
|
||||
|
||||
new (const_cast<void* >(static_cast<const void* >(&p_new_nd->m_value)))
|
||||
typename node::value_type(r_val);
|
||||
|
||||
cond.set_no_action();
|
||||
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
|
||||
++m_size;
|
||||
return p_new_nd;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::node_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_new_node_for_leaf_insert(const_reference r_val, true_type)
|
||||
{
|
||||
node_pointer p_new_nd = s_node_allocator.allocate(1);
|
||||
|
||||
new (const_cast<void* >(static_cast<const void* >(&p_new_nd->m_value)))
|
||||
typename node::value_type(r_val);
|
||||
|
||||
p_new_nd->m_p_left = p_new_nd->m_p_right = 0;
|
||||
++m_size;
|
||||
return p_new_nd;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/iterators_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
begin()
|
||||
{
|
||||
return (iterator(m_p_head->m_p_left));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
begin() const
|
||||
{
|
||||
return (const_iterator(m_p_head->m_p_left));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
end()
|
||||
{
|
||||
return (iterator(m_p_head));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
end() const
|
||||
{
|
||||
return (const_iterator(m_p_head));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
rbegin() const
|
||||
{
|
||||
return (const_reverse_iterator(m_p_head->m_p_right));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
rbegin()
|
||||
{
|
||||
return (reverse_iterator(m_p_head->m_p_right));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::reverse_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
rend()
|
||||
{
|
||||
return (reverse_iterator(m_p_head));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
rend() const
|
||||
{
|
||||
return (const_reverse_iterator(m_p_head));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
node_begin() const
|
||||
{
|
||||
return (node_const_iterator(m_p_head->m_p_parent));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::node_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
node_begin()
|
||||
{
|
||||
return (node_iterator(m_p_head->m_p_parent));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::node_const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
node_end() const
|
||||
{
|
||||
return (node_const_iterator(0));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::node_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
node_end()
|
||||
{
|
||||
return (node_iterator(0));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/node_iterators.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BIN_SEARCH_TREE_NODE_ITERATORS_HPP
|
||||
#define PB_DS_BIN_SEARCH_TREE_NODE_ITERATORS_HPP
|
||||
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
#define PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC \
|
||||
bin_search_tree_const_node_it_<Node, Const_Iterator, Iterator, _Alloc>
|
||||
|
||||
/// Const node iterator.
|
||||
template<typename Node,
|
||||
class Const_Iterator,
|
||||
class Iterator,
|
||||
typename _Alloc>
|
||||
class bin_search_tree_const_node_it_
|
||||
{
|
||||
private:
|
||||
typedef
|
||||
typename _Alloc::template rebind<
|
||||
Node>::other::pointer
|
||||
node_pointer;
|
||||
|
||||
public:
|
||||
/// Category.
|
||||
typedef trivial_iterator_tag iterator_category;
|
||||
|
||||
/// Difference type.
|
||||
typedef trivial_iterator_difference_type difference_type;
|
||||
|
||||
/// Iterator's value type.
|
||||
typedef Const_Iterator value_type;
|
||||
|
||||
/// Iterator's reference type.
|
||||
typedef Const_Iterator reference;
|
||||
|
||||
/// Iterator's __const reference type.
|
||||
typedef Const_Iterator const_reference;
|
||||
|
||||
/// Metadata type.
|
||||
typedef typename Node::metadata_type metadata_type;
|
||||
|
||||
/// Const metadata reference type.
|
||||
typedef
|
||||
typename _Alloc::template rebind<metadata_type>::other::const_reference
|
||||
metadata_const_reference;
|
||||
|
||||
|
||||
bin_search_tree_const_node_it_(const node_pointer p_nd = 0)
|
||||
: m_p_nd(const_cast<node_pointer>(p_nd))
|
||||
{ }
|
||||
|
||||
/// Access.
|
||||
const_reference
|
||||
operator*() const
|
||||
{ return Const_Iterator(m_p_nd); }
|
||||
|
||||
/// Metadata access.
|
||||
metadata_const_reference
|
||||
get_metadata() const
|
||||
{ return m_p_nd->get_metadata(); }
|
||||
|
||||
/// Returns the __const node iterator associated with the left node.
|
||||
PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
|
||||
get_l_child() const
|
||||
{ return PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(m_p_nd->m_p_left); }
|
||||
|
||||
/// Returns the __const node iterator associated with the right node.
|
||||
PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
|
||||
get_r_child() const
|
||||
{ return PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(m_p_nd->m_p_right); }
|
||||
|
||||
/// Compares to a different iterator object.
|
||||
bool
|
||||
operator==(const PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC& other) const
|
||||
{ return m_p_nd == other.m_p_nd; }
|
||||
|
||||
/// Compares (negatively) to a different iterator object.
|
||||
bool
|
||||
operator!=(const PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC& other) const
|
||||
{ return m_p_nd != other.m_p_nd; }
|
||||
|
||||
node_pointer m_p_nd;
|
||||
};
|
||||
|
||||
#define PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC \
|
||||
bin_search_tree_node_it_<Node, Const_Iterator, Iterator, _Alloc>
|
||||
|
||||
/// Node iterator.
|
||||
template<typename Node,
|
||||
class Const_Iterator,
|
||||
class Iterator,
|
||||
typename _Alloc>
|
||||
class bin_search_tree_node_it_
|
||||
: public PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
|
||||
{
|
||||
private:
|
||||
typedef
|
||||
typename _Alloc::template rebind<
|
||||
Node>::other::pointer
|
||||
node_pointer;
|
||||
|
||||
public:
|
||||
/// Iterator's value type.
|
||||
typedef Iterator value_type;
|
||||
|
||||
/// Iterator's reference type.
|
||||
typedef Iterator reference;
|
||||
|
||||
/// Iterator's __const reference type.
|
||||
typedef Iterator const_reference;
|
||||
|
||||
inline
|
||||
bin_search_tree_node_it_(const node_pointer p_nd = 0)
|
||||
: PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC(const_cast<node_pointer>(p_nd))
|
||||
{ }
|
||||
|
||||
/// Access.
|
||||
Iterator
|
||||
operator*() const
|
||||
{ return Iterator(PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC::m_p_nd); }
|
||||
|
||||
/// Returns the node iterator associated with the left node.
|
||||
PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC
|
||||
get_l_child() const
|
||||
{
|
||||
return PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC(
|
||||
PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC::m_p_nd->m_p_left);
|
||||
}
|
||||
|
||||
/// Returns the node iterator associated with the right node.
|
||||
PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC
|
||||
get_r_child() const
|
||||
{
|
||||
return PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC(
|
||||
PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC::m_p_nd->m_p_right);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#undef PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
|
||||
#undef PB_DS_TREE_NODE_ITERATOR_CLASS_C_DEC
|
||||
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif // #ifndef PB_DS_BIN_SEARCH_TREE_NODE_ITERATORS_HPP
|
||||
@@ -0,0 +1,367 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/point_iterators.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP
|
||||
#define PB_DS_BIN_SEARCH_TREE_FIND_ITERATORS_HPP
|
||||
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#define PB_DS_TREE_CONST_IT_C_DEC \
|
||||
bin_search_tree_const_it_< \
|
||||
Node_Pointer, \
|
||||
Value_Type, \
|
||||
Pointer, \
|
||||
Const_Pointer, \
|
||||
Reference, \
|
||||
Const_Reference, \
|
||||
Is_Forward_Iterator, \
|
||||
_Alloc>
|
||||
|
||||
#define PB_DS_TREE_CONST_ODIR_IT_C_DEC \
|
||||
bin_search_tree_const_it_< \
|
||||
Node_Pointer, \
|
||||
Value_Type, \
|
||||
Pointer, \
|
||||
Const_Pointer, \
|
||||
Reference, \
|
||||
Const_Reference, \
|
||||
!Is_Forward_Iterator, \
|
||||
_Alloc>
|
||||
|
||||
#define PB_DS_TREE_IT_C_DEC \
|
||||
bin_search_tree_it_< \
|
||||
Node_Pointer, \
|
||||
Value_Type, \
|
||||
Pointer, \
|
||||
Const_Pointer, \
|
||||
Reference, \
|
||||
Const_Reference, \
|
||||
Is_Forward_Iterator, \
|
||||
_Alloc>
|
||||
|
||||
#define PB_DS_TREE_ODIR_IT_C_DEC \
|
||||
bin_search_tree_it_< \
|
||||
Node_Pointer, \
|
||||
Value_Type, \
|
||||
Pointer, \
|
||||
Const_Pointer, \
|
||||
Reference, \
|
||||
Const_Reference, \
|
||||
!Is_Forward_Iterator, \
|
||||
_Alloc>
|
||||
|
||||
/// Const iterator.
|
||||
template<typename Node_Pointer,
|
||||
typename Value_Type,
|
||||
typename Pointer,
|
||||
typename Const_Pointer,
|
||||
typename Reference,
|
||||
typename Const_Reference,
|
||||
bool Is_Forward_Iterator,
|
||||
typename _Alloc>
|
||||
class bin_search_tree_const_it_
|
||||
{
|
||||
public:
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
typedef typename _Alloc::difference_type difference_type;
|
||||
typedef Value_Type value_type;
|
||||
typedef Pointer pointer;
|
||||
typedef Const_Pointer const_pointer;
|
||||
typedef Reference reference;
|
||||
typedef Const_Reference const_reference;
|
||||
|
||||
inline
|
||||
bin_search_tree_const_it_(const Node_Pointer p_nd = 0)
|
||||
: m_p_nd(const_cast<Node_Pointer>(p_nd))
|
||||
{ }
|
||||
|
||||
inline
|
||||
bin_search_tree_const_it_(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other)
|
||||
: m_p_nd(other.m_p_nd)
|
||||
{ }
|
||||
|
||||
inline
|
||||
PB_DS_TREE_CONST_IT_C_DEC&
|
||||
operator=(const PB_DS_TREE_CONST_IT_C_DEC& other)
|
||||
{
|
||||
m_p_nd = other.m_p_nd;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
PB_DS_TREE_CONST_IT_C_DEC&
|
||||
operator=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other)
|
||||
{
|
||||
m_p_nd = other.m_p_nd;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const_pointer
|
||||
operator->() const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
|
||||
return &m_p_nd->m_value;
|
||||
}
|
||||
|
||||
inline const_reference
|
||||
operator*() const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
|
||||
return m_p_nd->m_value;
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator==(const PB_DS_TREE_CONST_IT_C_DEC & other) const
|
||||
{ return m_p_nd == other.m_p_nd; }
|
||||
|
||||
inline bool
|
||||
operator==(const PB_DS_TREE_CONST_ODIR_IT_C_DEC & other) const
|
||||
{ return m_p_nd == other.m_p_nd; }
|
||||
|
||||
inline bool
|
||||
operator!=(const PB_DS_TREE_CONST_IT_C_DEC& other) const
|
||||
{ return m_p_nd != other.m_p_nd; }
|
||||
|
||||
inline bool
|
||||
operator!=(const PB_DS_TREE_CONST_ODIR_IT_C_DEC& other) const
|
||||
{ return m_p_nd != other.m_p_nd; }
|
||||
|
||||
inline PB_DS_TREE_CONST_IT_C_DEC&
|
||||
operator++()
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0);
|
||||
inc(integral_constant<int,Is_Forward_Iterator>());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_CONST_IT_C_DEC
|
||||
operator++(int)
|
||||
{
|
||||
PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd);
|
||||
operator++();
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_CONST_IT_C_DEC&
|
||||
operator--()
|
||||
{
|
||||
dec(integral_constant<int,Is_Forward_Iterator>());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_CONST_IT_C_DEC
|
||||
operator--(int)
|
||||
{
|
||||
PB_DS_TREE_CONST_IT_C_DEC ret_it(m_p_nd);
|
||||
operator--();
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
protected:
|
||||
inline void
|
||||
inc(false_type)
|
||||
{ dec(true_type()); }
|
||||
|
||||
void
|
||||
inc(true_type)
|
||||
{
|
||||
if (m_p_nd->special()&&
|
||||
m_p_nd->m_p_parent->m_p_parent == m_p_nd)
|
||||
{
|
||||
m_p_nd = m_p_nd->m_p_left;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_p_nd->m_p_right != 0)
|
||||
{
|
||||
m_p_nd = m_p_nd->m_p_right;
|
||||
while (m_p_nd->m_p_left != 0)
|
||||
m_p_nd = m_p_nd->m_p_left;
|
||||
return;
|
||||
}
|
||||
|
||||
Node_Pointer p_y = m_p_nd->m_p_parent;
|
||||
while (m_p_nd == p_y->m_p_right)
|
||||
{
|
||||
m_p_nd = p_y;
|
||||
p_y = p_y->m_p_parent;
|
||||
}
|
||||
|
||||
if (m_p_nd->m_p_right != p_y)
|
||||
m_p_nd = p_y;
|
||||
}
|
||||
|
||||
inline void
|
||||
dec(false_type)
|
||||
{ inc(true_type()); }
|
||||
|
||||
void
|
||||
dec(true_type)
|
||||
{
|
||||
if (m_p_nd->special() && m_p_nd->m_p_parent->m_p_parent == m_p_nd)
|
||||
{
|
||||
m_p_nd = m_p_nd->m_p_right;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_p_nd->m_p_left != 0)
|
||||
{
|
||||
Node_Pointer p_y = m_p_nd->m_p_left;
|
||||
while (p_y->m_p_right != 0)
|
||||
p_y = p_y->m_p_right;
|
||||
m_p_nd = p_y;
|
||||
return;
|
||||
}
|
||||
|
||||
Node_Pointer p_y = m_p_nd->m_p_parent;
|
||||
while (m_p_nd == p_y->m_p_left)
|
||||
{
|
||||
m_p_nd = p_y;
|
||||
p_y = p_y->m_p_parent;
|
||||
}
|
||||
if (m_p_nd->m_p_left != p_y)
|
||||
m_p_nd = p_y;
|
||||
}
|
||||
|
||||
public:
|
||||
Node_Pointer m_p_nd;
|
||||
};
|
||||
|
||||
/// Iterator.
|
||||
template<typename Node_Pointer,
|
||||
typename Value_Type,
|
||||
typename Pointer,
|
||||
typename Const_Pointer,
|
||||
typename Reference,
|
||||
typename Const_Reference,
|
||||
bool Is_Forward_Iterator,
|
||||
typename _Alloc>
|
||||
class bin_search_tree_it_ : public PB_DS_TREE_CONST_IT_C_DEC
|
||||
{
|
||||
public:
|
||||
inline
|
||||
bin_search_tree_it_(const Node_Pointer p_nd = 0)
|
||||
: PB_DS_TREE_CONST_IT_C_DEC((Node_Pointer)p_nd)
|
||||
{ }
|
||||
|
||||
inline
|
||||
bin_search_tree_it_(const PB_DS_TREE_ODIR_IT_C_DEC& other)
|
||||
: PB_DS_TREE_CONST_IT_C_DEC(other.m_p_nd)
|
||||
{ }
|
||||
|
||||
inline
|
||||
PB_DS_TREE_IT_C_DEC&
|
||||
operator=(const PB_DS_TREE_IT_C_DEC& other)
|
||||
{
|
||||
base_it_type::m_p_nd = other.m_p_nd;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
PB_DS_TREE_IT_C_DEC&
|
||||
operator=(const PB_DS_TREE_ODIR_IT_C_DEC& other)
|
||||
{
|
||||
base_it_type::m_p_nd = other.m_p_nd;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline typename PB_DS_TREE_CONST_IT_C_DEC::pointer
|
||||
operator->() const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != 0);
|
||||
return &base_it_type::m_p_nd->m_value;
|
||||
}
|
||||
|
||||
inline typename PB_DS_TREE_CONST_IT_C_DEC::reference
|
||||
operator*() const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(base_it_type::m_p_nd != 0);
|
||||
return base_it_type::m_p_nd->m_value;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_IT_C_DEC&
|
||||
operator++()
|
||||
{
|
||||
PB_DS_TREE_CONST_IT_C_DEC:: operator++();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_IT_C_DEC
|
||||
operator++(int)
|
||||
{
|
||||
PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd);
|
||||
operator++();
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_IT_C_DEC&
|
||||
operator--()
|
||||
{
|
||||
PB_DS_TREE_CONST_IT_C_DEC:: operator--();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PB_DS_TREE_IT_C_DEC
|
||||
operator--(int)
|
||||
{
|
||||
PB_DS_TREE_IT_C_DEC ret_it(base_it_type::m_p_nd);
|
||||
operator--();
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
protected:
|
||||
typedef PB_DS_TREE_CONST_IT_C_DEC base_it_type;
|
||||
};
|
||||
|
||||
#undef PB_DS_TREE_CONST_IT_C_DEC
|
||||
#undef PB_DS_TREE_CONST_ODIR_IT_C_DEC
|
||||
#undef PB_DS_TREE_IT_C_DEC
|
||||
#undef PB_DS_TREE_ODIR_IT_C_DEC
|
||||
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/policy_access_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
Cmp_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_cmp_fn()
|
||||
{ return (*this); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
const Cmp_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_cmp_fn() const
|
||||
{ return (*this); }
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/r_erase_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
actual_erase_node(node_pointer p_z)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
--m_size;
|
||||
_GLIBCXX_DEBUG_ONLY(erase_existing(PB_DS_V2F(p_z->m_value));)
|
||||
p_z->~node();
|
||||
s_node_allocator.deallocate(p_z, 1);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
update_min_max_for_erased_node(node_pointer p_z)
|
||||
{
|
||||
if (m_size == 1)
|
||||
{
|
||||
m_p_head->m_p_left = m_p_head->m_p_right = m_p_head;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_p_head->m_p_left == p_z)
|
||||
{
|
||||
iterator it(p_z);
|
||||
++it;
|
||||
m_p_head->m_p_left = it.m_p_nd;
|
||||
}
|
||||
else if (m_p_head->m_p_right == p_z)
|
||||
{
|
||||
iterator it(p_z);
|
||||
--it;
|
||||
m_p_head->m_p_right = it.m_p_nd;
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
clear_imp(m_p_head->m_p_parent);
|
||||
m_size = 0;
|
||||
initialize();
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::clear();)
|
||||
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
clear_imp(node_pointer p_nd)
|
||||
{
|
||||
if (p_nd == 0)
|
||||
return;
|
||||
|
||||
clear_imp(p_nd->m_p_left);
|
||||
clear_imp(p_nd->m_p_right);
|
||||
p_nd->~Node();
|
||||
s_node_allocator.deallocate(p_nd, 1);
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/rotate_fn_imps.hpp
|
||||
* Contains imps for rotating nodes.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
rotate_left(node_pointer p_x)
|
||||
{
|
||||
node_pointer p_y = p_x->m_p_right;
|
||||
|
||||
p_x->m_p_right = p_y->m_p_left;
|
||||
|
||||
if (p_y->m_p_left != 0)
|
||||
p_y->m_p_left->m_p_parent = p_x;
|
||||
|
||||
p_y->m_p_parent = p_x->m_p_parent;
|
||||
|
||||
if (p_x == m_p_head->m_p_parent)
|
||||
m_p_head->m_p_parent = p_y;
|
||||
else if (p_x == p_x->m_p_parent->m_p_left)
|
||||
p_x->m_p_parent->m_p_left = p_y;
|
||||
else
|
||||
p_x->m_p_parent->m_p_right = p_y;
|
||||
|
||||
p_y->m_p_left = p_x;
|
||||
p_x->m_p_parent = p_y;
|
||||
|
||||
PB_DS_ASSERT_NODE_CONSISTENT(p_x)
|
||||
PB_DS_ASSERT_NODE_CONSISTENT(p_y)
|
||||
|
||||
apply_update(p_x, (node_update* )this);
|
||||
apply_update(p_x->m_p_parent, (node_update* )this);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
rotate_right(node_pointer p_x)
|
||||
{
|
||||
node_pointer p_y = p_x->m_p_left;
|
||||
|
||||
p_x->m_p_left = p_y->m_p_right;
|
||||
|
||||
if (p_y->m_p_right != 0)
|
||||
p_y->m_p_right->m_p_parent = p_x;
|
||||
|
||||
p_y->m_p_parent = p_x->m_p_parent;
|
||||
|
||||
if (p_x == m_p_head->m_p_parent)
|
||||
m_p_head->m_p_parent = p_y;
|
||||
else if (p_x == p_x->m_p_parent->m_p_right)
|
||||
p_x->m_p_parent->m_p_right = p_y;
|
||||
else
|
||||
p_x->m_p_parent->m_p_left = p_y;
|
||||
|
||||
p_y->m_p_right = p_x;
|
||||
p_x->m_p_parent = p_y;
|
||||
|
||||
PB_DS_ASSERT_NODE_CONSISTENT(p_x)
|
||||
PB_DS_ASSERT_NODE_CONSISTENT(p_y)
|
||||
|
||||
apply_update(p_x, (node_update* )this);
|
||||
apply_update(p_x->m_p_parent, (node_update* )this);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
rotate_parent(node_pointer p_nd)
|
||||
{
|
||||
node_pointer p_parent = p_nd->m_p_parent;
|
||||
|
||||
if (p_nd == p_parent->m_p_left)
|
||||
rotate_right(p_parent);
|
||||
else
|
||||
rotate_left(p_parent);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_parent = p_nd);
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_left == p_parent ||
|
||||
p_nd->m_p_right == p_parent);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
apply_update(node_pointer /*p_nd*/, null_node_update_pointer /*p_update*/)
|
||||
{ }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Node_Update_>
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
apply_update(node_pointer p_nd, Node_Update_* /*p_update*/)
|
||||
{
|
||||
node_update::operator()(node_iterator(p_nd),
|
||||
node_const_iterator(static_cast<node_pointer>(0)));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Node_Update_>
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
update_to_top(node_pointer p_nd, Node_Update_* p_update)
|
||||
{
|
||||
while (p_nd != m_p_head)
|
||||
{
|
||||
apply_update(p_nd, p_update);
|
||||
|
||||
p_nd = p_nd->m_p_parent;
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
update_to_top(node_pointer /*p_nd*/, null_node_update_pointer /*p_update*/)
|
||||
{ }
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/split_join_fn_imps.hpp
|
||||
* Contains an implementation class for bin_search_tree_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
join_prep(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
if (other.m_size == 0)
|
||||
return false;
|
||||
|
||||
if (m_size == 0)
|
||||
{
|
||||
value_swap(other);
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool greater =
|
||||
Cmp_Fn::operator()(PB_DS_V2F(m_p_head->m_p_right->m_value),
|
||||
PB_DS_V2F(other.m_p_head->m_p_left->m_value));
|
||||
|
||||
const bool lesser =
|
||||
Cmp_Fn::operator()(PB_DS_V2F(other.m_p_head->m_p_right->m_value),
|
||||
PB_DS_V2F(m_p_head->m_p_left->m_value));
|
||||
|
||||
if (!greater && !lesser)
|
||||
__throw_join_error();
|
||||
|
||||
if (lesser)
|
||||
value_swap(other);
|
||||
|
||||
m_size += other.m_size;
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::join(other);)
|
||||
return true;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
join_finish(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
initialize_min_max();
|
||||
other.initialize();
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
split_prep(key_const_reference r_key, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
other.clear();
|
||||
|
||||
if (m_size == 0)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_left->m_value)))
|
||||
{
|
||||
value_swap(other);
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(m_p_head->m_p_right->m_value)))
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_size == 1)
|
||||
{
|
||||
value_swap(other);
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
return false;
|
||||
}
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(Cmp_Fn& )(*this), other);)
|
||||
return true;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
split_finish(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
other.initialize_min_max();
|
||||
other.m_size = std::distance(other.begin(), other.end());
|
||||
m_size -= other.m_size;
|
||||
initialize_min_max();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
recursive_count(node_pointer p) const
|
||||
{
|
||||
if (p == 0)
|
||||
return 0;
|
||||
return 1 + recursive_count(p->m_p_left) + recursive_count(p->m_p_right);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file bin_search_tree_/traits.hpp
|
||||
* Contains an implementation for bin_search_tree_.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BIN_SEARCH_TREE_NODE_AND_IT_TRAITS_HPP
|
||||
#define PB_DS_BIN_SEARCH_TREE_NODE_AND_IT_TRAITS_HPP
|
||||
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Binary search tree traits, primary template
|
||||
/// @ingroup traits
|
||||
template<typename Key,
|
||||
typename Mapped,
|
||||
class Cmp_Fn,
|
||||
template<typename Node_CItr,
|
||||
class Node_Itr,
|
||||
class _Cmp_Fn,
|
||||
typename _Alloc>
|
||||
class Node_Update,
|
||||
class Node,
|
||||
typename _Alloc>
|
||||
struct bin_search_tree_traits
|
||||
{
|
||||
private:
|
||||
typedef types_traits<Key, Mapped, _Alloc, false> type_traits;
|
||||
|
||||
public:
|
||||
typedef Node node;
|
||||
|
||||
typedef
|
||||
bin_search_tree_const_it_<
|
||||
typename _Alloc::template rebind<
|
||||
node>::other::pointer,
|
||||
typename type_traits::value_type,
|
||||
typename type_traits::pointer,
|
||||
typename type_traits::const_pointer,
|
||||
typename type_traits::reference,
|
||||
typename type_traits::const_reference,
|
||||
true,
|
||||
_Alloc>
|
||||
point_const_iterator;
|
||||
|
||||
typedef
|
||||
bin_search_tree_it_<
|
||||
typename _Alloc::template rebind<
|
||||
node>::other::pointer,
|
||||
typename type_traits::value_type,
|
||||
typename type_traits::pointer,
|
||||
typename type_traits::const_pointer,
|
||||
typename type_traits::reference,
|
||||
typename type_traits::const_reference,
|
||||
true,
|
||||
_Alloc>
|
||||
point_iterator;
|
||||
|
||||
typedef
|
||||
bin_search_tree_const_it_<
|
||||
typename _Alloc::template rebind<
|
||||
node>::other::pointer,
|
||||
typename type_traits::value_type,
|
||||
typename type_traits::pointer,
|
||||
typename type_traits::const_pointer,
|
||||
typename type_traits::reference,
|
||||
typename type_traits::const_reference,
|
||||
false,
|
||||
_Alloc>
|
||||
const_reverse_iterator;
|
||||
|
||||
typedef
|
||||
bin_search_tree_it_<
|
||||
typename _Alloc::template rebind<
|
||||
node>::other::pointer,
|
||||
typename type_traits::value_type,
|
||||
typename type_traits::pointer,
|
||||
typename type_traits::const_pointer,
|
||||
typename type_traits::reference,
|
||||
typename type_traits::const_reference,
|
||||
false,
|
||||
_Alloc>
|
||||
reverse_iterator;
|
||||
|
||||
/// This is an iterator to an iterator: it iterates over nodes,
|
||||
/// and de-referencing it returns one of the tree's iterators.
|
||||
typedef
|
||||
bin_search_tree_const_node_it_<
|
||||
Node,
|
||||
point_const_iterator,
|
||||
point_iterator,
|
||||
_Alloc>
|
||||
node_const_iterator;
|
||||
|
||||
typedef
|
||||
bin_search_tree_node_it_<
|
||||
Node,
|
||||
point_const_iterator,
|
||||
point_iterator,
|
||||
_Alloc>
|
||||
node_iterator;
|
||||
|
||||
typedef
|
||||
Node_Update<
|
||||
node_const_iterator,
|
||||
node_iterator,
|
||||
Cmp_Fn,
|
||||
_Alloc>
|
||||
node_update;
|
||||
|
||||
typedef
|
||||
__gnu_pbds::null_node_update<
|
||||
node_const_iterator,
|
||||
node_iterator,
|
||||
Cmp_Fn,
|
||||
_Alloc>*
|
||||
null_node_update_pointer;
|
||||
};
|
||||
|
||||
/// Specialization.
|
||||
/// @ingroup traits
|
||||
template<typename Key,
|
||||
class Cmp_Fn,
|
||||
template<typename Node_CItr,
|
||||
class Node_Itr,
|
||||
class _Cmp_Fn,
|
||||
typename _Alloc>
|
||||
class Node_Update,
|
||||
class Node,
|
||||
typename _Alloc>
|
||||
struct
|
||||
bin_search_tree_traits<Key, null_type, Cmp_Fn, Node_Update, Node, _Alloc>
|
||||
{
|
||||
private:
|
||||
typedef types_traits<Key, null_type, _Alloc, false> type_traits;
|
||||
|
||||
public:
|
||||
typedef Node node;
|
||||
|
||||
typedef
|
||||
bin_search_tree_const_it_<
|
||||
typename _Alloc::template rebind<
|
||||
node>::other::pointer,
|
||||
typename type_traits::value_type,
|
||||
typename type_traits::pointer,
|
||||
typename type_traits::const_pointer,
|
||||
typename type_traits::reference,
|
||||
typename type_traits::const_reference,
|
||||
true,
|
||||
_Alloc>
|
||||
point_const_iterator;
|
||||
|
||||
typedef point_const_iterator point_iterator;
|
||||
|
||||
typedef
|
||||
bin_search_tree_const_it_<
|
||||
typename _Alloc::template rebind<
|
||||
node>::other::pointer,
|
||||
typename type_traits::value_type,
|
||||
typename type_traits::pointer,
|
||||
typename type_traits::const_pointer,
|
||||
typename type_traits::reference,
|
||||
typename type_traits::const_reference,
|
||||
false,
|
||||
_Alloc>
|
||||
const_reverse_iterator;
|
||||
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
|
||||
/// This is an iterator to an iterator: it iterates over nodes,
|
||||
/// and de-referencing it returns one of the tree's iterators.
|
||||
typedef
|
||||
bin_search_tree_const_node_it_<
|
||||
Node,
|
||||
point_const_iterator,
|
||||
point_iterator,
|
||||
_Alloc>
|
||||
node_const_iterator;
|
||||
|
||||
typedef node_const_iterator node_iterator;
|
||||
|
||||
typedef
|
||||
Node_Update<node_const_iterator, node_iterator, Cmp_Fn, _Alloc>
|
||||
node_update;
|
||||
|
||||
typedef
|
||||
__gnu_pbds::null_node_update<
|
||||
node_const_iterator,
|
||||
node_iterator,
|
||||
Cmp_Fn,
|
||||
_Alloc>*
|
||||
null_node_update_pointer;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif // #ifndef PB_DS_BIN_SEARCH_TREE_NODE_AND_IT_TRAITS_HPP
|
||||
@@ -0,0 +1,352 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/binary_heap_.hpp
|
||||
* Contains an implementation class for a binary heap.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BINARY_HEAP_HPP
|
||||
#define PB_DS_BINARY_HEAP_HPP
|
||||
|
||||
#include <queue>
|
||||
#include <algorithm>
|
||||
#include <ext/pb_ds/detail/cond_dealtor.hpp>
|
||||
#include <ext/pb_ds/detail/cond_dealtor.hpp>
|
||||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/entry_cmp.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/entry_pred.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/resize_policy.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/const_iterator.hpp>
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
#include <iostream>
|
||||
#endif
|
||||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binary_heap<Value_Type, Cmp_Fn, _Alloc>
|
||||
|
||||
#define PB_DS_ENTRY_CMP_DEC \
|
||||
entry_cmp<Value_Type, Cmp_Fn, _Alloc, is_simple<Value_Type>::value>::type
|
||||
|
||||
#define PB_DS_RESIZE_POLICY_DEC \
|
||||
__gnu_pbds::detail::resize_policy<typename _Alloc::size_type>
|
||||
|
||||
/**
|
||||
* Binary heaps composed of resize and compare policies.
|
||||
*
|
||||
* @ingroup heap-detail
|
||||
*
|
||||
* Based on CLRS.
|
||||
*/
|
||||
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
|
||||
class binary_heap
|
||||
: public PB_DS_ENTRY_CMP_DEC, public PB_DS_RESIZE_POLICY_DEC
|
||||
{
|
||||
public:
|
||||
typedef Value_Type value_type;
|
||||
typedef Cmp_Fn cmp_fn;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef typename _Alloc::size_type size_type;
|
||||
typedef typename _Alloc::difference_type difference_type;
|
||||
typedef typename PB_DS_ENTRY_CMP_DEC entry_cmp;
|
||||
typedef PB_DS_RESIZE_POLICY_DEC resize_policy;
|
||||
typedef cond_dealtor<value_type, _Alloc> cond_dealtor_t;
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
simple_value = is_simple<value_type>::value
|
||||
};
|
||||
|
||||
typedef integral_constant<int, simple_value> no_throw_copies_t;
|
||||
|
||||
typedef typename _Alloc::template rebind<value_type> __rebind_v;
|
||||
typedef typename __rebind_v::other value_allocator;
|
||||
|
||||
public:
|
||||
typedef typename value_allocator::pointer pointer;
|
||||
typedef typename value_allocator::const_pointer const_pointer;
|
||||
typedef typename value_allocator::reference reference;
|
||||
typedef typename value_allocator::const_reference const_reference;
|
||||
|
||||
typedef typename __conditional_type<simple_value,
|
||||
value_type, pointer>::__type
|
||||
entry;
|
||||
|
||||
typedef typename _Alloc::template rebind<entry>::other
|
||||
entry_allocator;
|
||||
|
||||
typedef typename entry_allocator::pointer entry_pointer;
|
||||
|
||||
typedef binary_heap_point_const_iterator_<value_type, entry,
|
||||
simple_value, _Alloc>
|
||||
point_const_iterator;
|
||||
|
||||
typedef point_const_iterator point_iterator;
|
||||
|
||||
typedef binary_heap_const_iterator_<value_type, entry,
|
||||
simple_value, _Alloc>
|
||||
const_iterator;
|
||||
|
||||
typedef const_iterator iterator;
|
||||
|
||||
|
||||
binary_heap();
|
||||
|
||||
binary_heap(const cmp_fn&);
|
||||
|
||||
binary_heap(const binary_heap&);
|
||||
|
||||
void
|
||||
swap(binary_heap&);
|
||||
|
||||
~binary_heap();
|
||||
|
||||
inline bool
|
||||
empty() const;
|
||||
|
||||
inline size_type
|
||||
size() const;
|
||||
|
||||
inline size_type
|
||||
max_size() const;
|
||||
|
||||
Cmp_Fn&
|
||||
get_cmp_fn();
|
||||
|
||||
const Cmp_Fn&
|
||||
get_cmp_fn() const;
|
||||
|
||||
inline point_iterator
|
||||
push(const_reference);
|
||||
|
||||
void
|
||||
modify(point_iterator, const_reference);
|
||||
|
||||
inline const_reference
|
||||
top() const;
|
||||
|
||||
inline void
|
||||
pop();
|
||||
|
||||
inline void
|
||||
erase(point_iterator);
|
||||
|
||||
template<typename Pred>
|
||||
size_type
|
||||
erase_if(Pred);
|
||||
|
||||
inline void
|
||||
erase_at(entry_pointer, size_type, false_type);
|
||||
|
||||
inline void
|
||||
erase_at(entry_pointer, size_type, true_type);
|
||||
|
||||
inline iterator
|
||||
begin();
|
||||
|
||||
inline const_iterator
|
||||
begin() const;
|
||||
|
||||
inline iterator
|
||||
end();
|
||||
|
||||
inline const_iterator
|
||||
end() const;
|
||||
|
||||
void
|
||||
clear();
|
||||
|
||||
template<typename Pred>
|
||||
void
|
||||
split(Pred, binary_heap&);
|
||||
|
||||
void
|
||||
join(binary_heap&);
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
void
|
||||
trace() const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
template<typename It>
|
||||
void
|
||||
copy_from_range(It, It);
|
||||
|
||||
private:
|
||||
void
|
||||
value_swap(binary_heap&);
|
||||
|
||||
inline void
|
||||
insert_value(const_reference, false_type);
|
||||
|
||||
inline void
|
||||
insert_value(value_type, true_type);
|
||||
|
||||
inline void
|
||||
resize_for_insert_if_needed();
|
||||
|
||||
inline void
|
||||
swap_value_imp(entry_pointer, value_type, true_type);
|
||||
|
||||
inline void
|
||||
swap_value_imp(entry_pointer, const_reference, false_type);
|
||||
|
||||
void
|
||||
fix(entry_pointer);
|
||||
|
||||
inline const_reference
|
||||
top_imp(true_type) const;
|
||||
|
||||
inline const_reference
|
||||
top_imp(false_type) const;
|
||||
|
||||
inline static size_type
|
||||
left_child(size_type);
|
||||
|
||||
inline static size_type
|
||||
right_child(size_type);
|
||||
|
||||
inline static size_type
|
||||
parent(size_type);
|
||||
|
||||
inline void
|
||||
resize_for_erase_if_needed();
|
||||
|
||||
template<typename Pred>
|
||||
size_type
|
||||
partition(Pred);
|
||||
|
||||
void
|
||||
make_heap()
|
||||
{
|
||||
const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
|
||||
entry_pointer end = m_a_entries + m_size;
|
||||
std::make_heap(m_a_entries, end, m_cmp);
|
||||
_GLIBCXX_DEBUG_ASSERT(is_heap());
|
||||
}
|
||||
|
||||
void
|
||||
push_heap()
|
||||
{
|
||||
if (!is_heap())
|
||||
make_heap();
|
||||
else
|
||||
{
|
||||
const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
|
||||
entry_pointer end = m_a_entries + m_size;
|
||||
std::push_heap(m_a_entries, end, m_cmp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pop_heap()
|
||||
{
|
||||
const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
|
||||
entry_pointer end = m_a_entries + m_size;
|
||||
std::pop_heap(m_a_entries, end, m_cmp);
|
||||
}
|
||||
|
||||
bool
|
||||
is_heap()
|
||||
{
|
||||
const entry_cmp& m_cmp = static_cast<entry_cmp&>(*this);
|
||||
entry_pointer end = m_a_entries + m_size;
|
||||
bool p = std::__is_heap(m_a_entries, end, m_cmp);
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid(const char*, int) const;
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
void
|
||||
trace_entry(const entry&, false_type) const;
|
||||
|
||||
void
|
||||
trace_entry(const entry&, true_type) const;
|
||||
#endif
|
||||
|
||||
static entry_allocator s_entry_allocator;
|
||||
static value_allocator s_value_allocator;
|
||||
static no_throw_copies_t s_no_throw_copies_ind;
|
||||
|
||||
size_type m_size;
|
||||
size_type m_actual_size;
|
||||
entry_pointer m_a_entries;
|
||||
};
|
||||
|
||||
#define PB_DS_ASSERT_VALID(X) \
|
||||
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
|
||||
|
||||
#define PB_DS_DEBUG_VERIFY(_Cond) \
|
||||
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
|
||||
_M_message(#_Cond" assertion from %1;:%2;") \
|
||||
._M_string(__FILE__)._M_integer(__LINE__) \
|
||||
,__file,__line)
|
||||
|
||||
#include <ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_ENTRY_CMP_DEC
|
||||
#undef PB_DS_RESIZE_POLICY_DEC
|
||||
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,139 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/const_iterator.hpp
|
||||
* Contains an iterator class returned by the table's const find and insert
|
||||
* methods.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP
|
||||
#define PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP
|
||||
|
||||
#include <ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
#define PB_DS_BIN_HEAP_CIT_BASE \
|
||||
binary_heap_point_const_iterator_<Value_Type, Entry, Simple, _Alloc>
|
||||
|
||||
/// Const point-type iterator.
|
||||
template<typename Value_Type,
|
||||
typename Entry,
|
||||
bool Simple,
|
||||
typename _Alloc>
|
||||
class binary_heap_const_iterator_ : public PB_DS_BIN_HEAP_CIT_BASE
|
||||
{
|
||||
private:
|
||||
typedef PB_DS_BIN_HEAP_CIT_BASE base_type;
|
||||
typedef typename base_type::entry_pointer entry_pointer;
|
||||
|
||||
public:
|
||||
/// Category.
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
/// Difference type.
|
||||
typedef typename _Alloc::difference_type difference_type;
|
||||
|
||||
/// Iterator's value type.
|
||||
typedef typename base_type::value_type value_type;
|
||||
|
||||
/// Iterator's pointer type.
|
||||
typedef typename base_type::pointer pointer;
|
||||
|
||||
/// Iterator's const pointer type.
|
||||
typedef typename base_type::const_pointer const_pointer;
|
||||
|
||||
/// Iterator's reference type.
|
||||
typedef typename base_type::reference reference;
|
||||
|
||||
/// Iterator's const reference type.
|
||||
typedef typename base_type::const_reference const_reference;
|
||||
|
||||
inline
|
||||
binary_heap_const_iterator_(entry_pointer p_e) : base_type(p_e)
|
||||
{ }
|
||||
|
||||
/// Default constructor.
|
||||
inline
|
||||
binary_heap_const_iterator_()
|
||||
{ }
|
||||
|
||||
/// Copy constructor.
|
||||
inline
|
||||
binary_heap_const_iterator_(const binary_heap_const_iterator_& other)
|
||||
: base_type(other)
|
||||
{ }
|
||||
|
||||
/// Compares content to a different iterator object.
|
||||
inline bool
|
||||
operator==(const binary_heap_const_iterator_& other) const
|
||||
{ return base_type::m_p_e == other.m_p_e; }
|
||||
|
||||
/// Compares content (negatively) to a different iterator object.
|
||||
inline bool
|
||||
operator!=(const binary_heap_const_iterator_& other) const
|
||||
{ return base_type::m_p_e != other.m_p_e; }
|
||||
|
||||
inline binary_heap_const_iterator_&
|
||||
operator++()
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_e != 0);
|
||||
inc();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline binary_heap_const_iterator_
|
||||
operator++(int)
|
||||
{
|
||||
binary_heap_const_iterator_ ret_it(base_type::m_p_e);
|
||||
operator++();
|
||||
return ret_it;
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
inc()
|
||||
{ ++base_type::m_p_e; }
|
||||
};
|
||||
|
||||
#undef PB_DS_BIN_HEAP_CIT_BASE
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,139 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/constructors_destructor_fn_imps.hpp
|
||||
* Contains an implementation class for binary_heap_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::entry_allocator
|
||||
PB_DS_CLASS_C_DEC::s_entry_allocator;
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::value_allocator
|
||||
PB_DS_CLASS_C_DEC::s_value_allocator;
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::no_throw_copies_t
|
||||
PB_DS_CLASS_C_DEC::s_no_throw_copies_ind;
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename It>
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
copy_from_range(It first_it, It last_it)
|
||||
{
|
||||
while (first_it != last_it)
|
||||
{
|
||||
insert_value(*first_it, s_no_throw_copies_ind);
|
||||
++first_it;
|
||||
}
|
||||
make_heap();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binary_heap()
|
||||
: m_size(0), m_actual_size(resize_policy::min_size),
|
||||
m_a_entries(s_entry_allocator.allocate(m_actual_size))
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binary_heap(const Cmp_Fn& r_cmp_fn)
|
||||
: entry_cmp(r_cmp_fn), m_size(0), m_actual_size(resize_policy::min_size),
|
||||
m_a_entries(s_entry_allocator.allocate(m_actual_size))
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binary_heap(const PB_DS_CLASS_C_DEC& other)
|
||||
: entry_cmp(other), resize_policy(other), m_size(0),
|
||||
m_actual_size(other.m_actual_size),
|
||||
m_a_entries(s_entry_allocator.allocate(m_actual_size))
|
||||
{
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
|
||||
|
||||
__try
|
||||
{
|
||||
copy_from_range(other.begin(), other.end());
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
for (size_type i = 0; i < m_size; ++i)
|
||||
erase_at(m_a_entries, i, s_no_throw_copies_ind);
|
||||
|
||||
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
|
||||
__throw_exception_again;
|
||||
}
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
_GLIBCXX_DEBUG_ASSERT(m_a_entries != other.m_a_entries);
|
||||
value_swap(other);
|
||||
std::swap((entry_cmp&)(*this), (entry_cmp&)other);
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
value_swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
std::swap(m_a_entries, other.m_a_entries);
|
||||
std::swap(m_size, other.m_size);
|
||||
std::swap(m_actual_size, other.m_actual_size);
|
||||
static_cast<resize_policy*>(this)->swap(other);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~binary_heap()
|
||||
{
|
||||
for (size_type i = 0; i < m_size; ++i)
|
||||
erase_at(m_a_entries, i, s_no_throw_copies_ind);
|
||||
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/debug_fn_imps.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid(const char* __file, int __line) const
|
||||
{
|
||||
#ifdef PB_DS_REGRESSION
|
||||
s_entry_allocator.check_allocated(m_a_entries, m_actual_size);
|
||||
#endif
|
||||
|
||||
resize_policy::assert_valid(__file, __line);
|
||||
PB_DS_DEBUG_VERIFY(m_size <= m_actual_size);
|
||||
for (size_type i = 0; i < m_size; ++i)
|
||||
{
|
||||
#ifdef PB_DS_REGRESSION
|
||||
s_value_allocator.check_allocated(m_a_entries[i], 1);
|
||||
#endif
|
||||
|
||||
if (left_child(i) < m_size)
|
||||
PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)]));
|
||||
|
||||
PB_DS_DEBUG_VERIFY(parent(left_child(i)) == i);
|
||||
|
||||
if (right_child(i) < m_size)
|
||||
PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)]));
|
||||
|
||||
PB_DS_DEBUG_VERIFY(parent(right_child(i)) == i);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/entry_cmp.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BINARY_HEAP_ENTRY_CMP_HPP
|
||||
#define PB_DS_BINARY_HEAP_ENTRY_CMP_HPP
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Entry compare, primary template.
|
||||
template<typename _VTp, typename Cmp_Fn, typename _Alloc, bool No_Throw>
|
||||
struct entry_cmp;
|
||||
|
||||
/// Specialization, true.
|
||||
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
|
||||
struct entry_cmp<_VTp, Cmp_Fn, _Alloc, true>
|
||||
{
|
||||
/// Compare.
|
||||
typedef Cmp_Fn type;
|
||||
};
|
||||
|
||||
/// Specialization, false.
|
||||
template<typename _VTp, typename Cmp_Fn, typename _Alloc>
|
||||
struct entry_cmp<_VTp, Cmp_Fn, _Alloc, false>
|
||||
{
|
||||
private:
|
||||
typedef typename _Alloc::template rebind<_VTp> __rebind_v;
|
||||
|
||||
public:
|
||||
typedef typename __rebind_v::other::const_pointer entry;
|
||||
|
||||
/// Compare plus entry.
|
||||
struct type : public Cmp_Fn
|
||||
{
|
||||
type() { }
|
||||
|
||||
type(const Cmp_Fn& other) : Cmp_Fn(other) { }
|
||||
|
||||
bool
|
||||
operator()(entry lhs, entry rhs) const
|
||||
{ return Cmp_Fn::operator()(*lhs, *rhs); }
|
||||
};
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif // #ifndef PB_DS_BINARY_HEAP_ENTRY_CMP_HPP
|
||||
@@ -0,0 +1,85 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/entry_pred.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BINARY_HEAP_ENTRY_PRED_HPP
|
||||
#define PB_DS_BINARY_HEAP_ENTRY_PRED_HPP
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Entry predicate primary class template.
|
||||
template<typename _VTp, typename Pred, typename _Alloc, bool No_Throw>
|
||||
struct entry_pred;
|
||||
|
||||
/// Specialization, true.
|
||||
template<typename _VTp, typename Pred, typename _Alloc>
|
||||
struct entry_pred<_VTp, Pred, _Alloc, true>
|
||||
{
|
||||
typedef Pred type;
|
||||
};
|
||||
|
||||
/// Specialization, false.
|
||||
template<typename _VTp, typename Pred, typename _Alloc>
|
||||
struct entry_pred<_VTp, Pred, _Alloc, false>
|
||||
{
|
||||
private:
|
||||
typedef typename _Alloc::template rebind<_VTp> __rebind_v;
|
||||
|
||||
public:
|
||||
typedef typename __rebind_v::other::const_pointer entry;
|
||||
|
||||
struct type : public Pred
|
||||
{
|
||||
inline
|
||||
type() { }
|
||||
|
||||
inline
|
||||
type(const Pred& other) : Pred(other) { }
|
||||
|
||||
inline bool
|
||||
operator()(entry p_v) const
|
||||
{ return Pred::operator()(*p_v); }
|
||||
};
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif // #ifndef PB_DS_BINARY_HEAP_ENTRY_PRED_HPP
|
||||
@@ -0,0 +1,208 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/erase_fn_imps.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
for (size_type i = 0; i < m_size; ++i)
|
||||
erase_at(m_a_entries, i, s_no_throw_copies_ind);
|
||||
|
||||
__try
|
||||
{
|
||||
const size_type new_size = resize_policy::get_new_size_for_arbitrary(0);
|
||||
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
|
||||
resize_policy::notify_arbitrary(new_size);
|
||||
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
|
||||
m_actual_size = new_size;
|
||||
m_a_entries = new_entries;
|
||||
}
|
||||
__catch(...)
|
||||
{ }
|
||||
|
||||
m_size = 0;
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_at(entry_pointer a_entries, size_type i, false_type)
|
||||
{
|
||||
a_entries[i]->~value_type();
|
||||
s_value_allocator.deallocate(a_entries[i], 1);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_at(entry_pointer, size_type, true_type)
|
||||
{ }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
pop()
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
_GLIBCXX_DEBUG_ASSERT(!empty());
|
||||
|
||||
pop_heap();
|
||||
erase_at(m_a_entries, m_size - 1, s_no_throw_copies_ind);
|
||||
resize_for_erase_if_needed();
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
--m_size;
|
||||
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Pred>
|
||||
typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_if(Pred pred)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
|
||||
typedef typename entry_pred<value_type, Pred, _Alloc, simple_value>::type
|
||||
pred_t;
|
||||
|
||||
const size_type left = partition(pred_t(pred));
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size >= left);
|
||||
const size_type ersd = m_size - left;
|
||||
for (size_type i = left; i < m_size; ++i)
|
||||
erase_at(m_a_entries, i, s_no_throw_copies_ind);
|
||||
|
||||
__try
|
||||
{
|
||||
const size_type new_size =
|
||||
resize_policy::get_new_size_for_arbitrary(left);
|
||||
|
||||
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
|
||||
std::copy(m_a_entries, m_a_entries + left, new_entries);
|
||||
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
|
||||
m_actual_size = new_size;
|
||||
resize_policy::notify_arbitrary(m_actual_size);
|
||||
}
|
||||
__catch(...)
|
||||
{ };
|
||||
|
||||
m_size = left;
|
||||
make_heap();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return ersd;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase(point_iterator it)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
_GLIBCXX_DEBUG_ASSERT(!empty());
|
||||
|
||||
const size_type fix_pos = it.m_p_e - m_a_entries;
|
||||
std::swap(*it.m_p_e, m_a_entries[m_size - 1]);
|
||||
erase_at(m_a_entries, m_size - 1, s_no_throw_copies_ind);
|
||||
resize_for_erase_if_needed();
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
--m_size;
|
||||
_GLIBCXX_DEBUG_ASSERT(fix_pos <= m_size);
|
||||
|
||||
if (fix_pos != m_size)
|
||||
fix(m_a_entries + fix_pos);
|
||||
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
resize_for_erase_if_needed()
|
||||
{
|
||||
if (!resize_policy::resize_needed_for_shrink(m_size))
|
||||
return;
|
||||
|
||||
__try
|
||||
{
|
||||
const size_type new_size = resize_policy::get_new_size_for_shrink();
|
||||
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
|
||||
resize_policy::notify_shrink_resize();
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size > 0);
|
||||
std::copy(m_a_entries, m_a_entries + m_size - 1, new_entries);
|
||||
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
|
||||
m_actual_size = new_size;
|
||||
m_a_entries = new_entries;
|
||||
}
|
||||
__catch(...)
|
||||
{ }
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Pred>
|
||||
typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
partition(Pred pred)
|
||||
{
|
||||
size_type left = 0;
|
||||
size_type right = m_size - 1;
|
||||
|
||||
while (right + 1 != left)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(left <= m_size);
|
||||
|
||||
if (!pred(m_a_entries[left]))
|
||||
++left;
|
||||
else if (pred(m_a_entries[right]))
|
||||
--right;
|
||||
else
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(left < right);
|
||||
std::swap(m_a_entries[left], m_a_entries[right]);
|
||||
++left;
|
||||
--right;
|
||||
}
|
||||
}
|
||||
|
||||
return left;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/find_fn_imps.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_reference
|
||||
PB_DS_CLASS_C_DEC::
|
||||
top() const
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
_GLIBCXX_DEBUG_ASSERT(!empty());
|
||||
return top_imp(s_no_throw_copies_ind);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_reference
|
||||
PB_DS_CLASS_C_DEC::
|
||||
top_imp(true_type) const
|
||||
{ return *m_a_entries; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_reference
|
||||
PB_DS_CLASS_C_DEC::
|
||||
top_imp(false_type) const
|
||||
{ return **m_a_entries; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
left_child(size_type i)
|
||||
{ return i * 2 + 1; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
right_child(size_type i)
|
||||
{ return i * 2 + 2; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
parent(size_type i)
|
||||
{ return (i - 1) / 2; }
|
||||
@@ -0,0 +1,58 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/info_fn_imps.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
empty() const
|
||||
{ return m_size == 0; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
size() const
|
||||
{ return m_size; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
max_size() const
|
||||
{ return s_entry_allocator.max_size(); }
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/insert_fn_imps.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
push(const_reference r_val)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
insert_value(r_val, s_no_throw_copies_ind);
|
||||
push_heap();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return point_iterator(m_a_entries);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_value(value_type val, true_type)
|
||||
{
|
||||
resize_for_insert_if_needed();
|
||||
m_a_entries[m_size++] = val;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_value(const_reference r_val, false_type)
|
||||
{
|
||||
resize_for_insert_if_needed();
|
||||
pointer p_new = s_value_allocator.allocate(1);
|
||||
cond_dealtor_t cond(p_new);
|
||||
new (p_new) value_type(r_val);
|
||||
cond.set_no_action();
|
||||
m_a_entries[m_size++] = p_new;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
resize_for_insert_if_needed()
|
||||
{
|
||||
if (!resize_policy::resize_needed_for_grow(m_size))
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size < m_actual_size);
|
||||
return;
|
||||
}
|
||||
|
||||
const size_type new_size = resize_policy::get_new_size_for_grow();
|
||||
entry_pointer new_entries = s_entry_allocator.allocate(new_size);
|
||||
resize_policy::notify_grow_resize();
|
||||
|
||||
std::copy(m_a_entries, m_a_entries + m_size, new_entries);
|
||||
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
|
||||
m_actual_size = new_size;
|
||||
m_a_entries = new_entries;
|
||||
make_heap();
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
modify(point_iterator it, const_reference r_new_val)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
swap_value_imp(it.m_p_e, r_new_val, s_no_throw_copies_ind);
|
||||
fix(it.m_p_e);
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
_GLIBCXX_DEBUG_ASSERT(is_heap());
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
fix(entry_pointer p_e)
|
||||
{
|
||||
size_type i = p_e - m_a_entries;
|
||||
if (i > 0 && entry_cmp::operator()(m_a_entries[parent(i)], m_a_entries[i]))
|
||||
{
|
||||
size_type parent_i = parent(i);
|
||||
while (i > 0
|
||||
&& entry_cmp::operator()(m_a_entries[parent_i], m_a_entries[i]))
|
||||
{
|
||||
std::swap(m_a_entries[i], m_a_entries[parent_i]);
|
||||
i = parent_i;
|
||||
parent_i = parent(i);
|
||||
}
|
||||
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return;
|
||||
}
|
||||
|
||||
while (i < m_size)
|
||||
{
|
||||
const size_type lchild_i = left_child(i);
|
||||
const size_type rchild_i = right_child(i);
|
||||
_GLIBCXX_DEBUG_ASSERT(rchild_i > lchild_i);
|
||||
|
||||
const bool smaller_than_lchild = lchild_i < m_size &&
|
||||
entry_cmp::operator()(m_a_entries[i], m_a_entries[lchild_i]);
|
||||
|
||||
const bool smaller_than_rchild = rchild_i < m_size &&
|
||||
entry_cmp::operator()(m_a_entries[i], m_a_entries[rchild_i]);
|
||||
|
||||
const bool swap_with_rchild = smaller_than_rchild && (!smaller_than_lchild || entry_cmp::operator()(m_a_entries[lchild_i], m_a_entries[rchild_i]));
|
||||
|
||||
const bool swap_with_lchild = !swap_with_rchild && smaller_than_lchild;
|
||||
|
||||
if (swap_with_lchild)
|
||||
{
|
||||
std::swap(m_a_entries[i], m_a_entries[lchild_i]);
|
||||
i = lchild_i;
|
||||
}
|
||||
else if (swap_with_rchild)
|
||||
{
|
||||
std::swap(m_a_entries[i], m_a_entries[rchild_i]);
|
||||
i = rchild_i;
|
||||
}
|
||||
else
|
||||
i = m_size;
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap_value_imp(entry_pointer p_e, value_type new_val, true_type)
|
||||
{ *p_e = new_val; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap_value_imp(entry_pointer p_e, const_reference r_new_val, false_type)
|
||||
{
|
||||
value_type tmp(r_new_val);
|
||||
(*p_e)->swap(tmp);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/iterators_fn_imps.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
begin()
|
||||
{ return iterator(m_a_entries); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
begin() const
|
||||
{ return const_iterator(m_a_entries); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
end()
|
||||
{ return iterator(m_a_entries + m_size); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
end() const
|
||||
{ return const_iterator(m_a_entries + m_size); }
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/point_const_iterator.hpp
|
||||
* Contains an iterator class returned by the table's const find and insert
|
||||
* methods.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
|
||||
#define PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP
|
||||
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Const point-type iterator.
|
||||
template<typename Value_Type, typename Entry, bool Simple,
|
||||
typename _Alloc>
|
||||
class binary_heap_point_const_iterator_
|
||||
{
|
||||
protected:
|
||||
typedef typename _Alloc::template rebind<Entry>::other::pointer entry_pointer;
|
||||
|
||||
public:
|
||||
/// Category.
|
||||
typedef trivial_iterator_tag iterator_category;
|
||||
|
||||
/// Difference type.
|
||||
typedef trivial_iterator_difference_type difference_type;
|
||||
|
||||
/// Iterator's value type.
|
||||
typedef Value_Type value_type;
|
||||
|
||||
/// Iterator's pointer type.
|
||||
typedef typename _Alloc::template rebind<value_type>::other::pointer
|
||||
pointer;
|
||||
|
||||
/// Iterator's const pointer type.
|
||||
typedef
|
||||
typename _Alloc::template rebind<value_type>::other::const_pointer
|
||||
const_pointer;
|
||||
|
||||
/// Iterator's reference type.
|
||||
typedef
|
||||
typename _Alloc::template rebind<value_type>::other::reference
|
||||
reference;
|
||||
|
||||
/// Iterator's const reference type.
|
||||
typedef
|
||||
typename _Alloc::template rebind<value_type>::other::const_reference
|
||||
const_reference;
|
||||
|
||||
inline
|
||||
binary_heap_point_const_iterator_(entry_pointer p_e) : m_p_e(p_e)
|
||||
{ }
|
||||
|
||||
/// Default constructor.
|
||||
inline
|
||||
binary_heap_point_const_iterator_() : m_p_e(0) { }
|
||||
|
||||
/// Copy constructor.
|
||||
inline
|
||||
binary_heap_point_const_iterator_(const binary_heap_point_const_iterator_& other)
|
||||
: m_p_e(other.m_p_e)
|
||||
{ }
|
||||
|
||||
/// Access.
|
||||
inline const_pointer
|
||||
operator->() const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
|
||||
return to_ptr(integral_constant<int, Simple>());
|
||||
}
|
||||
|
||||
/// Access.
|
||||
inline const_reference
|
||||
operator*() const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
|
||||
return *to_ptr(integral_constant<int, Simple>());
|
||||
}
|
||||
|
||||
/// Compares content to a different iterator object.
|
||||
inline bool
|
||||
operator==(const binary_heap_point_const_iterator_& other) const
|
||||
{ return m_p_e == other.m_p_e; }
|
||||
|
||||
/// Compares content (negatively) to a different iterator object.
|
||||
inline bool
|
||||
operator!=(const binary_heap_point_const_iterator_& other) const
|
||||
{ return m_p_e != other.m_p_e; }
|
||||
|
||||
private:
|
||||
inline const_pointer
|
||||
to_ptr(true_type) const
|
||||
{ return m_p_e; }
|
||||
|
||||
inline const_pointer
|
||||
to_ptr(false_type) const
|
||||
{ return *m_p_e; }
|
||||
|
||||
public:
|
||||
entry_pointer m_p_e;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/policy_access_fn_imps.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
Cmp_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_cmp_fn()
|
||||
{
|
||||
return (*this);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
const Cmp_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_cmp_fn() const
|
||||
{
|
||||
return (*this);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/resize_policy.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
|
||||
#define PB_DS_BINARY_HEAP_RESIZE_POLICY_HPP
|
||||
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Resize policy for binary heap.
|
||||
template<typename _Tp>
|
||||
class resize_policy
|
||||
{
|
||||
private:
|
||||
enum
|
||||
{
|
||||
ratio = 8,
|
||||
factor = 2
|
||||
};
|
||||
|
||||
/// Next shrink size.
|
||||
_Tp m_shrink_size;
|
||||
|
||||
/// Next grow size.
|
||||
_Tp m_grow_size;
|
||||
|
||||
public:
|
||||
typedef _Tp size_type;
|
||||
|
||||
static const _Tp min_size = 16;
|
||||
|
||||
resize_policy() : m_shrink_size(0), m_grow_size(min_size)
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
resize_policy(const resize_policy& other)
|
||||
: m_shrink_size(other.m_shrink_size), m_grow_size(other.m_grow_size)
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
inline void
|
||||
swap(resize_policy<_Tp>&);
|
||||
|
||||
inline bool
|
||||
resize_needed_for_grow(size_type) const;
|
||||
|
||||
inline bool
|
||||
resize_needed_for_shrink(size_type) const;
|
||||
|
||||
inline bool
|
||||
grow_needed(size_type) const;
|
||||
|
||||
inline bool
|
||||
shrink_needed(size_type) const;
|
||||
|
||||
inline size_type
|
||||
get_new_size_for_grow() const;
|
||||
|
||||
inline size_type
|
||||
get_new_size_for_shrink() const;
|
||||
|
||||
inline size_type
|
||||
get_new_size_for_arbitrary(size_type) const;
|
||||
|
||||
inline void
|
||||
notify_grow_resize();
|
||||
|
||||
inline void
|
||||
notify_shrink_resize();
|
||||
|
||||
void
|
||||
notify_arbitrary(size_type);
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid(const char*, int) const;
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
void
|
||||
trace() const;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
const _Tp resize_policy<_Tp>::min_size;
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
resize_policy<_Tp>::
|
||||
swap(resize_policy<_Tp>& other)
|
||||
{
|
||||
std::swap(m_shrink_size, other.m_shrink_size);
|
||||
std::swap(m_grow_size, other.m_grow_size);
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline bool
|
||||
resize_policy<_Tp>::
|
||||
resize_needed_for_grow(size_type size) const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(size <= m_grow_size);
|
||||
return size == m_grow_size;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline bool
|
||||
resize_policy<_Tp>::
|
||||
resize_needed_for_shrink(size_type size) const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(size <= m_grow_size);
|
||||
return size == m_shrink_size;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline typename resize_policy<_Tp>::size_type
|
||||
resize_policy<_Tp>::
|
||||
get_new_size_for_grow() const
|
||||
{ return m_grow_size * factor; }
|
||||
|
||||
template<typename _Tp>
|
||||
inline typename resize_policy<_Tp>::size_type
|
||||
resize_policy<_Tp>::
|
||||
get_new_size_for_shrink() const
|
||||
{
|
||||
const size_type half_size = m_grow_size / factor;
|
||||
return std::max(min_size, half_size);
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline typename resize_policy<_Tp>::size_type
|
||||
resize_policy<_Tp>::
|
||||
get_new_size_for_arbitrary(size_type size) const
|
||||
{
|
||||
size_type ret = min_size;
|
||||
while (ret < size)
|
||||
ret *= factor;
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
resize_policy<_Tp>::
|
||||
notify_grow_resize()
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
_GLIBCXX_DEBUG_ASSERT(m_grow_size >= min_size);
|
||||
m_grow_size *= factor;
|
||||
m_shrink_size = m_grow_size / ratio;
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
resize_policy<_Tp>::
|
||||
notify_shrink_resize()
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
m_shrink_size /= factor;
|
||||
if (m_shrink_size == 1)
|
||||
m_shrink_size = 0;
|
||||
m_grow_size = std::max(m_grow_size / factor, min_size);
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
inline void
|
||||
resize_policy<_Tp>::
|
||||
notify_arbitrary(size_type actual_size)
|
||||
{
|
||||
m_grow_size = actual_size;
|
||||
m_shrink_size = m_grow_size / ratio;
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
template<typename _Tp>
|
||||
void
|
||||
resize_policy<_Tp>::
|
||||
assert_valid(const char* __file, int __line) const
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(m_shrink_size == 0
|
||||
|| m_shrink_size * ratio == m_grow_size);
|
||||
PB_DS_DEBUG_VERIFY(m_grow_size >= min_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
template<typename _Tp>
|
||||
void
|
||||
resize_policy<_Tp>::
|
||||
trace() const
|
||||
{
|
||||
std::cerr << "shrink = " << m_shrink_size
|
||||
<< " grow = " << m_grow_size << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/split_join_fn_imps.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Pred>
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
|
||||
typedef
|
||||
typename entry_pred<value_type, Pred, _Alloc, simple_value>::type
|
||||
pred_t;
|
||||
|
||||
const size_type left = partition(pred_t(pred));
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size >= left);
|
||||
|
||||
const size_type ersd = m_size - left;
|
||||
_GLIBCXX_DEBUG_ASSERT(m_size >= ersd);
|
||||
|
||||
const size_type new_size = resize_policy::get_new_size_for_arbitrary(left);
|
||||
const size_type other_actual_size = other.get_new_size_for_arbitrary(ersd);
|
||||
|
||||
entry_pointer a_entries = 0;
|
||||
entry_pointer a_other_entries = 0;
|
||||
|
||||
__try
|
||||
{
|
||||
a_entries = s_entry_allocator.allocate(new_size);
|
||||
a_other_entries = s_entry_allocator.allocate(other_actual_size);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
if (a_entries != 0)
|
||||
s_entry_allocator.deallocate(a_entries, new_size);
|
||||
|
||||
if (a_other_entries != 0)
|
||||
s_entry_allocator.deallocate(a_other_entries, other_actual_size);
|
||||
|
||||
__throw_exception_again;
|
||||
};
|
||||
|
||||
for (size_type i = 0; i < other.m_size; ++i)
|
||||
erase_at(other.m_a_entries, i, s_no_throw_copies_ind);
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(new_size >= left);
|
||||
std::copy(m_a_entries, m_a_entries + left, a_entries);
|
||||
std::copy(m_a_entries + left, m_a_entries + m_size, a_other_entries);
|
||||
|
||||
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
|
||||
s_entry_allocator.deallocate(other.m_a_entries, other.m_actual_size);
|
||||
|
||||
m_actual_size = new_size;
|
||||
other.m_actual_size = other_actual_size;
|
||||
|
||||
m_size = left;
|
||||
other.m_size = ersd;
|
||||
|
||||
m_a_entries = a_entries;
|
||||
other.m_a_entries = a_other_entries;
|
||||
|
||||
make_heap();
|
||||
other.make_heap();
|
||||
|
||||
resize_policy::notify_arbitrary(m_actual_size);
|
||||
other.notify_arbitrary(other.m_actual_size);
|
||||
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
join(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
|
||||
const size_type len = m_size + other.m_size;
|
||||
const size_type new_size = resize_policy::get_new_size_for_arbitrary(len);
|
||||
|
||||
entry_pointer a_entries = 0;
|
||||
entry_pointer a_other_entries = 0;
|
||||
|
||||
__try
|
||||
{
|
||||
a_entries = s_entry_allocator.allocate(new_size);
|
||||
a_other_entries = s_entry_allocator.allocate(resize_policy::min_size);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
if (a_entries != 0)
|
||||
s_entry_allocator.deallocate(a_entries, new_size);
|
||||
|
||||
if (a_other_entries != 0)
|
||||
s_entry_allocator.deallocate(a_other_entries, resize_policy::min_size);
|
||||
|
||||
__throw_exception_again;
|
||||
}
|
||||
|
||||
std::copy(m_a_entries, m_a_entries + m_size, a_entries);
|
||||
std::copy(other.m_a_entries, other.m_a_entries + other.m_size,
|
||||
a_entries + m_size);
|
||||
|
||||
s_entry_allocator.deallocate(m_a_entries, m_actual_size);
|
||||
m_a_entries = a_entries;
|
||||
m_size = len;
|
||||
m_actual_size = new_size;
|
||||
resize_policy::notify_arbitrary(new_size);
|
||||
make_heap();
|
||||
|
||||
s_entry_allocator.deallocate(other.m_a_entries, other.m_actual_size);
|
||||
other.m_a_entries = a_other_entries;
|
||||
other.m_size = 0;
|
||||
other.m_actual_size = resize_policy::min_size;
|
||||
other.notify_arbitrary(resize_policy::min_size);
|
||||
other.make_heap();
|
||||
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binary_heap_/trace_fn_imps.hpp
|
||||
* Contains an implementation class for a binary_heap.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
trace() const
|
||||
{
|
||||
std::cerr << this << std::endl;
|
||||
|
||||
std::cerr << m_a_entries << std::endl;
|
||||
|
||||
for (size_type i = 0; i < m_size; ++i)
|
||||
trace_entry(m_a_entries[i], s_no_throw_copies_ind);
|
||||
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::cerr << "size = " << m_size << " " << "actual_size = " << m_actual_size << std::endl;
|
||||
|
||||
resize_policy::trace();
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
trace_entry(const entry& r_e, false_type) const
|
||||
{
|
||||
std::cout << r_e << " " <<* r_e << std::endl;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
trace_entry(const entry& r_e, true_type) const
|
||||
{
|
||||
std::cout << r_e << std::endl;
|
||||
}
|
||||
|
||||
#endif // #ifdef PB_DS_BINARY_HEAP_TRACE_
|
||||
@@ -0,0 +1,112 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binomial_heap_.hpp
|
||||
* Contains an implementation class for a binomial heap.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Binomial heap.
|
||||
* Vuillemin J is the mastah.
|
||||
* Modified from CLRS.
|
||||
*/
|
||||
|
||||
#include <debug/debug.h>
|
||||
#include <ext/pb_ds/detail/cond_dealtor.hpp>
|
||||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binomial_heap<Value_Type, Cmp_Fn, _Alloc>
|
||||
|
||||
/**
|
||||
* Binomial heap.
|
||||
*
|
||||
* @ingroup heap-detail
|
||||
*/
|
||||
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
|
||||
class binomial_heap
|
||||
: public binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>
|
||||
{
|
||||
private:
|
||||
typedef binomial_heap_base<Value_Type, Cmp_Fn, _Alloc> base_type;
|
||||
typedef typename base_type::node_pointer node_pointer;
|
||||
typedef typename base_type::node_const_pointer node_const_pointer;
|
||||
|
||||
public:
|
||||
typedef Value_Type value_type;
|
||||
typedef typename _Alloc::size_type size_type;
|
||||
typedef typename _Alloc::difference_type difference_type;
|
||||
typedef typename base_type::pointer pointer;
|
||||
typedef typename base_type::const_pointer const_pointer;
|
||||
typedef typename base_type::reference reference;
|
||||
typedef typename base_type::const_reference const_reference;
|
||||
typedef typename base_type::point_const_iterator point_const_iterator;
|
||||
typedef typename base_type::point_iterator point_iterator;
|
||||
typedef typename base_type::const_iterator const_iterator;
|
||||
typedef typename base_type::iterator iterator;
|
||||
typedef typename base_type::cmp_fn cmp_fn;
|
||||
typedef typename base_type::allocator_type allocator_type;
|
||||
|
||||
binomial_heap();
|
||||
|
||||
binomial_heap(const Cmp_Fn&);
|
||||
|
||||
binomial_heap(const binomial_heap&);
|
||||
|
||||
~binomial_heap();
|
||||
|
||||
protected:
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid(const char*, int) const;
|
||||
#endif
|
||||
};
|
||||
|
||||
#include <ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
@@ -0,0 +1,60 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file detail/binomial_heap_/constructors_destructor_fn_imps.hpp
|
||||
* Contains an implementation for binomial_heap_.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binomial_heap()
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binomial_heap(const Cmp_Fn& r_cmp_fn)
|
||||
: base_type(r_cmp_fn)
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binomial_heap(const PB_DS_CLASS_C_DEC& other)
|
||||
: base_type(other)
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~binomial_heap() { }
|
||||
@@ -0,0 +1,49 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file detail/binomial_heap_/debug_fn_imps.hpp
|
||||
* Contains an implementation for binomial_heap_.
|
||||
*/
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid(const char* __file, int __line) const
|
||||
{ base_type::assert_valid(true, __file, __line); }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,211 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binomial_heap_base_/binomial_heap_base_.hpp
|
||||
* Contains an implementation class for a base of binomial heaps.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BINOMIAL_HEAP_BASE_HPP
|
||||
#define PB_DS_BINOMIAL_HEAP_BASE_HPP
|
||||
|
||||
/*
|
||||
* Binomial heap base.
|
||||
* Vuillemin J is the mastah.
|
||||
* Modified from CLRS.
|
||||
*/
|
||||
|
||||
#include <debug/debug.h>
|
||||
#include <ext/pb_ds/detail/cond_dealtor.hpp>
|
||||
#include <ext/pb_ds/detail/type_utils.hpp>
|
||||
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_B_HEAP_BASE \
|
||||
left_child_next_sibling_heap<Value_Type, Cmp_Fn, \
|
||||
typename _Alloc::size_type, _Alloc, false>
|
||||
#else
|
||||
#define PB_DS_B_HEAP_BASE \
|
||||
left_child_next_sibling_heap<Value_Type, Cmp_Fn, \
|
||||
typename _Alloc::size_type, _Alloc>
|
||||
#endif
|
||||
|
||||
/// Base class for binomial heap.
|
||||
template<typename Value_Type, typename Cmp_Fn, typename _Alloc>
|
||||
class binomial_heap_base
|
||||
: public PB_DS_B_HEAP_BASE
|
||||
{
|
||||
private:
|
||||
typedef typename _Alloc::template rebind<Value_Type>::other __rebind_v;
|
||||
typedef PB_DS_B_HEAP_BASE base_type;
|
||||
|
||||
protected:
|
||||
typedef typename base_type::node node;
|
||||
typedef typename base_type::node_pointer node_pointer;
|
||||
typedef typename base_type::node_const_pointer node_const_pointer;
|
||||
|
||||
public:
|
||||
typedef Value_Type value_type;
|
||||
typedef Cmp_Fn cmp_fn;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef typename _Alloc::size_type size_type;
|
||||
typedef typename _Alloc::difference_type difference_type;
|
||||
|
||||
typedef typename __rebind_v::pointer pointer;
|
||||
typedef typename __rebind_v::const_pointer const_pointer;
|
||||
typedef typename __rebind_v::reference reference;
|
||||
typedef typename __rebind_v::const_reference const_reference;
|
||||
|
||||
typedef typename base_type::point_const_iterator point_const_iterator;
|
||||
typedef typename base_type::point_iterator point_iterator;
|
||||
typedef typename base_type::const_iterator const_iterator;
|
||||
typedef typename base_type::iterator iterator;
|
||||
|
||||
public:
|
||||
|
||||
inline point_iterator
|
||||
push(const_reference);
|
||||
|
||||
void
|
||||
modify(point_iterator, const_reference);
|
||||
|
||||
inline const_reference
|
||||
top() const;
|
||||
|
||||
void
|
||||
pop();
|
||||
|
||||
void
|
||||
erase(point_iterator);
|
||||
|
||||
inline void
|
||||
clear();
|
||||
|
||||
template<typename Pred>
|
||||
size_type
|
||||
erase_if(Pred);
|
||||
|
||||
template<typename Pred>
|
||||
void
|
||||
split(Pred, PB_DS_CLASS_C_DEC&);
|
||||
|
||||
void
|
||||
join(PB_DS_CLASS_C_DEC&);
|
||||
|
||||
protected:
|
||||
|
||||
binomial_heap_base();
|
||||
|
||||
binomial_heap_base(const Cmp_Fn&);
|
||||
|
||||
binomial_heap_base(const PB_DS_CLASS_C_DEC&);
|
||||
|
||||
void
|
||||
swap(PB_DS_CLASS_C_DEC&);
|
||||
|
||||
~binomial_heap_base();
|
||||
|
||||
template<typename It>
|
||||
void
|
||||
copy_from_range(It, It);
|
||||
|
||||
inline void
|
||||
find_max();
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid(bool, const char*, int) const;
|
||||
|
||||
void
|
||||
assert_max(const char*, int) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
inline node_pointer
|
||||
fix(node_pointer) const;
|
||||
|
||||
inline void
|
||||
insert_node(node_pointer);
|
||||
|
||||
inline void
|
||||
remove_parentless_node(node_pointer);
|
||||
|
||||
inline node_pointer
|
||||
join(node_pointer, node_pointer) const;
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_node_consistent(node_const_pointer, bool, bool,
|
||||
const char*, int) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
node_pointer m_p_max;
|
||||
};
|
||||
|
||||
#define PB_DS_ASSERT_VALID_COND(X, _StrictlyBinomial) \
|
||||
_GLIBCXX_DEBUG_ONLY(X.assert_valid(_StrictlyBinomial,__FILE__, __LINE__);)
|
||||
|
||||
#define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node, _Bool) \
|
||||
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \
|
||||
__FILE__, __LINE__);)
|
||||
|
||||
#include <ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT
|
||||
#undef PB_DS_ASSERT_VALID_COND
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_B_HEAP_BASE
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binomial_heap_base_/constructors_destructor_fn_imps.hpp
|
||||
* Contains an implementation class for a base of binomial heaps.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename It>
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
copy_from_range(It first_it, It last_it)
|
||||
{
|
||||
while (first_it != last_it)
|
||||
push(*(first_it++));
|
||||
PB_DS_ASSERT_VALID_COND((*this),false)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binomial_heap_base() : m_p_max(0)
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),false)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binomial_heap_base(const Cmp_Fn& r_cmp_fn)
|
||||
: base_type(r_cmp_fn), m_p_max(0)
|
||||
{ PB_DS_ASSERT_VALID_COND((*this),false) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
binomial_heap_base(const PB_DS_CLASS_C_DEC& other)
|
||||
: base_type(other), m_p_max(0)
|
||||
{ PB_DS_ASSERT_VALID_COND((*this),false) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),false)
|
||||
base_type::swap(other);
|
||||
std::swap(m_p_max, other.m_p_max);
|
||||
PB_DS_ASSERT_VALID_COND((*this),false)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~binomial_heap_base()
|
||||
{ }
|
||||
@@ -0,0 +1,100 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binomial_heap_base_/debug_fn_imps.hpp
|
||||
* Contains an implementation class for a base of binomial heaps.
|
||||
*/
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid(bool strictly_binomial, const char* __file, int __line) const
|
||||
{
|
||||
base_type::assert_valid(__file, __line);
|
||||
assert_node_consistent(base_type::m_p_root, strictly_binomial, true,
|
||||
__file, __line);
|
||||
assert_max(__file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_max(const char* __file, int __line) const
|
||||
{
|
||||
if (m_p_max == 0)
|
||||
return;
|
||||
PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0);
|
||||
for (const_iterator it = base_type::begin(); it != base_type::end(); ++it)
|
||||
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(m_p_max->m_value,
|
||||
it.m_p_nd->m_value));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_node_consistent(node_const_pointer p_nd, bool strictly_binomial,
|
||||
bool increasing, const char* __file, int __line) const
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(increasing || strictly_binomial);
|
||||
base_type::assert_node_consistent(p_nd, false, __file, __line);
|
||||
if (p_nd == 0)
|
||||
return;
|
||||
PB_DS_DEBUG_VERIFY(p_nd->m_metadata == base_type::degree(p_nd));
|
||||
PB_DS_DEBUG_VERIFY(base_type::size_under_node(p_nd) ==
|
||||
static_cast<size_type>(1 << p_nd->m_metadata));
|
||||
assert_node_consistent(p_nd->m_p_next_sibling, strictly_binomial, increasing,
|
||||
__file, __line);
|
||||
assert_node_consistent(p_nd->m_p_l_child, true, false, __file, __line);
|
||||
if (p_nd->m_p_next_sibling != 0)
|
||||
{
|
||||
if (increasing)
|
||||
{
|
||||
if (strictly_binomial)
|
||||
PB_DS_DEBUG_VERIFY(p_nd->m_metadata
|
||||
< p_nd->m_p_next_sibling->m_metadata);
|
||||
else
|
||||
PB_DS_DEBUG_VERIFY(p_nd->m_metadata
|
||||
<= p_nd->m_p_next_sibling->m_metadata);
|
||||
}
|
||||
else
|
||||
PB_DS_DEBUG_VERIFY(p_nd->m_metadata
|
||||
> p_nd->m_p_next_sibling->m_metadata);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,161 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binomial_heap_base_/erase_fn_imps.hpp
|
||||
* Contains an implementation class for a base of binomial heaps.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
pop()
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
|
||||
if (m_p_max == 0)
|
||||
find_max();
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
|
||||
node_pointer p_nd = m_p_max;
|
||||
remove_parentless_node(m_p_max);
|
||||
base_type::actual_erase_node(p_nd);
|
||||
m_p_max = 0;
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
remove_parentless_node(node_pointer p_nd)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::parent(p_nd) == 0);
|
||||
|
||||
node_pointer p_cur_root = p_nd == base_type::m_p_root?
|
||||
p_nd->m_p_next_sibling : base_type::m_p_root;
|
||||
|
||||
if (p_cur_root != 0)
|
||||
p_cur_root->m_p_prev_or_parent = 0;
|
||||
|
||||
if (p_nd->m_p_prev_or_parent != 0)
|
||||
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd->m_p_next_sibling;
|
||||
|
||||
if (p_nd->m_p_next_sibling != 0)
|
||||
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
|
||||
|
||||
node_pointer p_child = p_nd->m_p_l_child;
|
||||
if (p_child != 0)
|
||||
{
|
||||
p_child->m_p_prev_or_parent = 0;
|
||||
while (p_child->m_p_next_sibling != 0)
|
||||
p_child = p_child->m_p_next_sibling;
|
||||
}
|
||||
|
||||
m_p_max = 0;
|
||||
base_type::m_p_root = join(p_cur_root, p_child);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
base_type::clear();
|
||||
m_p_max = 0;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase(point_iterator it)
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
|
||||
base_type::bubble_to_top(it.m_p_nd);
|
||||
remove_parentless_node(it.m_p_nd);
|
||||
base_type::actual_erase_node(it.m_p_nd);
|
||||
m_p_max = 0;
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Pred>
|
||||
typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_if(Pred pred)
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
|
||||
if (base_type::empty())
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
return 0;
|
||||
}
|
||||
|
||||
base_type::to_linked_list();
|
||||
node_pointer p_out = base_type::prune(pred);
|
||||
size_type ersd = 0;
|
||||
while (p_out != 0)
|
||||
{
|
||||
++ersd;
|
||||
node_pointer p_next = p_out->m_p_next_sibling;
|
||||
base_type::actual_erase_node(p_out);
|
||||
p_out = p_next;
|
||||
}
|
||||
|
||||
node_pointer p_cur = base_type::m_p_root;
|
||||
base_type::m_p_root = 0;
|
||||
while (p_cur != 0)
|
||||
{
|
||||
node_pointer p_next = p_cur->m_p_next_sibling;
|
||||
p_cur->m_p_l_child = p_cur->m_p_prev_or_parent = 0;
|
||||
p_cur->m_metadata = 0;
|
||||
p_cur->m_p_next_sibling = base_type::m_p_root;
|
||||
|
||||
if (base_type::m_p_root != 0)
|
||||
base_type::m_p_root->m_p_prev_or_parent = p_cur;
|
||||
|
||||
base_type::m_p_root = p_cur;
|
||||
base_type::m_p_root = fix(base_type::m_p_root);
|
||||
p_cur = p_next;
|
||||
}
|
||||
|
||||
m_p_max = 0;
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
return ersd;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binomial_heap_base_/find_fn_imps.hpp
|
||||
* Contains an implementation class for a base of binomial heaps.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_reference
|
||||
PB_DS_CLASS_C_DEC::
|
||||
top() const
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),false)
|
||||
_GLIBCXX_DEBUG_ASSERT(!base_type::empty());
|
||||
|
||||
if (m_p_max == 0)
|
||||
const_cast<PB_DS_CLASS_C_DEC* >(this)->find_max();
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0);
|
||||
return m_p_max->m_value;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find_max()
|
||||
{
|
||||
node_pointer p_cur = base_type::m_p_root;
|
||||
m_p_max = p_cur;
|
||||
while (p_cur != 0)
|
||||
{
|
||||
if (Cmp_Fn::operator()(m_p_max->m_value, p_cur->m_value))
|
||||
m_p_max = p_cur;
|
||||
p_cur = p_cur->m_p_next_sibling;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binomial_heap_base_/insert_fn_imps.hpp
|
||||
* Contains an implementation class for a base of binomial heaps.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
push(const_reference r_val)
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
node_pointer p_nd = base_type::get_new_node_for_insert(r_val);
|
||||
insert_node(p_nd);
|
||||
m_p_max = 0;
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
return point_iterator(p_nd);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_node(node_pointer p_nd)
|
||||
{
|
||||
if (base_type::m_p_root == 0)
|
||||
{
|
||||
p_nd->m_p_next_sibling = 0;
|
||||
p_nd->m_p_prev_or_parent = 0;
|
||||
p_nd->m_p_l_child = 0;
|
||||
p_nd->m_metadata = 0;
|
||||
base_type::m_p_root = p_nd;
|
||||
return;
|
||||
}
|
||||
|
||||
if (base_type::m_p_root->m_metadata > 0)
|
||||
{
|
||||
p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0;
|
||||
p_nd->m_p_next_sibling = base_type::m_p_root;
|
||||
base_type::m_p_root->m_p_prev_or_parent = p_nd;
|
||||
base_type::m_p_root = p_nd;
|
||||
p_nd->m_metadata = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value))
|
||||
{
|
||||
p_nd->m_p_next_sibling = base_type::m_p_root->m_p_next_sibling;
|
||||
p_nd->m_p_prev_or_parent = 0;
|
||||
p_nd->m_metadata = 1;
|
||||
p_nd->m_p_l_child = base_type::m_p_root;
|
||||
base_type::m_p_root->m_p_prev_or_parent = p_nd;
|
||||
base_type::m_p_root->m_p_next_sibling = 0;
|
||||
base_type::m_p_root = p_nd;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_nd->m_p_next_sibling = 0;
|
||||
p_nd->m_p_l_child = 0;
|
||||
p_nd->m_p_prev_or_parent = base_type::m_p_root;
|
||||
p_nd->m_metadata = 0;
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_root->m_p_l_child == 0);
|
||||
base_type::m_p_root->m_p_l_child = p_nd;
|
||||
base_type::m_p_root->m_metadata = 1;
|
||||
}
|
||||
|
||||
base_type::m_p_root = fix(base_type::m_p_root);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::node_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
fix(node_pointer p_nd) const
|
||||
{
|
||||
while (p_nd->m_p_next_sibling != 0 &&
|
||||
p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata)
|
||||
{
|
||||
node_pointer p_next = p_nd->m_p_next_sibling;
|
||||
if (Cmp_Fn::operator()(p_nd->m_value, p_next->m_value))
|
||||
{
|
||||
p_next->m_p_prev_or_parent = p_nd->m_p_prev_or_parent;
|
||||
|
||||
if (p_nd->m_p_prev_or_parent != 0)
|
||||
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_next;
|
||||
|
||||
base_type::make_child_of(p_nd, p_next);
|
||||
++p_next->m_metadata;
|
||||
p_nd = p_next;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_nd->m_p_next_sibling = p_next->m_p_next_sibling;
|
||||
|
||||
if (p_nd->m_p_next_sibling != 0)
|
||||
p_next->m_p_next_sibling = 0;
|
||||
|
||||
base_type::make_child_of(p_next, p_nd);
|
||||
++p_nd->m_metadata;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_nd->m_p_next_sibling != 0)
|
||||
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd;
|
||||
|
||||
return p_nd;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
modify(point_iterator it, const_reference r_new_val)
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
node_pointer p_nd = it.m_p_nd;
|
||||
|
||||
_GLIBCXX_DEBUG_ASSERT(p_nd != 0);
|
||||
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd, false)
|
||||
|
||||
const bool bubble_up = Cmp_Fn::operator()(p_nd->m_value, r_new_val);
|
||||
p_nd->m_value = r_new_val;
|
||||
|
||||
if (bubble_up)
|
||||
{
|
||||
node_pointer p_parent = base_type::parent(p_nd);
|
||||
while (p_parent != 0 &&
|
||||
Cmp_Fn::operator()(p_parent->m_value, p_nd->m_value))
|
||||
{
|
||||
base_type::swap_with_parent(p_nd, p_parent);
|
||||
p_parent = base_type::parent(p_nd);
|
||||
}
|
||||
|
||||
if (p_nd->m_p_prev_or_parent == 0)
|
||||
base_type::m_p_root = p_nd;
|
||||
|
||||
m_p_max = 0;
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
return;
|
||||
}
|
||||
|
||||
base_type::bubble_to_top(p_nd);
|
||||
remove_parentless_node(p_nd);
|
||||
insert_node(p_nd);
|
||||
m_p_max = 0;
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file binomial_heap_base_/split_join_fn_imps.hpp
|
||||
* Contains an implementation class for a base of binomial heaps.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Pred>
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
split(Pred pred, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
PB_DS_ASSERT_VALID_COND(other,true)
|
||||
|
||||
other.clear();
|
||||
if (base_type::empty())
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
PB_DS_ASSERT_VALID_COND(other,true)
|
||||
return;
|
||||
}
|
||||
|
||||
base_type::to_linked_list();
|
||||
node_pointer p_out = base_type::prune(pred);
|
||||
while (p_out != 0)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(base_type::m_size > 0);
|
||||
--base_type::m_size;
|
||||
++other.m_size;
|
||||
|
||||
node_pointer p_next = p_out->m_p_next_sibling;
|
||||
p_out->m_p_l_child = p_out->m_p_prev_or_parent = 0;
|
||||
p_out->m_metadata = 0;
|
||||
|
||||
p_out->m_p_next_sibling = other.m_p_root;
|
||||
if (other.m_p_root != 0)
|
||||
other.m_p_root->m_p_prev_or_parent = p_out;
|
||||
|
||||
other.m_p_root = p_out;
|
||||
other.m_p_root = other.fix(other.m_p_root);
|
||||
p_out = p_next;
|
||||
}
|
||||
|
||||
PB_DS_ASSERT_VALID_COND(other,true)
|
||||
node_pointer p_cur = base_type::m_p_root;
|
||||
base_type::m_p_root = 0;
|
||||
|
||||
while (p_cur != 0)
|
||||
{
|
||||
node_pointer p_next = p_cur->m_p_next_sibling;
|
||||
p_cur->m_p_l_child = p_cur->m_p_prev_or_parent = 0;
|
||||
p_cur->m_metadata = 0;
|
||||
p_cur->m_p_next_sibling = base_type::m_p_root;
|
||||
|
||||
if (base_type::m_p_root != 0)
|
||||
base_type::m_p_root->m_p_prev_or_parent = p_cur;
|
||||
|
||||
base_type::m_p_root = p_cur;
|
||||
base_type::m_p_root = fix(base_type::m_p_root);
|
||||
p_cur = p_next;
|
||||
}
|
||||
|
||||
m_p_max = 0;
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
PB_DS_ASSERT_VALID_COND(other,true)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
join(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
PB_DS_ASSERT_VALID_COND(other,true)
|
||||
|
||||
node_pointer p_other = other.m_p_root;
|
||||
if (p_other != 0)
|
||||
do
|
||||
{
|
||||
node_pointer p_next = p_other->m_p_next_sibling;
|
||||
std::swap(p_other->m_p_next_sibling, p_other->m_p_prev_or_parent);
|
||||
p_other = p_next;
|
||||
}
|
||||
while (p_other != 0);
|
||||
|
||||
base_type::m_p_root = join(base_type::m_p_root, other.m_p_root);
|
||||
base_type::m_size += other.m_size;
|
||||
m_p_max = 0;
|
||||
|
||||
other.m_p_root = 0;
|
||||
other.m_size = 0;
|
||||
other.m_p_max = 0;
|
||||
|
||||
PB_DS_ASSERT_VALID_COND((*this),true)
|
||||
PB_DS_ASSERT_VALID_COND(other,true)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::node_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
join(node_pointer p_lhs, node_pointer p_rhs) const
|
||||
{
|
||||
node_pointer p_ret = 0;
|
||||
node_pointer p_cur = 0;
|
||||
|
||||
while (p_lhs != 0 || p_rhs != 0)
|
||||
{
|
||||
if (p_rhs == 0)
|
||||
{
|
||||
if (p_cur == 0)
|
||||
p_ret = p_cur = p_lhs;
|
||||
else
|
||||
{
|
||||
p_cur->m_p_next_sibling = p_lhs;
|
||||
p_lhs->m_p_prev_or_parent = p_cur;
|
||||
}
|
||||
p_cur = p_lhs = 0;
|
||||
}
|
||||
else if (p_lhs == 0 || p_rhs->m_metadata < p_lhs->m_metadata)
|
||||
{
|
||||
if (p_cur == 0)
|
||||
{
|
||||
p_ret = p_cur = p_rhs;
|
||||
p_rhs = p_rhs->m_p_prev_or_parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_cur->m_p_next_sibling = p_rhs;
|
||||
p_rhs = p_rhs->m_p_prev_or_parent;
|
||||
p_cur->m_p_next_sibling->m_p_prev_or_parent = p_cur;
|
||||
p_cur = p_cur->m_p_next_sibling;
|
||||
}
|
||||
}
|
||||
else if (p_lhs->m_metadata < p_rhs->m_metadata)
|
||||
{
|
||||
if (p_cur == 0)
|
||||
p_ret = p_cur = p_lhs;
|
||||
else
|
||||
{
|
||||
p_cur->m_p_next_sibling = p_lhs;
|
||||
p_lhs->m_p_prev_or_parent = p_cur;
|
||||
p_cur = p_cur->m_p_next_sibling;
|
||||
}
|
||||
p_lhs = p_cur->m_p_next_sibling;
|
||||
}
|
||||
else
|
||||
{
|
||||
node_pointer p_next_rhs = p_rhs->m_p_prev_or_parent;
|
||||
p_rhs->m_p_next_sibling = p_lhs;
|
||||
p_lhs = fix(p_rhs);
|
||||
p_rhs = p_next_rhs;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_cur != 0)
|
||||
p_cur->m_p_next_sibling = 0;
|
||||
|
||||
if (p_ret != 0)
|
||||
p_ret->m_p_prev_or_parent = 0;
|
||||
|
||||
return p_ret;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file branch_policy/branch_policy.hpp
|
||||
* Contains a base class for branch policies.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_BRANCH_POLICY_BASE_HPP
|
||||
#define PB_DS_BRANCH_POLICY_BASE_HPP
|
||||
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Primary template, base class for branch structure policies.
|
||||
template<typename Node_CItr, typename Node_Itr, typename _Alloc>
|
||||
struct branch_policy
|
||||
{
|
||||
protected:
|
||||
typedef typename Node_Itr::value_type it_type;
|
||||
typedef typename std::iterator_traits<it_type>::value_type value_type;
|
||||
typedef typename value_type::first_type key_type;
|
||||
|
||||
typedef typename remove_const<value_type>::type rcvalue_type;
|
||||
typedef typename remove_const<key_type>::type rckey_type;
|
||||
|
||||
typedef typename _Alloc::template rebind<rcvalue_type>::other rebind_v;
|
||||
typedef typename _Alloc::template rebind<rckey_type>::other rebind_k;
|
||||
|
||||
typedef typename rebind_v::reference reference;
|
||||
typedef typename rebind_v::const_reference const_reference;
|
||||
typedef typename rebind_v::const_pointer const_pointer;
|
||||
|
||||
typedef typename rebind_k::const_reference key_const_reference;
|
||||
|
||||
static inline key_const_reference
|
||||
extract_key(const_reference r_val)
|
||||
{ return r_val.first; }
|
||||
|
||||
virtual it_type
|
||||
end() = 0;
|
||||
|
||||
it_type
|
||||
end_iterator() const
|
||||
{ return const_cast<branch_policy*>(this)->end(); }
|
||||
|
||||
virtual
|
||||
~branch_policy() { }
|
||||
};
|
||||
|
||||
/// Specialization for const iterators.
|
||||
template<typename Node_CItr, typename _Alloc>
|
||||
struct branch_policy<Node_CItr, Node_CItr, _Alloc>
|
||||
{
|
||||
protected:
|
||||
typedef typename Node_CItr::value_type it_type;
|
||||
typedef typename std::iterator_traits<it_type>::value_type value_type;
|
||||
typedef typename remove_const<value_type>::type rcvalue_type;
|
||||
typedef typename _Alloc::template rebind<rcvalue_type>::other rebind_v;
|
||||
typedef typename rebind_v::reference reference;
|
||||
typedef typename rebind_v::const_reference const_reference;
|
||||
typedef typename rebind_v::const_pointer const_pointer;
|
||||
|
||||
typedef value_type key_type;
|
||||
typedef typename rebind_v::const_reference key_const_reference;
|
||||
|
||||
static inline key_const_reference
|
||||
extract_key(const_reference r_val)
|
||||
{ return r_val; }
|
||||
|
||||
virtual it_type
|
||||
end() const = 0;
|
||||
|
||||
it_type
|
||||
end_iterator() const
|
||||
{ return end(); }
|
||||
|
||||
virtual
|
||||
~branch_policy() { }
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif // #ifndef PB_DS_BRANCH_POLICY_BASE_HPP
|
||||
@@ -0,0 +1,66 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file branch_policy/null_node_metadata.hpp
|
||||
* Contains an implementation class for tree-like classes.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_0_NODE_METADATA_HPP
|
||||
#define PB_DS_0_NODE_METADATA_HPP
|
||||
|
||||
#include <ext/pb_ds/detail/types_traits.hpp>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Constant node iterator.
|
||||
template<typename Key, typename Data, typename _Alloc>
|
||||
struct dumnode_const_iterator
|
||||
{
|
||||
private:
|
||||
typedef types_traits<Key, Data, _Alloc, false> __traits_type;
|
||||
typedef typename __traits_type::pointer const_iterator;
|
||||
|
||||
public:
|
||||
typedef const_iterator value_type;
|
||||
typedef const_iterator const_reference;
|
||||
typedef const_reference reference;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file branch_policy/traits.hpp
|
||||
* Contains an implementation class for tree-like classes.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_NODE_AND_IT_TRAITS_HPP
|
||||
#define PB_DS_NODE_AND_IT_TRAITS_HPP
|
||||
|
||||
#include <ext/pb_ds/detail/types_traits.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/traits.hpp>
|
||||
#include <ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp>
|
||||
#include <ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp>
|
||||
|
||||
#define PB_DS_DEBUG_VERIFY(_Cond) \
|
||||
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
|
||||
_M_message(#_Cond" assertion from %1;:%2;") \
|
||||
._M_string(__FILE__)._M_integer(__LINE__) \
|
||||
,__file,__line)
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Tree traits class, primary template.
|
||||
template<typename Key,
|
||||
typename Data,
|
||||
typename Cmp_Fn,
|
||||
template<typename Node_CItr,
|
||||
typename Node_Itr,
|
||||
typename Cmp_Fn_,
|
||||
typename _Alloc>
|
||||
class Node_Update,
|
||||
typename Tag,
|
||||
typename _Alloc>
|
||||
struct tree_traits;
|
||||
|
||||
/// Trie traits class, primary template.
|
||||
template<typename Key,
|
||||
typename Data,
|
||||
typename _ATraits,
|
||||
template<typename Node_CItr,
|
||||
typename Node_Itr,
|
||||
typename _ATraits_,
|
||||
typename _Alloc>
|
||||
class Node_Update,
|
||||
typename Tag,
|
||||
typename _Alloc>
|
||||
struct trie_traits;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#include <ext/pb_ds/detail/rb_tree_map_/traits.hpp>
|
||||
#include <ext/pb_ds/detail/splay_tree_/traits.hpp>
|
||||
#include <ext/pb_ds/detail/ov_tree_map_/traits.hpp>
|
||||
#include <ext/pb_ds/detail/pat_trie_/traits.hpp>
|
||||
|
||||
#undef PB_DS_DEBUG_VERIFY
|
||||
|
||||
#endif // #ifndef PB_DS_NODE_AND_IT_TRAITS_HPP
|
||||
@@ -0,0 +1,679 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/cc_ht_map_.hpp
|
||||
* Contains an implementation class for cc_ht_map_.
|
||||
*/
|
||||
|
||||
#include <utility>
|
||||
#include <iterator>
|
||||
#include <ext/pb_ds/detail/cond_dealtor.hpp>
|
||||
#include <ext/pb_ds/tag_and_trait.hpp>
|
||||
#include <ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp>
|
||||
#include <ext/pb_ds/detail/types_traits.hpp>
|
||||
#include <ext/pb_ds/exception.hpp>
|
||||
#include <ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp>
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#include <ext/pb_ds/detail/debug_map_base.hpp>
|
||||
#endif
|
||||
#ifdef PB_DS_HT_MAP_TRACE_
|
||||
#include <iostream>
|
||||
#endif
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_CC_HASH_NAME cc_ht_map
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_CC_HASH_NAME cc_ht_set
|
||||
#endif
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Key, typename Mapped, typename Hash_Fn, \
|
||||
typename Eq_Fn, typename _Alloc, bool Store_Hash, \
|
||||
typename Comb_Hash_Fn, typename Resize_Policy>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
PB_DS_CC_HASH_NAME<Key, Mapped, Hash_Fn, Eq_Fn, _Alloc, \
|
||||
Store_Hash, Comb_Hash_Fn, Resize_Policy>
|
||||
|
||||
#define PB_DS_HASH_EQ_FN_C_DEC \
|
||||
hash_eq_fn<Key, Eq_Fn, _Alloc, Store_Hash>
|
||||
|
||||
#define PB_DS_RANGED_HASH_FN_C_DEC \
|
||||
ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, Store_Hash>
|
||||
|
||||
#define PB_DS_CC_HASH_TRAITS_BASE \
|
||||
types_traits<Key, Mapped, _Alloc, Store_Hash>
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
|
||||
debug_map_base<Key, Eq_Fn, \
|
||||
typename _Alloc::template rebind<Key>::other::const_reference>
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* A collision-chaining hash-based container.
|
||||
*
|
||||
*
|
||||
* @ingroup hash-detail
|
||||
*
|
||||
* @tparam Key Key type.
|
||||
*
|
||||
* @tparam Mapped Map type.
|
||||
*
|
||||
* @tparam Hash_Fn Hashing functor.
|
||||
* Default is __gnu_cxx::hash.
|
||||
*
|
||||
* @tparam Eq_Fn Equal functor.
|
||||
* Default std::equal_to<Key>
|
||||
*
|
||||
* @tparam _Alloc Allocator type.
|
||||
*
|
||||
* @tparam Store_Hash If key type stores extra metadata.
|
||||
* Defaults to false.
|
||||
*
|
||||
* @tparam Comb_Hash_Fn Combining hash functor.
|
||||
* If Hash_Fn is not null_type, then this
|
||||
* is the ranged-hash functor; otherwise,
|
||||
* this is the range-hashing functor.
|
||||
* XXX(See Design::Hash-Based Containers::Hash Policies.)
|
||||
* Default direct_mask_range_hashing.
|
||||
*
|
||||
* @tparam Resize_Policy Resizes hash.
|
||||
* Defaults to hash_standard_resize_policy,
|
||||
* using hash_exponential_size_policy and
|
||||
* hash_load_check_resize_trigger.
|
||||
*
|
||||
*
|
||||
* Bases are: detail::hash_eq_fn, Resize_Policy, detail::ranged_hash_fn,
|
||||
* detail::types_traits. (Optional: detail::debug_map_base.)
|
||||
*/
|
||||
template<typename Key,
|
||||
typename Mapped,
|
||||
typename Hash_Fn,
|
||||
typename Eq_Fn,
|
||||
typename _Alloc,
|
||||
bool Store_Hash,
|
||||
typename Comb_Hash_Fn,
|
||||
typename Resize_Policy >
|
||||
class PB_DS_CC_HASH_NAME:
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
|
||||
#endif
|
||||
public PB_DS_HASH_EQ_FN_C_DEC,
|
||||
public Resize_Policy,
|
||||
public PB_DS_RANGED_HASH_FN_C_DEC,
|
||||
public PB_DS_CC_HASH_TRAITS_BASE
|
||||
{
|
||||
private:
|
||||
typedef PB_DS_CC_HASH_TRAITS_BASE traits_base;
|
||||
typedef typename traits_base::comp_hash comp_hash;
|
||||
typedef typename traits_base::value_type value_type_;
|
||||
typedef typename traits_base::pointer pointer_;
|
||||
typedef typename traits_base::const_pointer const_pointer_;
|
||||
typedef typename traits_base::reference reference_;
|
||||
typedef typename traits_base::const_reference const_reference_;
|
||||
|
||||
struct entry : public traits_base::stored_data_type
|
||||
{
|
||||
typename _Alloc::template rebind<entry>::other::pointer m_p_next;
|
||||
};
|
||||
|
||||
typedef cond_dealtor<entry, _Alloc> cond_dealtor_t;
|
||||
|
||||
typedef typename _Alloc::template rebind<entry>::other entry_allocator;
|
||||
typedef typename entry_allocator::pointer entry_pointer;
|
||||
typedef typename entry_allocator::const_pointer const_entry_pointer;
|
||||
typedef typename entry_allocator::reference entry_reference;
|
||||
typedef typename entry_allocator::const_reference const_entry_reference;
|
||||
|
||||
typedef typename _Alloc::template rebind<entry_pointer>::other entry_pointer_allocator;
|
||||
typedef typename entry_pointer_allocator::pointer entry_pointer_array;
|
||||
|
||||
typedef PB_DS_RANGED_HASH_FN_C_DEC ranged_hash_fn_base;
|
||||
typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base;
|
||||
typedef Resize_Policy resize_base;
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
|
||||
#endif
|
||||
|
||||
#define PB_DS_GEN_POS std::pair<entry_pointer, typename _Alloc::size_type>
|
||||
|
||||
#include <ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp>
|
||||
#include <ext/pb_ds/detail/unordered_iterator/point_iterator.hpp>
|
||||
#include <ext/pb_ds/detail/unordered_iterator/const_iterator.hpp>
|
||||
#include <ext/pb_ds/detail/unordered_iterator/iterator.hpp>
|
||||
|
||||
#undef PB_DS_GEN_POS
|
||||
|
||||
public:
|
||||
typedef _Alloc allocator_type;
|
||||
typedef typename _Alloc::size_type size_type;
|
||||
typedef typename _Alloc::difference_type difference_type;
|
||||
typedef Hash_Fn hash_fn;
|
||||
typedef Eq_Fn eq_fn;
|
||||
typedef Comb_Hash_Fn comb_hash_fn;
|
||||
typedef Resize_Policy resize_policy;
|
||||
|
||||
/// Value stores hash, true or false.
|
||||
enum
|
||||
{
|
||||
store_hash = Store_Hash
|
||||
};
|
||||
|
||||
typedef typename traits_base::key_type key_type;
|
||||
typedef typename traits_base::key_pointer key_pointer;
|
||||
typedef typename traits_base::key_const_pointer key_const_pointer;
|
||||
typedef typename traits_base::key_reference key_reference;
|
||||
typedef typename traits_base::key_const_reference key_const_reference;
|
||||
typedef typename traits_base::mapped_type mapped_type;
|
||||
typedef typename traits_base::mapped_pointer mapped_pointer;
|
||||
typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
|
||||
typedef typename traits_base::mapped_reference mapped_reference;
|
||||
typedef typename traits_base::mapped_const_reference mapped_const_reference;
|
||||
typedef typename traits_base::value_type value_type;
|
||||
typedef typename traits_base::pointer pointer;
|
||||
typedef typename traits_base::const_pointer const_pointer;
|
||||
typedef typename traits_base::reference reference;
|
||||
typedef typename traits_base::const_reference const_reference;
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
typedef point_iterator_ point_iterator;
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
typedef point_const_iterator_ point_iterator;
|
||||
#endif
|
||||
|
||||
typedef point_const_iterator_ point_const_iterator;
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
typedef iterator_ iterator;
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_DATA_FALSE_INDICATOR
|
||||
typedef const_iterator_ iterator;
|
||||
#endif
|
||||
|
||||
typedef const_iterator_ const_iterator;
|
||||
|
||||
PB_DS_CC_HASH_NAME();
|
||||
|
||||
PB_DS_CC_HASH_NAME(const Hash_Fn&);
|
||||
|
||||
PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&);
|
||||
|
||||
PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&);
|
||||
|
||||
PB_DS_CC_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Hash_Fn&,
|
||||
const Resize_Policy&);
|
||||
|
||||
PB_DS_CC_HASH_NAME(const PB_DS_CLASS_C_DEC&);
|
||||
|
||||
virtual
|
||||
~PB_DS_CC_HASH_NAME();
|
||||
|
||||
void
|
||||
swap(PB_DS_CLASS_C_DEC&);
|
||||
|
||||
template<typename It>
|
||||
void
|
||||
copy_from_range(It, It);
|
||||
|
||||
void
|
||||
initialize();
|
||||
|
||||
inline size_type
|
||||
size() const;
|
||||
|
||||
inline size_type
|
||||
max_size() const;
|
||||
|
||||
/// True if size() == 0.
|
||||
inline bool
|
||||
empty() const;
|
||||
|
||||
/// Return current hash_fn.
|
||||
Hash_Fn&
|
||||
get_hash_fn();
|
||||
|
||||
/// Return current const hash_fn.
|
||||
const Hash_Fn&
|
||||
get_hash_fn() const;
|
||||
|
||||
/// Return current eq_fn.
|
||||
Eq_Fn&
|
||||
get_eq_fn();
|
||||
|
||||
/// Return current const eq_fn.
|
||||
const Eq_Fn&
|
||||
get_eq_fn() const;
|
||||
|
||||
/// Return current comb_hash_fn.
|
||||
Comb_Hash_Fn&
|
||||
get_comb_hash_fn();
|
||||
|
||||
/// Return current const comb_hash_fn.
|
||||
const Comb_Hash_Fn&
|
||||
get_comb_hash_fn() const;
|
||||
|
||||
/// Return current resize_policy.
|
||||
Resize_Policy&
|
||||
get_resize_policy();
|
||||
|
||||
/// Return current const resize_policy.
|
||||
const Resize_Policy&
|
||||
get_resize_policy() const;
|
||||
|
||||
inline std::pair<point_iterator, bool>
|
||||
insert(const_reference r_val)
|
||||
{ return insert_imp(r_val, traits_base::m_store_extra_indicator); }
|
||||
|
||||
inline mapped_reference
|
||||
operator[](key_const_reference r_key)
|
||||
{
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
return (subscript_imp(r_key, traits_base::m_store_extra_indicator));
|
||||
#else
|
||||
insert(r_key);
|
||||
return traits_base::s_null_type;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline point_iterator
|
||||
find(key_const_reference);
|
||||
|
||||
inline point_const_iterator
|
||||
find(key_const_reference) const;
|
||||
|
||||
inline point_iterator
|
||||
find_end();
|
||||
|
||||
inline point_const_iterator
|
||||
find_end() const;
|
||||
|
||||
inline bool
|
||||
erase(key_const_reference);
|
||||
|
||||
template<typename Pred>
|
||||
inline size_type
|
||||
erase_if(Pred);
|
||||
|
||||
void
|
||||
clear();
|
||||
|
||||
inline iterator
|
||||
begin();
|
||||
|
||||
inline const_iterator
|
||||
begin() const;
|
||||
|
||||
inline iterator
|
||||
end();
|
||||
|
||||
inline const_iterator
|
||||
end() const;
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_valid(const char*, int) const;
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_HT_MAP_TRACE_
|
||||
void
|
||||
trace() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void
|
||||
deallocate_all();
|
||||
|
||||
inline bool
|
||||
do_resize_if_needed();
|
||||
|
||||
inline void
|
||||
do_resize_if_needed_no_throw();
|
||||
|
||||
void
|
||||
resize_imp(size_type);
|
||||
|
||||
void
|
||||
do_resize(size_type);
|
||||
|
||||
void
|
||||
resize_imp_no_exceptions(size_type, entry_pointer_array, size_type);
|
||||
|
||||
inline entry_pointer
|
||||
resize_imp_no_exceptions_reassign_pointer(entry_pointer,
|
||||
entry_pointer_array,
|
||||
false_type);
|
||||
|
||||
inline entry_pointer
|
||||
resize_imp_no_exceptions_reassign_pointer(entry_pointer,
|
||||
entry_pointer_array,
|
||||
true_type);
|
||||
|
||||
void
|
||||
deallocate_links_in_list(entry_pointer);
|
||||
|
||||
inline entry_pointer
|
||||
get_entry(const_reference, false_type);
|
||||
|
||||
inline entry_pointer
|
||||
get_entry(const_reference, true_type);
|
||||
|
||||
inline void
|
||||
rels_entry(entry_pointer);
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
inline mapped_reference
|
||||
subscript_imp(key_const_reference r_key, false_type)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
|
||||
const size_type pos = ranged_hash_fn_base::operator()(r_key);
|
||||
entry_pointer p_e = m_entries[pos];
|
||||
resize_base::notify_insert_search_start();
|
||||
|
||||
while (p_e != 0
|
||||
&& !hash_eq_fn_base::operator()(p_e->m_value.first, r_key))
|
||||
{
|
||||
resize_base::notify_insert_search_collision();
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_insert_search_end();
|
||||
if (p_e != 0)
|
||||
{
|
||||
PB_DS_CHECK_KEY_EXISTS(r_key)
|
||||
return (p_e->m_value.second);
|
||||
}
|
||||
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
|
||||
return insert_new_imp(value_type(r_key, mapped_type()), pos)->second;
|
||||
}
|
||||
|
||||
inline mapped_reference
|
||||
subscript_imp(key_const_reference r_key, true_type)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
|
||||
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
|
||||
entry_pointer p_e = m_entries[pos_hash_pair.first];
|
||||
resize_base::notify_insert_search_start();
|
||||
while (p_e != 0 &&
|
||||
!hash_eq_fn_base::operator()(p_e->m_value.first, p_e->m_hash,
|
||||
r_key, pos_hash_pair.second))
|
||||
{
|
||||
resize_base::notify_insert_search_collision();
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_insert_search_end();
|
||||
if (p_e != 0)
|
||||
{
|
||||
PB_DS_CHECK_KEY_EXISTS(r_key)
|
||||
return p_e->m_value.second;
|
||||
}
|
||||
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
|
||||
return insert_new_imp(value_type(r_key, mapped_type()),
|
||||
pos_hash_pair)->second;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline std::pair<point_iterator, bool>
|
||||
insert_imp(const_reference, false_type);
|
||||
|
||||
inline std::pair<point_iterator, bool>
|
||||
insert_imp(const_reference, true_type);
|
||||
|
||||
inline pointer
|
||||
insert_new_imp(const_reference r_val, size_type pos)
|
||||
{
|
||||
if (do_resize_if_needed())
|
||||
pos = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val));
|
||||
|
||||
// Following lines might throw an exception.
|
||||
entry_pointer p_e = get_entry(r_val,
|
||||
traits_base::m_no_throw_copies_indicator);
|
||||
|
||||
// At this point no exceptions can be thrown.
|
||||
p_e->m_p_next = m_entries[pos];
|
||||
m_entries[pos] = p_e;
|
||||
resize_base::notify_inserted(++m_num_used_e);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
|
||||
return &p_e->m_value;
|
||||
}
|
||||
|
||||
inline pointer
|
||||
insert_new_imp(const_reference r_val, comp_hash& r_pos_hash_pair)
|
||||
{
|
||||
// Following lines might throw an exception.
|
||||
if (do_resize_if_needed())
|
||||
r_pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(r_val));
|
||||
|
||||
entry_pointer p_e = get_entry(r_val,
|
||||
traits_base::m_no_throw_copies_indicator);
|
||||
|
||||
// At this point no exceptions can be thrown.
|
||||
p_e->m_hash = r_pos_hash_pair.second;
|
||||
p_e->m_p_next = m_entries[r_pos_hash_pair.first];
|
||||
m_entries[r_pos_hash_pair.first] = p_e;
|
||||
resize_base::notify_inserted(++m_num_used_e);
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));)
|
||||
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);)
|
||||
return &p_e->m_value;
|
||||
}
|
||||
|
||||
inline pointer
|
||||
find_key_pointer(key_const_reference r_key, false_type)
|
||||
{
|
||||
entry_pointer p_e = m_entries[ranged_hash_fn_base::operator()(r_key)];
|
||||
resize_base::notify_find_search_start();
|
||||
while (p_e != 0 &&
|
||||
!hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
|
||||
{
|
||||
resize_base::notify_find_search_collision();
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_find_search_end();
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
if (p_e == 0)
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
|
||||
else
|
||||
PB_DS_CHECK_KEY_EXISTS(r_key)
|
||||
#endif
|
||||
return &p_e->m_value;
|
||||
}
|
||||
|
||||
inline pointer
|
||||
find_key_pointer(key_const_reference r_key, true_type)
|
||||
{
|
||||
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(r_key);
|
||||
entry_pointer p_e = m_entries[pos_hash_pair.first];
|
||||
resize_base::notify_find_search_start();
|
||||
while (p_e != 0 &&
|
||||
!hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
|
||||
p_e->m_hash,
|
||||
r_key, pos_hash_pair.second))
|
||||
{
|
||||
resize_base::notify_find_search_collision();
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_find_search_end();
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
if (p_e == 0)
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
|
||||
else
|
||||
PB_DS_CHECK_KEY_EXISTS(r_key)
|
||||
#endif
|
||||
return &p_e->m_value;
|
||||
}
|
||||
|
||||
inline bool
|
||||
erase_in_pos_imp(key_const_reference, size_type);
|
||||
|
||||
inline bool
|
||||
erase_in_pos_imp(key_const_reference, const comp_hash&);
|
||||
|
||||
inline void
|
||||
erase_entry_pointer(entry_pointer&);
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
void
|
||||
inc_it_state(pointer& r_p_value,
|
||||
std::pair<entry_pointer, size_type>& r_pos) const
|
||||
{
|
||||
inc_it_state((mapped_const_pointer& )r_p_value, r_pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
inc_it_state(const_pointer& r_p_value,
|
||||
std::pair<entry_pointer, size_type>& r_pos) const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(r_p_value != 0);
|
||||
r_pos.first = r_pos.first->m_p_next;
|
||||
if (r_pos.first != 0)
|
||||
{
|
||||
r_p_value = &r_pos.first->m_value;
|
||||
return;
|
||||
}
|
||||
|
||||
for (++r_pos.second; r_pos.second < m_num_e; ++r_pos.second)
|
||||
if (m_entries[r_pos.second] != 0)
|
||||
{
|
||||
r_pos.first = m_entries[r_pos.second];
|
||||
r_p_value = &r_pos.first->m_value;
|
||||
return;
|
||||
}
|
||||
r_p_value = 0;
|
||||
}
|
||||
|
||||
void
|
||||
get_start_it_state(pointer& r_p_value,
|
||||
std::pair<entry_pointer, size_type>& r_pos) const
|
||||
{
|
||||
for (r_pos.second = 0; r_pos.second < m_num_e; ++r_pos.second)
|
||||
if (m_entries[r_pos.second] != 0)
|
||||
{
|
||||
r_pos.first = m_entries[r_pos.second];
|
||||
r_p_value = &r_pos.first->m_value;
|
||||
return;
|
||||
}
|
||||
r_p_value = 0;
|
||||
}
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
void
|
||||
assert_entry_pointer_array_valid(const entry_pointer_array,
|
||||
const char*, int) const;
|
||||
|
||||
void
|
||||
assert_entry_pointer_valid(const entry_pointer, true_type,
|
||||
const char*, int) const;
|
||||
|
||||
void
|
||||
assert_entry_pointer_valid(const entry_pointer, false_type,
|
||||
const char*, int) const;
|
||||
#endif
|
||||
|
||||
#ifdef PB_DS_HT_MAP_TRACE_
|
||||
void
|
||||
trace_list(const_entry_pointer) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
friend class iterator_;
|
||||
#endif
|
||||
|
||||
friend class const_iterator_;
|
||||
|
||||
static entry_allocator s_entry_allocator;
|
||||
static entry_pointer_allocator s_entry_pointer_allocator;
|
||||
static iterator s_end_it;
|
||||
static const_iterator s_const_end_it;
|
||||
static point_iterator s_find_end_it;
|
||||
static point_const_iterator s_const_find_end_it;
|
||||
|
||||
size_type m_num_e;
|
||||
size_type m_num_used_e;
|
||||
entry_pointer_array m_entries;
|
||||
|
||||
enum
|
||||
{
|
||||
store_hash_ok = !Store_Hash
|
||||
|| !is_same<Hash_Fn, __gnu_pbds::null_type>::value
|
||||
};
|
||||
|
||||
PB_DS_STATIC_ASSERT(sth, store_hash_ok);
|
||||
};
|
||||
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp>
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
#undef PB_DS_HASH_EQ_FN_C_DEC
|
||||
#undef PB_DS_RANGED_HASH_FN_C_DEC
|
||||
#undef PB_DS_CC_HASH_TRAITS_BASE
|
||||
#undef PB_DS_DEBUG_MAP_BASE_C_DEC
|
||||
#undef PB_DS_CC_HASH_NAME
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
@@ -0,0 +1,83 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/cmp_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s entire container comparison related
|
||||
* functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Other_HT_Map_Type>
|
||||
bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
operator==(const Other_HT_Map_Type& other) const
|
||||
{ return cmp_with_other(other); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Other_Map_Type>
|
||||
bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
cmp_with_other(const Other_Map_Type& other) const
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
|
||||
for (typename Other_Map_Type::const_iterator it = other.begin();
|
||||
it != other.end(); ++it)
|
||||
{
|
||||
key_const_reference r_key = key_const_reference(PB_DS_V2F(*it));
|
||||
|
||||
mapped_const_pointer p_mapped_value =
|
||||
const_cast<PB_DS_CLASS_C_DEC& >(*this).
|
||||
find_key_pointer(r_key, traits_base::m_store_extra_indicator);
|
||||
|
||||
if (p_mapped_value == 0)
|
||||
return false;
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
if (p_mapped_value->second != it->second)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Other_HT_Map_Type>
|
||||
bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
operator!=(const Other_HT_Map_Type& other) const
|
||||
{ return !operator==(other); }
|
||||
@@ -0,0 +1,90 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp
|
||||
* Contains a conditional key destructor, used for exception handling.
|
||||
*/
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Conditional dey destructor, cc_hash.
|
||||
template<typename HT_Map>
|
||||
class cond_dealtor
|
||||
{
|
||||
public:
|
||||
typedef typename HT_Map::entry entry;
|
||||
typedef typename HT_Map::entry_allocator entry_allocator;
|
||||
typedef typename HT_Map::key_type key_type;
|
||||
|
||||
cond_dealtor(entry_allocator* p_a, entry* p_e)
|
||||
: m_p_a(p_a), m_p_e(p_e), m_key_destruct(false),
|
||||
m_no_action_destructor(false)
|
||||
{ }
|
||||
|
||||
inline
|
||||
~cond_dealtor();
|
||||
|
||||
void
|
||||
set_key_destruct()
|
||||
{ m_key_destruct = true; }
|
||||
|
||||
void
|
||||
set_no_action_destructor()
|
||||
{ m_no_action_destructor = true; }
|
||||
|
||||
protected:
|
||||
entry_allocator* const m_p_a;
|
||||
entry* const m_p_e;
|
||||
|
||||
bool m_key_destruct;
|
||||
bool m_no_action_destructor;
|
||||
};
|
||||
|
||||
template<typename HT_Map>
|
||||
inline
|
||||
cond_dealtor<HT_Map>::
|
||||
~cond_dealtor()
|
||||
{
|
||||
if (m_no_action_destructor)
|
||||
return;
|
||||
if (m_key_destruct)
|
||||
m_p_e->m_value.first.~key_type();
|
||||
m_p_a->deallocate(m_p_e, 1);
|
||||
}
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
@@ -0,0 +1,191 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/constructor_destructor_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s constructors, destructor,
|
||||
* and related functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::entry_allocator
|
||||
PB_DS_CLASS_C_DEC::s_entry_allocator;
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::entry_pointer_allocator
|
||||
PB_DS_CLASS_C_DEC::s_entry_pointer_allocator;
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename It>
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
copy_from_range(It first_it, It last_it)
|
||||
{
|
||||
while (first_it != last_it)
|
||||
insert(*(first_it++));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CC_HASH_NAME() :
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn) :
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn) :
|
||||
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
|
||||
{
|
||||
std::fill(m_entries, m_entries + m_num_e, (entry_pointer)0);
|
||||
Resize_Policy::notify_cleared();
|
||||
ranged_hash_fn_base::notify_resized(m_num_e);
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
|
||||
const Comb_Hash_Fn& r_comb_hash_fn) :
|
||||
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn, r_comb_hash_fn),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CC_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
|
||||
const Comb_Hash_Fn& r_comb_hash_fn,
|
||||
const Resize_Policy& r_resize_policy) :
|
||||
PB_DS_HASH_EQ_FN_C_DEC(r_eq_fn),
|
||||
Resize_Policy(r_resize_policy),
|
||||
ranged_hash_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn, r_comb_hash_fn),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_CC_HASH_NAME(const PB_DS_CLASS_C_DEC& other) :
|
||||
PB_DS_HASH_EQ_FN_C_DEC(other),
|
||||
resize_base(other), ranged_hash_fn_base(other),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_pointer_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
__try
|
||||
{
|
||||
copy_from_range(other.begin(), other.end());
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
deallocate_all();
|
||||
__throw_exception_again;
|
||||
}
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~PB_DS_CC_HASH_NAME()
|
||||
{ deallocate_all(); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
|
||||
std::swap(m_entries, other.m_entries);
|
||||
std::swap(m_num_e, other.m_num_e);
|
||||
std::swap(m_num_used_e, other.m_num_used_e);
|
||||
ranged_hash_fn_base::swap(other);
|
||||
hash_eq_fn_base::swap(other);
|
||||
resize_base::swap(other);
|
||||
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other));
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
deallocate_all()
|
||||
{
|
||||
clear();
|
||||
s_entry_pointer_allocator.deallocate(m_entries, m_num_e);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
initialize()
|
||||
{
|
||||
std::fill(m_entries, m_entries + m_num_e, entry_pointer(0));
|
||||
Resize_Policy::notify_resized(m_num_e);
|
||||
Resize_Policy::notify_cleared();
|
||||
ranged_hash_fn_base::notify_resized(m_num_e);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s constructors, destructor,
|
||||
* and related functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
constructor_insert_new_imp(mapped_const_reference r_val, size_type pos,
|
||||
false_type)
|
||||
{
|
||||
// Following lines might throw an exception.
|
||||
entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator);
|
||||
|
||||
// At this point no exceptions can be thrown.
|
||||
p->m_p_next = m_entries[pos];
|
||||
m_entries[pos] = p;
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(r_key);)
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s constructors, destructor,
|
||||
* and related functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
constructor_insert_new_imp(const_reference r_val, size_type pos, true_type)
|
||||
{
|
||||
// Following lines might throw an exception.
|
||||
entry_pointer p = get_entry(r_val, traits_base::s_no_throw_copies_indicator);
|
||||
|
||||
// At this point no exceptions can be thrown.
|
||||
p->m_p_next = m_entries[pos];
|
||||
p->m_hash = ranged_hash_fn_base::operator()((key_const_reference)(PB_DS_V2F(p->m_value))).second;
|
||||
|
||||
m_entries[pos] = p;
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(r_key);)
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/debug_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid(const char* __file, int __line) const
|
||||
{
|
||||
debug_base::check_size(m_num_used_e, __file, __line);
|
||||
assert_entry_pointer_array_valid(m_entries, __file, __line);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_entry_pointer_array_valid(const entry_pointer_array a_p_entries,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
size_type iterated_num_used_e = 0;
|
||||
for (size_type pos = 0; pos < m_num_e; ++pos)
|
||||
{
|
||||
entry_pointer p_e = a_p_entries[pos];
|
||||
while (p_e != 0)
|
||||
{
|
||||
++iterated_num_used_e;
|
||||
assert_entry_pointer_valid(p_e, traits_base::m_store_extra_indicator,
|
||||
__file, __line);
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
}
|
||||
PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e);
|
||||
}
|
||||
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_entry_pointer_valid(const entry_pointer p, false_type,
|
||||
const char* __file, int __line) const
|
||||
{ debug_base::check_key_exists(PB_DS_V2F(p->m_value), __file, __line); }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/debug_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s debug-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_entry_pointer_valid(const entry_pointer p_e, true_type,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
debug_base::check_key_exists(PB_DS_V2F(p_e->m_value), __file, __line);
|
||||
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value));
|
||||
PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,91 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/entry_list_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s entry-list related functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
deallocate_links_in_list(entry_pointer p_e)
|
||||
{
|
||||
while (p_e != 0)
|
||||
{
|
||||
entry_pointer p_dealloc_e = p_e;
|
||||
p_e = p_e->m_p_next;
|
||||
s_entry_allocator.deallocate(p_dealloc_e, 1);
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::entry_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_entry(const_reference r_val, true_type)
|
||||
{
|
||||
// Following line might throw an exception.
|
||||
entry_pointer p_e = s_entry_allocator.allocate(1);
|
||||
|
||||
// Following lines* cannot* throw an exception.
|
||||
new (&p_e->m_value) value_type(r_val);
|
||||
return p_e;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::entry_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_entry(const_reference r_val, false_type)
|
||||
{
|
||||
// Following line might throw an exception.
|
||||
entry_pointer p_e = s_entry_allocator.allocate(1);
|
||||
cond_dealtor_t cond(p_e);
|
||||
|
||||
// Following lines might throw an exception.
|
||||
new (&p_e->m_value) value_type(r_val);
|
||||
cond.set_no_action();
|
||||
return p_e;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
rels_entry(entry_pointer p_e)
|
||||
{
|
||||
// The following lines cannot throw exceptions (unless if key-data dtors do).
|
||||
p_e->m_value.~value_type();
|
||||
s_entry_allocator.deallocate(p_e, 1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/erase_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s erase related functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_entry_pointer(entry_pointer& r_p_e)
|
||||
{
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(r_p_e->m_value)));
|
||||
|
||||
entry_pointer p_e = r_p_e;
|
||||
r_p_e = r_p_e->m_p_next;
|
||||
rels_entry(p_e);
|
||||
_GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0);
|
||||
resize_base::notify_erased(--m_num_used_e);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Pred>
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_if(Pred pred)
|
||||
{
|
||||
size_type num_ersd = 0;
|
||||
for (size_type pos = 0; pos < m_num_e; ++pos)
|
||||
{
|
||||
while (m_entries[pos] != 0 && pred(m_entries[pos]->m_value))
|
||||
{
|
||||
++num_ersd;
|
||||
entry_pointer p_next_e = m_entries[pos]->m_p_next;
|
||||
erase_entry_pointer(m_entries[pos]);
|
||||
m_entries[pos] = p_next_e;
|
||||
}
|
||||
|
||||
entry_pointer p_e = m_entries[pos];
|
||||
while (p_e != 0 && p_e->m_p_next != 0)
|
||||
{
|
||||
if (pred(p_e->m_p_next->m_value))
|
||||
{
|
||||
++num_ersd;
|
||||
erase_entry_pointer(p_e->m_p_next);
|
||||
}
|
||||
else
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
}
|
||||
|
||||
do_resize_if_needed_no_throw();
|
||||
return num_ersd;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
for (size_type pos = 0; pos < m_num_e; ++pos)
|
||||
while (m_entries[pos] != 0)
|
||||
erase_entry_pointer(m_entries[pos]);
|
||||
do_resize_if_needed_no_throw();
|
||||
resize_base::notify_cleared();
|
||||
}
|
||||
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp>
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s erase related functions,
|
||||
* when the hash value is not stored.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase(key_const_reference r_key)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return erase_in_pos_imp(r_key, ranged_hash_fn_base::operator()(r_key));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_in_pos_imp(key_const_reference r_key, size_type pos)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
entry_pointer p_e = m_entries[pos];
|
||||
resize_base::notify_erase_search_start();
|
||||
if (p_e == 0)
|
||||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key))
|
||||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
PB_DS_CHECK_KEY_EXISTS(r_key)
|
||||
erase_entry_pointer(m_entries[pos]);
|
||||
do_resize_if_needed_no_throw();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return true;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
entry_pointer p_next_e = p_e->m_p_next;
|
||||
if (p_next_e == 0)
|
||||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value), r_key))
|
||||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
PB_DS_CHECK_KEY_EXISTS(r_key)
|
||||
erase_entry_pointer(p_e->m_p_next);
|
||||
do_resize_if_needed_no_throw();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return true;
|
||||
}
|
||||
resize_base::notify_erase_search_collision();
|
||||
p_e = p_next_e;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/erase_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s erase related functions,
|
||||
* when the hash value is stored.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_in_pos_imp(key_const_reference r_key, const comp_hash& r_pos_hash_pair)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
entry_pointer p_e = m_entries[r_pos_hash_pair.first];
|
||||
resize_base::notify_erase_search_start();
|
||||
if (p_e == 0)
|
||||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash,
|
||||
r_key, r_pos_hash_pair.second))
|
||||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
PB_DS_CHECK_KEY_EXISTS(r_key)
|
||||
erase_entry_pointer(m_entries[r_pos_hash_pair.first]);
|
||||
do_resize_if_needed_no_throw();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return true;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
entry_pointer p_next_e = p_e->m_p_next;
|
||||
if (p_next_e == 0)
|
||||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_next_e->m_value),
|
||||
p_next_e->m_hash, r_key,
|
||||
r_pos_hash_pair.second))
|
||||
{
|
||||
resize_base::notify_erase_search_end();
|
||||
PB_DS_CHECK_KEY_EXISTS(r_key)
|
||||
erase_entry_pointer(p_e->m_p_next);
|
||||
do_resize_if_needed_no_throw();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return true;
|
||||
}
|
||||
resize_base::notify_erase_search_collision();
|
||||
p_e = p_next_e;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/find_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s find related functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find(key_const_reference r_key)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return find_key_pointer(r_key, traits_base::m_store_extra_indicator);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find(key_const_reference r_key) const
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
return const_cast<PB_DS_CLASS_C_DEC& >(*this).find_key_pointer(r_key,
|
||||
traits_base::m_store_extra_indicator);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find_end()
|
||||
{ return 0; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::point_const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find_end() const
|
||||
{ return 0; }
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/find_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s find related functions,
|
||||
* when the hash value is stored.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/info_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s entire container info related
|
||||
* functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
size() const
|
||||
{ return m_num_used_e; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
max_size() const
|
||||
{ return m_entry_allocator.max_size(); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
empty() const
|
||||
{ return (size() == 0); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Other_HT_Map_Type>
|
||||
bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
operator==(const Other_HT_Map_Type& other) const
|
||||
{ return cmp_with_other(other); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Other_Map_Type>
|
||||
bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
cmp_with_other(const Other_Map_Type& other) const
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
|
||||
for (typename Other_Map_Type::const_iterator it = other.begin();
|
||||
it != other.end(); ++it)
|
||||
{
|
||||
key_const_reference r_key =(key_const_reference)PB_DS_V2F(*it);
|
||||
mapped_const_pointer p_mapped_value =
|
||||
const_cast<PB_DS_CLASS_C_DEC& >(*this).
|
||||
find_key_pointer(r_key, traits_base::m_store_extra_indicator);
|
||||
|
||||
if (p_mapped_value == 0)
|
||||
return false;
|
||||
|
||||
#ifdef PB_DS_DATA_TRUE_INDICATOR
|
||||
if (p_mapped_value->second != it->second)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Other_HT_Map_Type>
|
||||
bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
operator!=(const Other_HT_Map_Type& other) const
|
||||
{ return !operator==(other); }
|
||||
@@ -0,0 +1,43 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/insert_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s insert related functions.
|
||||
*/
|
||||
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s insert related functions,
|
||||
* when the hash value is not stored.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_imp(const_reference r_val, false_type)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
key_const_reference r_key = PB_DS_V2F(r_val);
|
||||
const size_type pos = ranged_hash_fn_base::operator()(r_key);
|
||||
entry_pointer p_e = m_entries[pos];
|
||||
resize_base::notify_insert_search_start();
|
||||
|
||||
while (p_e != 0 && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
|
||||
r_key))
|
||||
{
|
||||
resize_base::notify_insert_search_collision();
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_insert_search_end();
|
||||
if (p_e != 0)
|
||||
{
|
||||
PB_DS_CHECK_KEY_EXISTS(r_key)
|
||||
return std::make_pair(&p_e->m_value, false);
|
||||
}
|
||||
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key)
|
||||
return std::make_pair(insert_new_imp(r_val, pos), true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/insert_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s insert related functions,
|
||||
* when the hash value is stored.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool>
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_imp(const_reference r_val, true_type)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
key_const_reference key = PB_DS_V2F(r_val);
|
||||
comp_hash pos_hash_pair = ranged_hash_fn_base::operator()(key);
|
||||
entry_pointer p_e = m_entries[pos_hash_pair.first];
|
||||
resize_base::notify_insert_search_start();
|
||||
|
||||
while (p_e != 0 && !hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value),
|
||||
p_e->m_hash,
|
||||
key, pos_hash_pair.second))
|
||||
{
|
||||
resize_base::notify_insert_search_collision();
|
||||
p_e = p_e->m_p_next;
|
||||
}
|
||||
|
||||
resize_base::notify_insert_search_end();
|
||||
if (p_e != 0)
|
||||
{
|
||||
PB_DS_CHECK_KEY_EXISTS(key)
|
||||
return std::make_pair(&p_e->m_value, false);
|
||||
}
|
||||
|
||||
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key)
|
||||
return std::make_pair(insert_new_imp(r_val, pos_hash_pair), true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/iterators_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s iterators related functions, e.g.,
|
||||
* begin().
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::s_end_it;
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::const_iterator
|
||||
PB_DS_CLASS_C_DEC::s_const_end_it;
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
begin()
|
||||
{
|
||||
pointer p_value;
|
||||
std::pair<entry_pointer, size_type> pos;
|
||||
get_start_it_state(p_value, pos);
|
||||
return iterator(p_value, pos, this);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
end()
|
||||
{ return s_end_it; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
begin() const
|
||||
{
|
||||
pointer p_value;
|
||||
std::pair<entry_pointer, size_type> pos;
|
||||
get_start_it_state(p_value, pos);
|
||||
return const_iterator(p_value, pos, this);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
end() const
|
||||
{ return s_const_end_it; }
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/policy_access_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s policy access
|
||||
* functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
Hash_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_hash_fn()
|
||||
{ return *this; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
const Hash_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_hash_fn() const
|
||||
{ return *this; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
Eq_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_eq_fn()
|
||||
{ return *this; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
const Eq_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_eq_fn() const
|
||||
{ return *this; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
Comb_Hash_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_comb_hash_fn()
|
||||
{ return *this; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
const Comb_Hash_Fn&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_comb_hash_fn() const
|
||||
{ return *this; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
Resize_Policy&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_resize_policy()
|
||||
{ return *this; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
const Resize_Policy&
|
||||
PB_DS_CLASS_C_DEC::
|
||||
get_resize_policy() const
|
||||
{ return *this; }
|
||||
@@ -0,0 +1,134 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/resize_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s resize related functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
do_resize_if_needed()
|
||||
{
|
||||
if (!resize_base::is_resize_needed())
|
||||
return false;
|
||||
resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
|
||||
return true;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
do_resize(size_type len)
|
||||
{ resize_imp(resize_base::get_nearest_larger_size(len)); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
do_resize_if_needed_no_throw()
|
||||
{
|
||||
if (!resize_base::is_resize_needed())
|
||||
return;
|
||||
|
||||
__try
|
||||
{
|
||||
resize_imp(resize_base::get_new_size(m_num_e, m_num_used_e));
|
||||
}
|
||||
__catch(...)
|
||||
{ }
|
||||
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
resize_imp(size_type new_size)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
if (new_size == m_num_e)
|
||||
return;
|
||||
|
||||
const size_type old_size = m_num_e;
|
||||
entry_pointer_array a_p_entries_resized;
|
||||
|
||||
// Following line might throw an exception.
|
||||
ranged_hash_fn_base::notify_resized(new_size);
|
||||
|
||||
__try
|
||||
{
|
||||
// Following line might throw an exception.
|
||||
a_p_entries_resized = s_entry_pointer_allocator.allocate(new_size);
|
||||
m_num_e = new_size;
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
ranged_hash_fn_base::notify_resized(old_size);
|
||||
__throw_exception_again;
|
||||
}
|
||||
|
||||
// At this point no exceptions can be thrown.
|
||||
resize_imp_no_exceptions(new_size, a_p_entries_resized, old_size);
|
||||
Resize_Policy::notify_resized(new_size);
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
resize_imp_no_exceptions(size_type new_size, entry_pointer_array a_p_entries_resized, size_type old_size)
|
||||
{
|
||||
std::fill(a_p_entries_resized, a_p_entries_resized + m_num_e,
|
||||
entry_pointer(0));
|
||||
|
||||
for (size_type pos = 0; pos < old_size; ++pos)
|
||||
{
|
||||
entry_pointer p_e = m_entries[pos];
|
||||
while (p_e != 0)
|
||||
p_e = resize_imp_no_exceptions_reassign_pointer(p_e, a_p_entries_resized, traits_base::m_store_extra_indicator);
|
||||
}
|
||||
|
||||
m_num_e = new_size;
|
||||
_GLIBCXX_DEBUG_ONLY(assert_entry_pointer_array_valid(a_p_entries_resized,
|
||||
__FILE__, __LINE__);)
|
||||
s_entry_pointer_allocator.deallocate(m_entries, old_size);
|
||||
m_entries = a_p_entries_resized;
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s resize related functions, when the
|
||||
* hash value is not stored.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::entry_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, false_type)
|
||||
{
|
||||
const size_type hash_pos =
|
||||
ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value));
|
||||
|
||||
entry_pointer const p_next_e = p_e->m_p_next;
|
||||
p_e->m_p_next = a_p_entries_resized[hash_pos];
|
||||
a_p_entries_resized[hash_pos] = p_e;
|
||||
return p_next_e;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/resize_store_hash_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s resize related functions, when the
|
||||
* hash value is stored.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::entry_pointer
|
||||
PB_DS_CLASS_C_DEC::
|
||||
resize_imp_no_exceptions_reassign_pointer(entry_pointer p_e, entry_pointer_array a_p_entries_resized, true_type)
|
||||
{
|
||||
const comp_hash pos_hash_pair =
|
||||
ranged_hash_fn_base::operator()(PB_DS_V2F(p_e->m_value), p_e->m_hash);
|
||||
|
||||
entry_pointer const p_next_e = p_e->m_p_next;
|
||||
p_e->m_p_next = a_p_entries_resized[pos_hash_pair.first];
|
||||
a_p_entries_resized[pos_hash_pair.first] = p_e;
|
||||
return p_next_e;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/size_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s entire container size related
|
||||
* functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
size() const
|
||||
{ return m_num_used_e; }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline bool
|
||||
PB_DS_CLASS_C_DEC::
|
||||
empty() const
|
||||
{ return (size() == 0); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline typename PB_DS_CLASS_C_DEC::size_type
|
||||
PB_DS_CLASS_C_DEC::
|
||||
max_size() const
|
||||
{ return s_entry_allocator.max_size(); }
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file cc_hash_table_map_/trace_fn_imps.hpp
|
||||
* Contains implementations of cc_ht_map_'s trace-mode functions.
|
||||
*/
|
||||
|
||||
#ifdef PB_DS_HT_MAP_TRACE_
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
trace() const
|
||||
{
|
||||
std::cerr << static_cast<unsigned long>(m_num_e) << " "
|
||||
<< static_cast<unsigned long>(m_num_used_e) << std::endl;
|
||||
|
||||
for (size_type i = 0; i < m_num_e; ++i)
|
||||
{
|
||||
std::cerr << static_cast<unsigned long>(i) << " ";
|
||||
trace_list(m_entries[i]);
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
trace_list(const_entry_pointer p_l) const
|
||||
{
|
||||
size_type iterated_num_used_e = 0;
|
||||
while (p_l != 0)
|
||||
{
|
||||
std::cerr << PB_DS_V2F(p_l->m_value) << " ";
|
||||
p_l = p_l->m_p_next;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
84
openflow/usr/include/c++/5/ext/pb_ds/detail/cond_dealtor.hpp
Normal file
84
openflow/usr/include/c++/5/ext/pb_ds/detail/cond_dealtor.hpp
Normal file
@@ -0,0 +1,84 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file detail/cond_dealtor.hpp
|
||||
* Contains a conditional deallocator.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_COND_DEALTOR_HPP
|
||||
#define PB_DS_COND_DEALTOR_HPP
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Conditional deallocate constructor argument.
|
||||
template<typename Entry, typename _Alloc>
|
||||
class cond_dealtor
|
||||
{
|
||||
typedef typename _Alloc::template rebind<Entry> __rebind_e;
|
||||
|
||||
public:
|
||||
typedef typename __rebind_e::other entry_allocator;
|
||||
typedef typename entry_allocator::pointer entry_pointer;
|
||||
|
||||
cond_dealtor(entry_pointer p_e)
|
||||
: m_p_e(p_e), m_no_action_destructor(false) { }
|
||||
|
||||
~cond_dealtor()
|
||||
{
|
||||
if (m_no_action_destructor)
|
||||
return;
|
||||
s_alloc.deallocate(m_p_e, 1);
|
||||
}
|
||||
|
||||
void
|
||||
set_no_action()
|
||||
{ m_no_action_destructor = true; }
|
||||
|
||||
private:
|
||||
entry_pointer m_p_e;
|
||||
bool m_no_action_destructor;
|
||||
static entry_allocator s_alloc;
|
||||
};
|
||||
|
||||
template<typename Entry, class _Alloc>
|
||||
typename cond_dealtor<Entry, _Alloc>::entry_allocator
|
||||
cond_dealtor<Entry, _Alloc>::s_alloc;
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif // #ifndef PB_DS_COND_DEALTOR_HPP
|
||||
@@ -0,0 +1,352 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file container_base_dispatch.hpp
|
||||
* Contains associative container dispatching.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_ASSOC_CNTNR_BASE_DS_DISPATCHER_HPP
|
||||
#define PB_DS_ASSOC_CNTNR_BASE_DS_DISPATCHER_HPP
|
||||
|
||||
#include <ext/typelist.h>
|
||||
|
||||
#define PB_DS_ASSERT_VALID(X) \
|
||||
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);)
|
||||
|
||||
#define PB_DS_DEBUG_VERIFY(_Cond) \
|
||||
_GLIBCXX_DEBUG_VERIFY_AT(_Cond, \
|
||||
_M_message(#_Cond" assertion from %1;:%2;") \
|
||||
._M_string(__FILE__)._M_integer(__LINE__) \
|
||||
,__file,__line)
|
||||
|
||||
#define PB_DS_CHECK_KEY_EXISTS(_Key) \
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_exists(_Key, __FILE__, __LINE__);)
|
||||
|
||||
#define PB_DS_CHECK_KEY_DOES_NOT_EXIST(_Key) \
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::check_key_does_not_exist(_Key, \
|
||||
__FILE__, __LINE__);)
|
||||
|
||||
#define PB_DS_DATA_TRUE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X).first
|
||||
#define PB_DS_V2S(X) (X).second
|
||||
#define PB_DS_EP2VP(X)& ((X)->m_value)
|
||||
#include <ext/pb_ds/detail/list_update_map_/lu_map_.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
|
||||
#include <ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp>
|
||||
#include <ext/pb_ds/detail/splay_tree_/splay_tree_.hpp>
|
||||
#include <ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp>
|
||||
#include <ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp>
|
||||
#include <ext/pb_ds/detail/pat_trie_/pat_trie_.hpp>
|
||||
#undef PB_DS_DATA_TRUE_INDICATOR
|
||||
#undef PB_DS_V2F
|
||||
#undef PB_DS_V2S
|
||||
#undef PB_DS_EP2VP
|
||||
|
||||
#define PB_DS_DATA_FALSE_INDICATOR
|
||||
#define PB_DS_V2F(X) (X)
|
||||
#define PB_DS_V2S(X) Mapped_Data()
|
||||
#define PB_DS_EP2VP(X)& ((X)->m_value.first)
|
||||
#include <ext/pb_ds/detail/list_update_map_/lu_map_.hpp>
|
||||
#include <ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp>
|
||||
#include <ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp>
|
||||
#include <ext/pb_ds/detail/splay_tree_/splay_tree_.hpp>
|
||||
#include <ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp>
|
||||
#include <ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp>
|
||||
#include <ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp>
|
||||
#include <ext/pb_ds/detail/pat_trie_/pat_trie_.hpp>
|
||||
#undef PB_DS_DATA_FALSE_INDICATOR
|
||||
#undef PB_DS_V2F
|
||||
#undef PB_DS_V2S
|
||||
#undef PB_DS_EP2VP
|
||||
|
||||
#undef PB_DS_CHECK_KEY_DOES_NOT_EXIST
|
||||
#undef PB_DS_CHECK_KEY_EXISTS
|
||||
#undef PB_DS_DEBUG_VERIFY
|
||||
#undef PB_DS_ASSERT_VALID
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Specialization for list-update map.
|
||||
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, Mapped, _Alloc, list_update_tag,
|
||||
Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef lu_map<Key, Mapped, at0t, _Alloc, at1t> type;
|
||||
};
|
||||
|
||||
/// Specialization for list-update set.
|
||||
template<typename Key, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, null_type, _Alloc, list_update_tag,
|
||||
Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef lu_set<Key, null_type, at0t, _Alloc, at1t> type;
|
||||
};
|
||||
|
||||
/// Specialization for PATRICIA trie map.
|
||||
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, Mapped, _Alloc, pat_trie_tag, Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
typedef pat_trie_map<Key, Mapped, at1t, _Alloc> type;
|
||||
};
|
||||
|
||||
/// Specialization for PATRICIA trie set.
|
||||
template<typename Key, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, null_type, _Alloc, pat_trie_tag,
|
||||
Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef pat_trie_set<Key, null_type, at1t, _Alloc> type;
|
||||
};
|
||||
|
||||
/// Specialization for R-B tree map.
|
||||
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, Mapped, _Alloc, rb_tree_tag, Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef rb_tree_map<Key, Mapped, at0t, at1t, _Alloc> type;
|
||||
};
|
||||
|
||||
/// Specialization for R-B tree set.
|
||||
template<typename Key, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, null_type, _Alloc, rb_tree_tag,
|
||||
Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
typedef rb_tree_set<Key, null_type, at0t, at1t, _Alloc> type;
|
||||
};
|
||||
|
||||
/// Specialization splay tree map.
|
||||
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, Mapped, _Alloc, splay_tree_tag,
|
||||
Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef splay_tree_map<Key, Mapped, at0t, at1t, _Alloc> type;
|
||||
};
|
||||
|
||||
/// Specialization splay tree set.
|
||||
template<typename Key, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, null_type, _Alloc, splay_tree_tag,
|
||||
Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef splay_tree_set<Key, null_type, at0t, at1t, _Alloc> type;
|
||||
};
|
||||
|
||||
/// Specialization ordered-vector tree map.
|
||||
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, Mapped, _Alloc, ov_tree_tag, Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef ov_tree_map<Key, Mapped, at0t, at1t, _Alloc> type;
|
||||
};
|
||||
|
||||
/// Specialization ordered-vector tree set.
|
||||
template<typename Key, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, null_type, _Alloc, ov_tree_tag,
|
||||
Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef ov_tree_set<Key, null_type, at0t, at1t, _Alloc> type;
|
||||
};
|
||||
|
||||
/// Specialization colision-chaining hash map.
|
||||
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, Mapped, _Alloc, cc_hash_tag, Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2> at2;
|
||||
typedef typename at2::type at2t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3> at3;
|
||||
typedef typename at3::type at3t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> at4;
|
||||
typedef typename at4::type at4t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef cc_ht_map<Key, Mapped, at0t, at1t, _Alloc,
|
||||
at3t::value, at4t, at2t> type;
|
||||
};
|
||||
|
||||
/// Specialization colision-chaining hash set.
|
||||
template<typename Key, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, null_type, _Alloc, cc_hash_tag,
|
||||
Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2> at2;
|
||||
typedef typename at2::type at2t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3> at3;
|
||||
typedef typename at3::type at3t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> at4;
|
||||
typedef typename at4::type at4t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef cc_ht_set<Key, null_type, at0t, at1t, _Alloc,
|
||||
at3t::value, at4t, at2t> type;
|
||||
};
|
||||
|
||||
/// Specialization general-probe hash map.
|
||||
template<typename Key, typename Mapped, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, Mapped, _Alloc, gp_hash_tag, Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2> at2;
|
||||
typedef typename at2::type at2t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3> at3;
|
||||
typedef typename at3::type at3t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> at4;
|
||||
typedef typename at4::type at4t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 5> at5;
|
||||
typedef typename at5::type at5t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef gp_ht_map<Key, Mapped, at0t, at1t, _Alloc,
|
||||
at3t::value, at4t, at5t, at2t> type;
|
||||
};
|
||||
|
||||
/// Specialization general-probe hash set.
|
||||
template<typename Key, typename _Alloc, typename Policy_Tl>
|
||||
struct container_base_dispatch<Key, null_type, _Alloc, gp_hash_tag,
|
||||
Policy_Tl>
|
||||
{
|
||||
private:
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0> at0;
|
||||
typedef typename at0::type at0t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> at1;
|
||||
typedef typename at1::type at1t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2> at2;
|
||||
typedef typename at2::type at2t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3> at3;
|
||||
typedef typename at3::type at3t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> at4;
|
||||
typedef typename at4::type at4t;
|
||||
typedef __gnu_cxx::typelist::at_index<Policy_Tl, 5> at5;
|
||||
typedef typename at5::type at5t;
|
||||
|
||||
public:
|
||||
/// Dispatched type.
|
||||
typedef gp_ht_set<Key, null_type, at0t, at1t, _Alloc,
|
||||
at3t::value, at4t, at5t, at2t> type;
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
349
openflow/usr/include/c++/5/ext/pb_ds/detail/debug_map_base.hpp
Normal file
349
openflow/usr/include/c++/5/ext/pb_ds/detail/debug_map_base.hpp
Normal file
@@ -0,0 +1,349 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file detail/debug_map_base.hpp
|
||||
* Contains a debug-mode base for all maps.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_DEBUG_MAP_BASE_HPP
|
||||
#define PB_DS_DEBUG_MAP_BASE_HPP
|
||||
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <ext/throw_allocator.h>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
// Need std::pair ostream extractor.
|
||||
template<typename _CharT, typename _Traits, typename _Tp1, typename _Tp2>
|
||||
inline std::basic_ostream<_CharT, _Traits>&
|
||||
operator<<(std::basic_ostream<_CharT, _Traits>& __out,
|
||||
const std::pair<_Tp1, _Tp2>& p)
|
||||
{ return (__out << '(' << p.first << ',' << p.second << ')'); }
|
||||
|
||||
#define PB_DS_CLASS_T_DEC \
|
||||
template<typename Key, typename Eq_Fn, typename Const_Key_Reference>
|
||||
|
||||
#define PB_DS_CLASS_C_DEC \
|
||||
debug_map_base<Key, Eq_Fn, Const_Key_Reference>
|
||||
|
||||
/// Debug base class.
|
||||
template<typename Key, typename Eq_Fn, typename Const_Key_Reference>
|
||||
class debug_map_base
|
||||
{
|
||||
private:
|
||||
typedef Const_Key_Reference key_const_reference;
|
||||
typedef std::_GLIBCXX_STD_C::list<Key> key_repository;
|
||||
typedef typename key_repository::size_type size_type;
|
||||
typedef typename key_repository::iterator iterator;
|
||||
typedef typename key_repository::const_iterator const_iterator;
|
||||
|
||||
protected:
|
||||
debug_map_base();
|
||||
|
||||
debug_map_base(const PB_DS_CLASS_C_DEC&);
|
||||
|
||||
~debug_map_base();
|
||||
|
||||
inline void
|
||||
insert_new(key_const_reference);
|
||||
|
||||
inline void
|
||||
erase_existing(key_const_reference);
|
||||
|
||||
void
|
||||
clear();
|
||||
|
||||
inline void
|
||||
check_key_exists(key_const_reference, const char*, int) const;
|
||||
|
||||
inline void
|
||||
check_key_does_not_exist(key_const_reference, const char*, int) const;
|
||||
|
||||
inline void
|
||||
check_size(size_type, const char*, int) const;
|
||||
|
||||
void
|
||||
swap(PB_DS_CLASS_C_DEC&);
|
||||
|
||||
template<typename Cmp_Fn>
|
||||
void
|
||||
split(key_const_reference, Cmp_Fn, PB_DS_CLASS_C_DEC&);
|
||||
|
||||
void
|
||||
join(PB_DS_CLASS_C_DEC&, bool with_cleanup = true);
|
||||
|
||||
private:
|
||||
void
|
||||
assert_valid(const char*, int) const;
|
||||
|
||||
const_iterator
|
||||
find(key_const_reference) const;
|
||||
|
||||
iterator
|
||||
find(key_const_reference);
|
||||
|
||||
key_repository m_keys;
|
||||
Eq_Fn m_eq;
|
||||
};
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
debug_map_base()
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
debug_map_base(const PB_DS_CLASS_C_DEC& other)
|
||||
: m_keys(other.m_keys), m_eq(other.m_eq)
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~debug_map_base()
|
||||
{ PB_DS_ASSERT_VALID((*this)) }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
insert_new(key_const_reference r_key)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
|
||||
if (find(r_key) != m_keys.end())
|
||||
{
|
||||
std::cerr << "insert_new key already present " << r_key << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
|
||||
__try
|
||||
{
|
||||
m_keys.push_back(r_key);
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
std::cerr << "insert_new " << r_key << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_existing(key_const_reference r_key)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
iterator it = find(r_key);
|
||||
if (it == m_keys.end())
|
||||
{
|
||||
std::cerr << "erase_existing" << r_key << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
m_keys.erase(it);
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
clear()
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
m_keys.clear();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
check_key_exists(key_const_reference r_key,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
assert_valid(__file, __line);
|
||||
if (find(r_key) == m_keys.end())
|
||||
{
|
||||
std::cerr << __file << ':' << __line << ": check_key_exists "
|
||||
<< r_key << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
check_key_does_not_exist(key_const_reference r_key,
|
||||
const char* __file, int __line) const
|
||||
{
|
||||
assert_valid(__file, __line);
|
||||
if (find(r_key) != m_keys.end())
|
||||
{
|
||||
using std::cerr;
|
||||
using std::endl;
|
||||
cerr << __file << ':' << __line << ": check_key_does_not_exist "
|
||||
<< r_key << endl;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
inline void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
check_size(size_type size, const char* __file, int __line) const
|
||||
{
|
||||
assert_valid(__file, __line);
|
||||
const size_type keys_size = m_keys.size();
|
||||
if (size != keys_size)
|
||||
{
|
||||
std::cerr << __file << ':' << __line << ": check_size "
|
||||
<< size << " != " << keys_size << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
m_keys.swap(other.m_keys);
|
||||
std::swap(m_eq, other.m_eq);
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::const_iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find(key_const_reference r_key) const
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
typedef const_iterator iterator_type;
|
||||
for (iterator_type it = m_keys.begin(); it != m_keys.end(); ++it)
|
||||
if (m_eq(*it, r_key))
|
||||
return it;
|
||||
return m_keys.end();
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::iterator
|
||||
PB_DS_CLASS_C_DEC::
|
||||
find(key_const_reference r_key)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
iterator it = m_keys.begin();
|
||||
while (it != m_keys.end())
|
||||
{
|
||||
if (m_eq(*it, r_key))
|
||||
return it;
|
||||
++it;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
assert_valid(const char* __file, int __line) const
|
||||
{
|
||||
const_iterator prime_it = m_keys.begin();
|
||||
while (prime_it != m_keys.end())
|
||||
{
|
||||
const_iterator sec_it = prime_it;
|
||||
++sec_it;
|
||||
while (sec_it != m_keys.end())
|
||||
{
|
||||
PB_DS_DEBUG_VERIFY(!m_eq(*sec_it, *prime_it));
|
||||
PB_DS_DEBUG_VERIFY(!m_eq(*prime_it, *sec_it));
|
||||
++sec_it;
|
||||
}
|
||||
++prime_it;
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename Cmp_Fn>
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
split(key_const_reference r_key, Cmp_Fn cmp_fn, PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
other.clear();
|
||||
iterator it = m_keys.begin();
|
||||
while (it != m_keys.end())
|
||||
if (cmp_fn(r_key, *it))
|
||||
{
|
||||
other.insert_new(*it);
|
||||
it = m_keys.erase(it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
join(PB_DS_CLASS_C_DEC& other, bool with_cleanup)
|
||||
{
|
||||
iterator it = other.m_keys.begin();
|
||||
while (it != other.m_keys.end())
|
||||
{
|
||||
insert_new(*it);
|
||||
if (with_cleanup)
|
||||
it = other.m_keys.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
_GLIBCXX_DEBUG_ASSERT(!with_cleanup || other.m_keys.empty());
|
||||
}
|
||||
|
||||
#undef PB_DS_CLASS_T_DEC
|
||||
#undef PB_DS_CLASS_C_DEC
|
||||
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file eq_by_less.hpp
|
||||
* Contains an equivalence function.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_EQ_BY_LESS_HPP
|
||||
#define PB_DS_EQ_BY_LESS_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include <ext/pb_ds/detail/types_traits.hpp>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Equivalence function.
|
||||
template<typename Key, class Cmp_Fn>
|
||||
struct eq_by_less : private Cmp_Fn
|
||||
{
|
||||
bool
|
||||
operator()(const Key& r_lhs, const Key& r_rhs) const
|
||||
{
|
||||
const bool l = Cmp_Fn::operator()(r_lhs, r_rhs);
|
||||
const bool g = Cmp_Fn::operator()(r_rhs, r_lhs);
|
||||
return !(l || g);
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif // #ifndef PB_DS_EQ_BY_LESS_HPP
|
||||
110
openflow/usr/include/c++/5/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp
Normal file
110
openflow/usr/include/c++/5/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp
Normal file
@@ -0,0 +1,110 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file hash_eq_fn.hpp
|
||||
* Contains 2 eqivalence functions, one employing a hash value,
|
||||
* and one ignoring it.
|
||||
*/
|
||||
|
||||
#ifndef PB_DS_HASH_EQ_FN_HPP
|
||||
#define PB_DS_HASH_EQ_FN_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <debug/debug.h>
|
||||
|
||||
namespace __gnu_pbds
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
/// Primary template.
|
||||
template<typename Key, typename Eq_Fn, typename _Alloc, bool Store_Hash>
|
||||
struct hash_eq_fn;
|
||||
|
||||
/// Specialization 1 - The client requests that hash values not be stored.
|
||||
template<typename Key, typename Eq_Fn, typename _Alloc>
|
||||
struct hash_eq_fn<Key, Eq_Fn, _Alloc, false> : public Eq_Fn
|
||||
{
|
||||
typedef Eq_Fn eq_fn_base;
|
||||
typedef typename _Alloc::template rebind<Key>::other key_allocator;
|
||||
typedef typename key_allocator::const_reference key_const_reference;
|
||||
|
||||
hash_eq_fn() { }
|
||||
|
||||
hash_eq_fn(const Eq_Fn& r_eq_fn) : Eq_Fn(r_eq_fn) { }
|
||||
|
||||
bool
|
||||
operator()(key_const_reference r_lhs_key,
|
||||
key_const_reference r_rhs_key) const
|
||||
{ return eq_fn_base::operator()(r_lhs_key, r_rhs_key); }
|
||||
|
||||
void
|
||||
swap(const hash_eq_fn& other)
|
||||
{ std::swap((Eq_Fn&)(*this), (Eq_Fn&)other); }
|
||||
};
|
||||
|
||||
|
||||
/// Specialization 2 - The client requests that hash values be stored.
|
||||
template<typename Key, class Eq_Fn, class _Alloc>
|
||||
struct hash_eq_fn<Key, Eq_Fn, _Alloc, true> : public Eq_Fn
|
||||
{
|
||||
typedef typename _Alloc::size_type size_type;
|
||||
typedef Eq_Fn eq_fn_base;
|
||||
typedef typename _Alloc::template rebind<Key>::other key_allocator;
|
||||
typedef typename key_allocator::const_reference key_const_reference;
|
||||
|
||||
hash_eq_fn() { }
|
||||
|
||||
hash_eq_fn(const Eq_Fn& r_eq_fn) : Eq_Fn(r_eq_fn) { }
|
||||
|
||||
bool
|
||||
operator()(key_const_reference r_lhs_key, size_type lhs_hash,
|
||||
key_const_reference r_rhs_key, size_type rhs_hash) const
|
||||
{
|
||||
_GLIBCXX_DEBUG_ASSERT(!eq_fn_base::operator()(r_lhs_key, r_rhs_key)
|
||||
|| lhs_hash == rhs_hash);
|
||||
|
||||
return (lhs_hash == rhs_hash &&
|
||||
eq_fn_base::operator()(r_lhs_key, r_rhs_key));
|
||||
}
|
||||
|
||||
void
|
||||
swap(const hash_eq_fn& other)
|
||||
{ std::swap((Eq_Fn&)(*this), (Eq_Fn&)(other)); }
|
||||
};
|
||||
} // namespace detail
|
||||
} // namespace __gnu_pbds
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,223 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2005-2015 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; 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, or (at your option) any later
|
||||
// version.
|
||||
|
||||
// This library is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
|
||||
// Under Section 7 of GPL version 3, you are granted additional
|
||||
// permissions described in the GCC Runtime Library Exception, version
|
||||
// 3.1, as published by the Free Software Foundation.
|
||||
|
||||
// You should have received a copy of the GNU General Public License and
|
||||
// a copy of the GCC Runtime Library Exception along with this program;
|
||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
|
||||
|
||||
// Permission to use, copy, modify, sell, and distribute this software
|
||||
// is hereby granted without fee, provided that the above copyright
|
||||
// notice appears in all copies, and that both that copyright notice
|
||||
// and this permission notice appear in supporting documentation. None
|
||||
// of the above authors, nor IBM Haifa Research Laboratories, make any
|
||||
// representation about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied
|
||||
// warranty.
|
||||
|
||||
/**
|
||||
* @file gp_hash_table_map_/constructor_destructor_fn_imps.hpp
|
||||
* Contains implementations of gp_ht_map_'s constructors, destructor,
|
||||
* and related functions.
|
||||
*/
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
typename PB_DS_CLASS_C_DEC::entry_allocator
|
||||
PB_DS_CLASS_C_DEC::s_entry_allocator;
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
template<typename It>
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
copy_from_range(It first_it, It last_it)
|
||||
{
|
||||
while (first_it != last_it)
|
||||
insert(*(first_it++));
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_GP_HASH_NAME()
|
||||
: ranged_probe_fn_base(resize_base::get_nearest_larger_size(1)),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn)
|
||||
: ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn)
|
||||
: hash_eq_fn_base(r_eq_fn),
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1), r_hash_fn),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
|
||||
const Comb_Probe_Fn& r_comb_hash_fn)
|
||||
: hash_eq_fn_base(r_eq_fn),
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn, r_comb_hash_fn),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
|
||||
const Comb_Probe_Fn& comb_hash_fn, const Probe_Fn& prober)
|
||||
: hash_eq_fn_base(r_eq_fn),
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn, comb_hash_fn, prober),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_GP_HASH_NAME(const Hash_Fn& r_hash_fn, const Eq_Fn& r_eq_fn,
|
||||
const Comb_Probe_Fn& comb_hash_fn, const Probe_Fn& prober,
|
||||
const Resize_Policy& r_resize_policy)
|
||||
: hash_eq_fn_base(r_eq_fn), resize_base(r_resize_policy),
|
||||
ranged_probe_fn_base(resize_base::get_nearest_larger_size(1),
|
||||
r_hash_fn, comb_hash_fn, prober),
|
||||
m_num_e(resize_base::get_nearest_larger_size(1)), m_num_used_e(0),
|
||||
m_entries(s_entry_allocator.allocate(m_num_e))
|
||||
{
|
||||
initialize();
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
PB_DS_GP_HASH_NAME(const PB_DS_CLASS_C_DEC& other) :
|
||||
#ifdef _GLIBCXX_DEBUG
|
||||
debug_base(other),
|
||||
#endif
|
||||
hash_eq_fn_base(other),
|
||||
resize_base(other),
|
||||
ranged_probe_fn_base(other),
|
||||
m_num_e(other.m_num_e),
|
||||
m_num_used_e(other.m_num_used_e),
|
||||
m_entries(s_entry_allocator.allocate(m_num_e))
|
||||
{
|
||||
for (size_type i = 0; i < m_num_e; ++i)
|
||||
m_entries[i].m_stat = (entry_status)empty_entry_status;
|
||||
|
||||
__try
|
||||
{
|
||||
for (size_type i = 0; i < m_num_e; ++i)
|
||||
{
|
||||
m_entries[i].m_stat = other.m_entries[i].m_stat;
|
||||
if (m_entries[i].m_stat == valid_entry_status)
|
||||
new (m_entries + i) entry(other.m_entries[i]);
|
||||
}
|
||||
}
|
||||
__catch(...)
|
||||
{
|
||||
deallocate_all();
|
||||
__throw_exception_again;
|
||||
}
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
PB_DS_CLASS_C_DEC::
|
||||
~PB_DS_GP_HASH_NAME()
|
||||
{ deallocate_all(); }
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
swap(PB_DS_CLASS_C_DEC& other)
|
||||
{
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
std::swap(m_num_e, other.m_num_e);
|
||||
std::swap(m_num_used_e, other.m_num_used_e);
|
||||
std::swap(m_entries, other.m_entries);
|
||||
ranged_probe_fn_base::swap(other);
|
||||
hash_eq_fn_base::swap(other);
|
||||
resize_base::swap(other);
|
||||
_GLIBCXX_DEBUG_ONLY(debug_base::swap(other));
|
||||
PB_DS_ASSERT_VALID((*this))
|
||||
PB_DS_ASSERT_VALID(other)
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
deallocate_all()
|
||||
{
|
||||
clear();
|
||||
erase_all_valid_entries(m_entries, m_num_e);
|
||||
s_entry_allocator.deallocate(m_entries, m_num_e);
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
erase_all_valid_entries(entry_array a_entries_resized, size_type len)
|
||||
{
|
||||
for (size_type pos = 0; pos < len; ++pos)
|
||||
{
|
||||
entry_pointer p_e = &a_entries_resized[pos];
|
||||
if (p_e->m_stat == valid_entry_status)
|
||||
p_e->m_value.~value_type();
|
||||
}
|
||||
}
|
||||
|
||||
PB_DS_CLASS_T_DEC
|
||||
void
|
||||
PB_DS_CLASS_C_DEC::
|
||||
initialize()
|
||||
{
|
||||
Resize_Policy::notify_resized(m_num_e);
|
||||
Resize_Policy::notify_cleared();
|
||||
ranged_probe_fn_base::notify_resized(m_num_e);
|
||||
for (size_type i = 0; i < m_num_e; ++i)
|
||||
m_entries[i].m_stat = empty_entry_status;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user