/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/assoc_container.hpp |
---|
0,0 → 1,861 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp |
---|
0,0 → 1,428 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,218 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp |
---|
0,0 → 1,277 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp |
---|
0,0 → 1,103 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp |
---|
0,0 → 1,171 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp |
---|
0,0 → 1,64 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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()); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp |
---|
0,0 → 1,180 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp |
---|
0,0 → 1,136 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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)); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp |
---|
0,0 → 1,189 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp |
---|
0,0 → 1,367 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp |
---|
0,0 → 1,52 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp |
---|
0,0 → 1,103 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp |
---|
0,0 → 1,155 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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*/) |
{ } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp |
---|
0,0 → 1,150 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/bin_search_tree_/traits.hpp |
---|
0,0 → 1,241 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp |
---|
0,0 → 1,352 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/const_iterator.hpp |
---|
0,0 → 1,139 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,139 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp |
---|
0,0 → 1,72 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp |
---|
0,0 → 1,85 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/entry_pred.hpp |
---|
0,0 → 1,85 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp |
---|
0,0 → 1,208 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp |
---|
0,0 → 1,79 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp |
---|
0,0 → 1,58 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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(); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp |
---|
0,0 → 1,174 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp |
---|
0,0 → 1,64 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp |
---|
0,0 → 1,144 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp |
---|
0,0 → 1,56 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/resize_policy.hpp |
---|
0,0 → 1,240 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp |
---|
0,0 → 1,160 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp |
---|
0,0 → 1,78 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_ |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp |
---|
0,0 → 1,112 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,60 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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() { } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp |
---|
0,0 → 1,49 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp |
---|
0,0 → 1,211 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,85 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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() |
{ } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp |
---|
0,0 → 1,100 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp |
---|
0,0 → 1,161 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp |
---|
0,0 → 1,70 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp |
---|
0,0 → 1,178 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp |
---|
0,0 → 1,197 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/branch_policy/branch_policy.hpp |
---|
0,0 → 1,119 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/branch_policy/null_node_metadata.hpp |
---|
0,0 → 1,66 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/branch_policy/traits.hpp |
---|
0,0 → 1,95 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp |
---|
0,0 → 1,679 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp |
---|
0,0 → 1,83 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp |
---|
0,0 → 1,90 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp |
---|
0,0 → 1,191 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,55 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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);) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp |
---|
0,0 → 1,56 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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);) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp |
---|
0,0 → 1,76 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,50 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp |
---|
0,0 → 1,54 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp |
---|
0,0 → 1,91 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp |
---|
0,0 → 1,103 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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> |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,100 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp |
---|
0,0 → 1,94 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp |
---|
0,0 → 1,71 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp |
---|
0,0 → 1,41 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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. |
*/ |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp |
---|
0,0 → 1,100 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp |
---|
0,0 → 1,43 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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> |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,70 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp |
---|
0,0 → 1,71 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp |
---|
0,0 → 1,83 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp |
---|
0,0 → 1,88 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp |
---|
0,0 → 1,134 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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> |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,54 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp |
---|
0,0 → 1,54 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp |
---|
0,0 → 1,59 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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(); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp |
---|
0,0 → 1,72 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/cond_dealtor.hpp |
---|
0,0 → 1,84 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/container_base_dispatch.hpp |
---|
0,0 → 1,352 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/debug_map_base.hpp |
---|
0,0 → 1,349 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/eq_fn/eq_by_less.hpp |
---|
0,0 → 1,69 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp |
---|
0,0 → 1,110 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp |
---|
0,0 → 1,223 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,53 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_no_store_hash_fn_imps.hpp |
* Contains implementations of gp_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) |
{ |
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status)k; |
entry* const p_e = m_entries + pos; |
new (&p_e->m_value) mapped_value_type(r_val); |
p_e->m_stat = valid_entry_status; |
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(p_e->m_value.first);) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp |
---|
0,0 → 1,54 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_store_hash_fn_imps.hpp |
* Contains implementations of gp_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, |
true_type) |
{ |
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status); |
entry* const p_e = m_entries + pos; |
new (&p_e->m_value) mapped_value_type(r_val); |
p_e->m_hash = ranged_probe_fn_base::operator()(PB_DS_V2F(r_val)).second; |
p_e->m_stat = valid_entry_status; |
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(p_e->m_value.first);) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp |
---|
0,0 → 1,56 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/debug_fn_imps.hpp |
* Contains implementations of gp_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_array_valid(m_entries, traits_base::m_store_extra_indicator, |
__file, __line); |
} |
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp> |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,72 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/debug_no_store_hash_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s debug-mode functions. |
*/ |
#ifdef _GLIBCXX_DEBUG |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_entry_array_valid(const entry_array a_entries, false_type, |
const char* __file, int __line) const |
{ |
size_type iterated_num_used_e = 0; |
for (size_type pos = 0; pos < m_num_e; ++pos) |
{ |
const_entry_pointer p_e = &a_entries[pos]; |
switch(p_e->m_stat) |
{ |
case empty_entry_status: |
case erased_entry_status: |
break; |
case valid_entry_status: |
{ |
key_const_reference r_key = PB_DS_V2F(p_e->m_value); |
debug_base::check_key_exists(r_key, __file, __line); |
++iterated_num_used_e; |
break; |
} |
default: |
PB_DS_DEBUG_VERIFY(0); |
}; |
} |
PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e); |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp |
---|
0,0 → 1,78 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/debug_store_hash_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s debug-mode functions. |
*/ |
#ifdef _GLIBCXX_DEBUG |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_entry_array_valid(const entry_array a_entries, true_type, |
const char* __file, int __line) const |
{ |
size_type iterated_num_used_e = 0; |
for (size_type pos = 0; pos < m_num_e; ++pos) |
{ |
const_entry_pointer p_e =& a_entries[pos]; |
switch(p_e->m_stat) |
{ |
case empty_entry_status: |
case erased_entry_status: |
break; |
case valid_entry_status: |
{ |
key_const_reference r_key = PB_DS_V2F(p_e->m_value); |
debug_base::check_key_exists(r_key, __file, __line); |
const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); |
PB_DS_DEBUG_VERIFY(p_e->m_hash == pos_hash_pair.second); |
++iterated_num_used_e; |
break; |
} |
default: |
PB_DS_DEBUG_VERIFY(0); |
}; |
} |
PB_DS_DEBUG_VERIFY(iterated_num_used_e == m_num_used_e); |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp |
---|
0,0 → 1,100 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/erase_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s erase related functions. |
*/ |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
erase_entry(entry_pointer p_e) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_e->m_stat = valid_entry_status); |
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_e->m_value));) |
p_e->m_value.~value_type(); |
p_e->m_stat = erased_entry_status; |
_GLIBCXX_DEBUG_ASSERT(m_num_used_e > 0); |
resize_base::notify_erased(--m_num_used_e); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
clear() |
{ |
for (size_type pos = 0; pos < m_num_e; ++pos) |
{ |
entry_pointer p_e = &m_entries[pos]; |
if (p_e->m_stat == valid_entry_status) |
erase_entry(p_e); |
} |
do_resize_if_needed_no_throw(); |
resize_base::notify_cleared(); |
} |
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) |
{ |
PB_DS_ASSERT_VALID((*this)) |
size_type num_ersd = 0; |
for (size_type pos = 0; pos < m_num_e; ++pos) |
{ |
entry_pointer p_e = &m_entries[pos]; |
if (p_e->m_stat == valid_entry_status) |
if (pred(p_e->m_value)) |
{ |
++num_ersd; |
erase_entry(p_e); |
} |
} |
do_resize_if_needed_no_throw(); |
PB_DS_ASSERT_VALID((*this)) |
return num_ersd; |
} |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
erase(key_const_reference r_key) |
{ return erase_imp(r_key, traits_base::m_store_extra_indicator); } |
#include <ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp> |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,84 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/erase_no_store_hash_fn_imps.hpp |
* Contains implementations of gp_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_imp(key_const_reference r_key, false_type) |
{ |
PB_DS_ASSERT_VALID((*this)) |
size_type hash = ranged_probe_fn_base::operator()(r_key); |
size_type i; |
resize_base::notify_erase_search_start(); |
for (i = 0; i < m_num_e; ++i) |
{ |
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i); |
entry* const p_e = m_entries + pos; |
switch(p_e->m_stat) |
{ |
case empty_entry_status: |
{ |
resize_base::notify_erase_search_end(); |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return false; |
} |
break; |
case valid_entry_status: |
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) |
{ |
resize_base::notify_erase_search_end(); |
erase_entry(p_e); |
do_resize_if_needed_no_throw(); |
return true; |
} |
break; |
case erased_entry_status: |
break; |
default: |
_GLIBCXX_DEBUG_ASSERT(0); |
}; |
resize_base::notify_erase_search_collision(); |
} |
resize_base::notify_erase_search_end(); |
return false; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp |
---|
0,0 → 1,85 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/erase_store_hash_fn_imps.hpp |
* Contains implementations of gp_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_imp(key_const_reference r_key, true_type) |
{ |
const comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); |
size_type i; |
resize_base::notify_erase_search_start(); |
for (i = 0; i < m_num_e; ++i) |
{ |
const size_type pos = ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i); |
entry* const p_e = m_entries + pos; |
switch(p_e->m_stat) |
{ |
case empty_entry_status: |
{ |
resize_base::notify_erase_search_end(); |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return false; |
} |
break; |
case valid_entry_status: |
if (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_erase_search_end(); |
erase_entry(p_e); |
do_resize_if_needed_no_throw(); |
return true; |
} |
break; |
case erased_entry_status: |
break; |
default: |
_GLIBCXX_DEBUG_ASSERT(0); |
}; |
resize_base::notify_erase_search_collision(); |
} |
resize_base::notify_erase_search_end(); |
return false; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp |
---|
0,0 → 1,70 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/find_fn_imps.hpp |
* Contains implementations of gp_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; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,46 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/find_no_store_hash_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s find related functions, |
* when the hash value is not stored. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::pointer |
PB_DS_CLASS_C_DEC:: |
find_key_pointer(key_const_reference r_key, false_type) |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp |
---|
0,0 → 1,40 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/find_store_hash_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s insert related functions, |
* when the hash value is stored. |
*/ |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp |
---|
0,0 → 1,713 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/gp_ht_map_.hpp |
* Contains an implementation class for general probing hash. |
*/ |
#include <ext/pb_ds/tag_and_trait.hpp> |
#include <ext/pb_ds/detail/hash_fn/ranged_probe_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> |
#include <utility> |
#ifdef PB_DS_HT_MAP_TRACE_ |
#include <iostream> |
#endif |
#ifdef _GLIBCXX_DEBUG |
#include <ext/pb_ds/detail/debug_map_base.hpp> |
#endif |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
#define PB_DS_GP_HASH_NAME gp_ht_map |
#endif |
#ifdef PB_DS_DATA_FALSE_INDICATOR |
#define PB_DS_GP_HASH_NAME gp_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_Probe_Fn, \ |
typename Probe_Fn, typename Resize_Policy> |
#define PB_DS_CLASS_C_DEC \ |
PB_DS_GP_HASH_NAME<Key, Mapped, Hash_Fn, Eq_Fn, _Alloc, \ |
Store_Hash, Comb_Probe_Fn, Probe_Fn, Resize_Policy> |
#define PB_DS_HASH_EQ_FN_C_DEC \ |
hash_eq_fn<Key, Eq_Fn, _Alloc, Store_Hash> |
#define PB_DS_RANGED_PROBE_FN_C_DEC \ |
ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, Probe_Fn, Store_Hash> |
#define PB_DS_GP_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 general-probing 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_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. |
* Default direct_mask_range_hashing. |
* |
* @tparam Probe_Fn Probe functor. |
* Defaults to linear_probe_fn, |
* also quadratic_probe_fn. |
* |
* @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_probe_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_Probe_Fn, |
typename Probe_Fn, |
typename Resize_Policy> |
class PB_DS_GP_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_PROBE_FN_C_DEC, |
public PB_DS_GP_HASH_TRAITS_BASE |
{ |
private: |
typedef PB_DS_GP_HASH_TRAITS_BASE traits_base; |
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_base::comp_hash comp_hash; |
enum entry_status |
{ |
empty_entry_status, |
valid_entry_status, |
erased_entry_status |
} __attribute__ ((packed)); |
struct entry : public traits_base::stored_data_type |
{ |
entry_status m_stat; |
}; |
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 entry_allocator::pointer entry_array; |
typedef PB_DS_RANGED_PROBE_FN_C_DEC ranged_probe_fn_base; |
#ifdef _GLIBCXX_DEBUG |
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; |
#endif |
typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base; |
typedef Resize_Policy resize_base; |
#define PB_DS_GEN_POS 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 Probe_Fn probe_fn; |
typedef Comb_Probe_Fn comb_probe_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_GP_HASH_NAME(); |
PB_DS_GP_HASH_NAME(const PB_DS_CLASS_C_DEC&); |
PB_DS_GP_HASH_NAME(const Hash_Fn&); |
PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&); |
PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&); |
PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&, |
const Probe_Fn&); |
PB_DS_GP_HASH_NAME(const Hash_Fn&, const Eq_Fn&, const Comb_Probe_Fn&, |
const Probe_Fn&, const Resize_Policy&); |
template<typename It> |
void |
copy_from_range(It, It); |
virtual |
~PB_DS_GP_HASH_NAME(); |
void |
swap(PB_DS_CLASS_C_DEC&); |
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 probe_fn. |
Probe_Fn& |
get_probe_fn(); |
/// Return current const probe_fn. |
const Probe_Fn& |
get_probe_fn() const; |
/// Return current comb_probe_fn. |
Comb_Probe_Fn& |
get_comb_probe_fn(); |
/// Return current const comb_probe_fn. |
const Comb_Probe_Fn& |
get_comb_probe_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) |
{ |
_GLIBCXX_DEBUG_ONLY(PB_DS_CLASS_C_DEC::assert_valid(__FILE__, __LINE__);) |
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: |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
friend class iterator_; |
#endif |
friend class const_iterator_; |
void |
deallocate_all(); |
void |
initialize(); |
void |
erase_all_valid_entries(entry_array, size_type); |
inline bool |
do_resize_if_needed(); |
inline void |
do_resize_if_needed_no_throw(); |
void |
resize_imp(size_type); |
virtual void |
do_resize(size_type); |
void |
resize_imp(entry_array, size_type); |
inline void |
resize_imp_reassign(entry_pointer, entry_array, false_type); |
inline void |
resize_imp_reassign(entry_pointer, entry_array, true_type); |
inline size_type |
find_ins_pos(key_const_reference, false_type); |
inline comp_hash |
find_ins_pos(key_const_reference, true_type); |
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) |
{ |
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status); |
if (do_resize_if_needed()) |
pos = find_ins_pos(PB_DS_V2F(r_val), |
traits_base::m_store_extra_indicator); |
_GLIBCXX_DEBUG_ASSERT(m_entries[pos].m_stat != valid_entry_status); |
entry* const p_e = m_entries + pos; |
new (&p_e->m_value) value_type(r_val); |
p_e->m_stat = valid_entry_status; |
resize_base::notify_inserted(++m_num_used_e); |
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));) |
_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) |
{ |
_GLIBCXX_DEBUG_ASSERT(m_entries[r_pos_hash_pair.first].m_stat != |
valid_entry_status); |
if (do_resize_if_needed()) |
r_pos_hash_pair = find_ins_pos(PB_DS_V2F(r_val), |
traits_base::m_store_extra_indicator); |
_GLIBCXX_DEBUG_ASSERT(m_entries[r_pos_hash_pair.first].m_stat != |
valid_entry_status); |
entry* const p_e = m_entries + r_pos_hash_pair.first; |
new (&p_e->m_value) value_type(r_val); |
p_e->m_hash = r_pos_hash_pair.second; |
p_e->m_stat = valid_entry_status; |
resize_base::notify_inserted(++m_num_used_e); |
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(p_e->m_value));) |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
return &p_e->m_value; |
} |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
inline mapped_reference |
subscript_imp(key_const_reference key, false_type) |
{ |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
const size_type pos = find_ins_pos(key, |
traits_base::m_store_extra_indicator); |
entry_pointer p_e = &m_entries[pos]; |
if (p_e->m_stat != valid_entry_status) |
return insert_new_imp(value_type(key, mapped_type()), pos)->second; |
PB_DS_CHECK_KEY_EXISTS(key) |
return p_e->m_value.second; |
} |
inline mapped_reference |
subscript_imp(key_const_reference key, true_type) |
{ |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
comp_hash pos_hash_pair = find_ins_pos(key, |
traits_base::m_store_extra_indicator); |
if (m_entries[pos_hash_pair.first].m_stat != valid_entry_status) |
return insert_new_imp(value_type(key, mapped_type()), |
pos_hash_pair)->second; |
PB_DS_CHECK_KEY_EXISTS(key) |
return (m_entries + pos_hash_pair.first)->m_value.second; |
} |
#endif |
inline pointer |
find_key_pointer(key_const_reference key, false_type) |
{ |
const size_type hash = ranged_probe_fn_base::operator()(key); |
resize_base::notify_find_search_start(); |
// Loop until entry is found or until all possible entries accessed. |
for (size_type i = 0; i < m_num_e; ++i) |
{ |
const size_type pos = ranged_probe_fn_base::operator()(key, |
hash, i); |
entry* const p_e = m_entries + pos; |
switch (p_e->m_stat) |
{ |
case empty_entry_status: |
{ |
resize_base::notify_find_search_end(); |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) |
return 0; |
} |
break; |
case valid_entry_status: |
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), key)) |
{ |
resize_base::notify_find_search_end(); |
PB_DS_CHECK_KEY_EXISTS(key) |
return pointer(&p_e->m_value); |
} |
break; |
case erased_entry_status: |
break; |
default: |
_GLIBCXX_DEBUG_ASSERT(0); |
}; |
resize_base::notify_find_search_collision(); |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) |
resize_base::notify_find_search_end(); |
return 0; |
} |
inline pointer |
find_key_pointer(key_const_reference key, true_type) |
{ |
comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(key); |
resize_base::notify_find_search_start(); |
// Loop until entry is found or until all possible entries accessed. |
for (size_type i = 0; i < m_num_e; ++i) |
{ |
const size_type pos = |
ranged_probe_fn_base::operator()(key, pos_hash_pair.second, i); |
entry* const p_e = m_entries + pos; |
switch(p_e->m_stat) |
{ |
case empty_entry_status: |
{ |
resize_base::notify_find_search_end(); |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) |
return 0; |
} |
break; |
case valid_entry_status: |
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), |
p_e->m_hash, |
key, pos_hash_pair.second)) |
{ |
resize_base::notify_find_search_end(); |
PB_DS_CHECK_KEY_EXISTS(key) |
return pointer(&p_e->m_value); |
} |
break; |
case erased_entry_status: |
break; |
default: |
_GLIBCXX_DEBUG_ASSERT(0); |
}; |
resize_base::notify_find_search_collision(); |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(key) |
resize_base::notify_find_search_end(); |
return 0; |
} |
inline bool |
erase_imp(key_const_reference, true_type); |
inline bool |
erase_imp(key_const_reference, false_type); |
inline void |
erase_entry(entry_pointer); |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
void |
inc_it_state(pointer& r_p_value, 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, size_type& r_pos) const |
{ |
_GLIBCXX_DEBUG_ASSERT(r_p_value != 0); |
for (++r_pos; r_pos < m_num_e; ++r_pos) |
{ |
const_entry_pointer p_e =& m_entries[r_pos]; |
if (p_e->m_stat == valid_entry_status) |
{ |
r_p_value =& p_e->m_value; |
return; |
} |
} |
r_p_value = 0; |
} |
void |
get_start_it_state(const_pointer& r_p_value, size_type& r_pos) const |
{ |
for (r_pos = 0; r_pos < m_num_e; ++r_pos) |
{ |
const_entry_pointer p_e = &m_entries[r_pos]; |
if (p_e->m_stat == valid_entry_status) |
{ |
r_p_value = &p_e->m_value; |
return; |
} |
} |
r_p_value = 0; |
} |
void |
get_start_it_state(pointer& r_p_value, size_type& r_pos) |
{ |
for (r_pos = 0; r_pos < m_num_e; ++r_pos) |
{ |
entry_pointer p_e = &m_entries[r_pos]; |
if (p_e->m_stat == valid_entry_status) |
{ |
r_p_value = &p_e->m_value; |
return; |
} |
} |
r_p_value = 0; |
} |
#ifdef _GLIBCXX_DEBUG |
void |
assert_entry_array_valid(const entry_array, false_type, |
const char*, int) const; |
void |
assert_entry_array_valid(const entry_array, true_type, |
const char*, int) const; |
#endif |
static entry_allocator s_entry_allocator; |
static iterator s_end_it; |
static const_iterator s_const_end_it; |
size_type m_num_e; |
size_type m_num_used_e; |
entry_pointer 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/gp_hash_table_map_/constructor_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_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_PROBE_FN_C_DEC |
#undef PB_DS_GP_HASH_TRAITS_BASE |
#undef PB_DS_DEBUG_MAP_BASE_C_DEC |
#undef PB_DS_GP_HASH_NAME |
} // namespace detail |
} // namespace __gnu_pbds |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp |
---|
0,0 → 1,58 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/info_fn_imps.hpp |
* Contains implementations of gp_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 s_entry_allocator.max_size(); } |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
empty() const |
{ return (size() == 0); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp |
---|
0,0 → 1,43 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/insert_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s insert related functions. |
*/ |
#include <ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp> |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,111 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/insert_no_store_hash_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s insert related functions, |
* when the hash value is not stored. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
find_ins_pos(key_const_reference r_key, false_type) |
{ |
size_type hash = ranged_probe_fn_base::operator()(r_key); |
size_type i; |
/* The insertion position is initted to a non-legal value to indicate |
* that it has not been initted yet. |
*/ |
size_type ins_pos = m_num_e; |
resize_base::notify_insert_search_start(); |
for (i = 0; i < m_num_e; ++i) |
{ |
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i); |
_GLIBCXX_DEBUG_ASSERT(pos < m_num_e); |
entry* const p_e = m_entries + pos; |
switch(p_e->m_stat) |
{ |
case empty_entry_status: |
{ |
resize_base::notify_insert_search_end(); |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return (ins_pos == m_num_e) ? pos : ins_pos; |
} |
break; |
case erased_entry_status: |
if (ins_pos == m_num_e) |
ins_pos = pos; |
break; |
case valid_entry_status: |
if (hash_eq_fn_base::operator()(PB_DS_V2F(p_e->m_value), r_key)) |
{ |
resize_base::notify_insert_search_end(); |
PB_DS_CHECK_KEY_EXISTS(r_key) |
return pos; |
} |
break; |
default: |
_GLIBCXX_DEBUG_ASSERT(0); |
}; |
resize_base::notify_insert_search_collision(); |
} |
resize_base::notify_insert_search_end(); |
if (ins_pos == m_num_e) |
__throw_insert_error(); |
return ins_pos; |
} |
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) |
{ |
key_const_reference r_key = PB_DS_V2F(r_val); |
const size_type pos = find_ins_pos(r_key, |
traits_base::m_store_extra_indicator); |
if (m_entries[pos].m_stat == valid_entry_status) |
{ |
PB_DS_CHECK_KEY_EXISTS(r_key) |
return std::make_pair(&(m_entries + pos)->m_value, false); |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return std::make_pair(insert_new_imp(r_val, pos), true); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp |
---|
0,0 → 1,118 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/insert_store_hash_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s find related functions, |
* when the hash value is stored. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::comp_hash |
PB_DS_CLASS_C_DEC:: |
find_ins_pos(key_const_reference r_key, true_type) |
{ |
PB_DS_ASSERT_VALID((*this)) |
comp_hash pos_hash_pair = ranged_probe_fn_base::operator()(r_key); |
size_type i; |
/* The insertion position is initted to a non-legal value to indicate |
* that it has not been initted yet. |
*/ |
size_type ins_pos = m_num_e; |
resize_base::notify_insert_search_start(); |
for (i = 0; i < m_num_e; ++i) |
{ |
const size_type pos = ranged_probe_fn_base::operator()(r_key, pos_hash_pair.second, i); |
entry* const p_e = m_entries + pos; |
switch(p_e->m_stat) |
{ |
case empty_entry_status: |
{ |
resize_base::notify_insert_search_end(); |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return ((ins_pos == m_num_e) ? |
std::make_pair(pos, pos_hash_pair.second) : |
std::make_pair(ins_pos, pos_hash_pair.second)); |
} |
break; |
case erased_entry_status: |
if (ins_pos == m_num_e) |
ins_pos = pos; |
break; |
case valid_entry_status: |
if (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_insert_search_end(); |
PB_DS_CHECK_KEY_EXISTS(r_key) |
return std::make_pair(pos, pos_hash_pair.second); |
} |
break; |
default: |
_GLIBCXX_DEBUG_ASSERT(0); |
}; |
resize_base::notify_insert_search_collision(); |
} |
resize_base::notify_insert_search_end(); |
if (ins_pos == m_num_e) |
__throw_insert_error(); |
return std::make_pair(ins_pos, pos_hash_pair.second); |
} |
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) |
{ |
key_const_reference r_key = PB_DS_V2F(r_val); |
comp_hash pos_hash_pair = find_ins_pos(r_key, |
traits_base::m_store_extra_indicator); |
_GLIBCXX_DEBUG_ASSERT(pos_hash_pair.first < m_num_e); |
entry_pointer p_e =& m_entries[pos_hash_pair.first]; |
if (p_e->m_stat == valid_entry_status) |
{ |
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_hash_pair), true); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp |
---|
0,0 → 1,83 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/iterator_fn_imps.hpp |
* Contains implementations of gp_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; |
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 |
{ |
const_pointer_ p_value; |
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; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp |
---|
0,0 → 1,100 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/policy_access_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s policy agpess |
* 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 |
Probe_Fn& |
PB_DS_CLASS_C_DEC:: |
get_probe_fn() |
{ return *this; } |
PB_DS_CLASS_T_DEC |
const Probe_Fn& |
PB_DS_CLASS_C_DEC:: |
get_probe_fn() const |
{ return *this; } |
PB_DS_CLASS_T_DEC |
Comb_Probe_Fn& |
PB_DS_CLASS_C_DEC:: |
get_comb_probe_fn() |
{ return *this; } |
PB_DS_CLASS_T_DEC |
const Comb_Probe_Fn& |
PB_DS_CLASS_C_DEC:: |
get_comb_probe_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; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp |
---|
0,0 → 1,139 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/resize_fn_imps.hpp |
* Contains implementations of gp_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 n) |
{ resize_imp(resize_base::get_nearest_larger_size(n)); } |
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) |
{ |
#ifdef PB_DS_REGRESSION |
typename _Alloc::group_adjustor adjust(m_num_e); |
#endif |
if (new_size == m_num_e) |
return; |
PB_DS_ASSERT_VALID((*this)) |
const size_type old_size = m_num_e; |
entry_array a_entries_resized = 0; |
// Following line might throw an exception. |
a_entries_resized = s_entry_allocator.allocate(new_size); |
ranged_probe_fn_base::notify_resized(new_size); |
m_num_e = new_size; |
for (size_type i = 0; i < m_num_e; ++i) |
a_entries_resized[i].m_stat = empty_entry_status; |
__try |
{ |
resize_imp(a_entries_resized, old_size); |
} |
__catch(...) |
{ |
erase_all_valid_entries(a_entries_resized, new_size); |
m_num_e = old_size; |
s_entry_allocator.deallocate(a_entries_resized, new_size); |
ranged_probe_fn_base::notify_resized(old_size); |
__throw_exception_again; |
} |
// At this point no exceptions can be thrown. |
_GLIBCXX_DEBUG_ONLY(assert_entry_array_valid(a_entries_resized, |
traits_base::m_store_extra_indicator, |
__FILE__, __LINE__);) |
Resize_Policy::notify_resized(new_size); |
erase_all_valid_entries(m_entries, old_size); |
s_entry_allocator.deallocate(m_entries, old_size); |
m_entries = a_entries_resized; |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
resize_imp(entry_array a_entries_resized, size_type old_size) |
{ |
for (size_type pos = 0; pos < old_size; ++pos) |
if (m_entries[pos].m_stat == valid_entry_status) |
resize_imp_reassign(m_entries + pos, a_entries_resized, |
traits_base::m_store_extra_indicator); |
} |
#include <ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp> |
#include <ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp> |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp |
---|
0,0 → 1,72 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/resize_no_store_hash_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s resize related functions, when the |
* hash value is not stored. |
*/ |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, |
false_type) |
{ |
key_const_reference r_key = PB_DS_V2F(p_e->m_value); |
size_type hash = ranged_probe_fn_base::operator()(r_key); |
size_type i; |
for (i = 0; i < m_num_e; ++i) |
{ |
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i); |
entry_pointer p_new_e = a_entries_resized + pos; |
switch(p_new_e->m_stat) |
{ |
case empty_entry_status: |
new (&p_new_e->m_value) value_type(p_e->m_value); |
p_new_e->m_stat = valid_entry_status; |
return; |
case erased_entry_status: |
_GLIBCXX_DEBUG_ASSERT(0); |
break; |
case valid_entry_status: |
break; |
default: |
_GLIBCXX_DEBUG_ASSERT(0); |
}; |
} |
__throw_insert_error(); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp |
---|
0,0 → 1,74 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/resize_store_hash_fn_imps.hpp |
* Contains implementations of gp_ht_map_'s resize related functions, when the |
* hash value is stored. |
*/ |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
resize_imp_reassign(entry_pointer p_e, entry_array a_entries_resized, |
true_type) |
{ |
key_const_reference r_key = PB_DS_V2F(p_e->m_value); |
size_type hash = ranged_probe_fn_base::operator()(r_key, p_e->m_hash); |
size_type i; |
for (i = 0; i < m_num_e; ++i) |
{ |
const size_type pos = ranged_probe_fn_base::operator()(r_key, hash, i); |
entry_pointer p_new_e = a_entries_resized + pos; |
switch(p_new_e->m_stat) |
{ |
case empty_entry_status: |
new (&p_new_e->m_value) value_type(p_e->m_value); |
p_new_e->m_hash = hash; |
p_new_e->m_stat = valid_entry_status; |
return; |
case erased_entry_status: |
_GLIBCXX_DEBUG_ASSERT(0); |
break; |
case valid_entry_status: |
break; |
default: |
_GLIBCXX_DEBUG_ASSERT(0); |
}; |
} |
__throw_insert_error(); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp |
---|
0,0 → 1,74 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_/trace_fn_imps.hpp |
* Contains implementations of gp_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) << " "; |
switch(m_entries[i].m_stat) |
{ |
case empty_entry_status: |
std::cerr << "<empty>"; |
break; |
case erased_entry_status: |
std::cerr << "<erased>"; |
break; |
case valid_entry_status: |
std::cerr << PB_DS_V2F(m_entries[i].m_value); |
break; |
default: |
_GLIBCXX_DEBUG_ASSERT(0); |
}; |
std::cerr << std::endl; |
} |
} |
#endif // #ifdef PB_DS_HT_MAP_TRACE_ |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp |
---|
0,0 → 1,58 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 direct_mask_range_hashing_imp.hpp |
* Contains a range-hashing policy implementation |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ mask_based_base::swap(other); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_resized(size_type size) |
{ mask_based_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
operator()(size_type hash) const |
{ return mask_based_base::range_hash(hash); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp |
---|
0,0 → 1,58 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 direct_mod_range_hashing_imp.hpp |
* Contains a range-hashing policy implementation |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ mod_based_base::swap(other); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_resized(size_type n) |
{ mod_based_base::notify_resized(n); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
operator()(size_type hash) const |
{ return mod_based_base::range_hash(hash); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp |
---|
0,0 → 1,53 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 linear_probe_fn_imp.hpp |
* Contains a probe policy implementation |
*/ |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
operator()(size_type i) const |
{ |
return (i); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp |
---|
0,0 → 1,101 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 mask_based_range_hashing.hpp |
* Contains a range hashing policy base. |
*/ |
#ifndef PB_DS_MASK_BASED_RANGE_HASHING_HPP |
#define PB_DS_MASK_BASED_RANGE_HASHING_HPP |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Range hashing policy. |
template<typename Size_Type> |
class mask_based_range_hashing |
{ |
protected: |
typedef Size_Type size_type; |
void |
swap(mask_based_range_hashing& other) |
{ std::swap(m_mask, other.m_mask); } |
void |
notify_resized(size_type size); |
inline size_type |
range_hash(size_type hash) const |
{ return size_type(hash & m_mask); } |
private: |
size_type m_mask; |
const static size_type s_num_bits_in_size_type; |
const static size_type s_highest_bit_1; |
}; |
template<typename Size_Type> |
const typename mask_based_range_hashing<Size_Type>::size_type |
mask_based_range_hashing<Size_Type>::s_num_bits_in_size_type = |
sizeof(typename mask_based_range_hashing<Size_Type>::size_type) << 3; |
template<typename Size_Type> |
const typename mask_based_range_hashing<Size_Type>::size_type mask_based_range_hashing<Size_Type>::s_highest_bit_1 = static_cast<typename mask_based_range_hashing<Size_Type>::size_type>(1) << (s_num_bits_in_size_type - 1); |
template<typename Size_Type> |
void |
mask_based_range_hashing<Size_Type>:: |
notify_resized(size_type size) |
{ |
size_type i = 0; |
while (size ^ s_highest_bit_1) |
{ |
size <<= 1; |
++i; |
} |
m_mask = 1; |
i += 2; |
while (i++ < s_num_bits_in_size_type) |
m_mask = (m_mask << 1) ^ 1; |
} |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp |
---|
0,0 → 1,74 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 mod_based_range_hashing.hpp |
* Contains a range hashing policy base. |
*/ |
#ifndef PB_DS_MOD_BASED_RANGE_HASHING_HPP |
#define PB_DS_MOD_BASED_RANGE_HASHING_HPP |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Mod based range hashing. |
template<typename Size_Type> |
class mod_based_range_hashing |
{ |
protected: |
typedef Size_Type size_type; |
void |
swap(mod_based_range_hashing& other) |
{ std::swap(m_size, other.m_size); } |
void |
notify_resized(size_type s) |
{ m_size = s; } |
inline size_type |
range_hash(size_type s) const |
{ return s % m_size; } |
private: |
size_type m_size; |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifndef PB_DS_MOD_BASED_RANGE_HASHING_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp |
---|
0,0 → 1,60 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 probe_fn_base.hpp |
* Contains a probe policy base. |
*/ |
#ifndef PB_DS_PROBE_FN_BASE_HPP |
#define PB_DS_PROBE_FN_BASE_HPP |
#include <functional> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Probe functor base. |
template<typename _Alloc> |
class probe_fn_base |
{ |
protected: |
~probe_fn_base() { } |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp |
---|
0,0 → 1,53 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 quadratic_probe_fn_imp.hpp |
* Contains a probe policy implementation |
*/ |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
operator()(size_type i) const |
{ |
return (i* i); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp |
---|
0,0 → 1,359 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ranged_hash_fn.hpp |
* Contains a unified ranged hash functor, allowing the hash tables |
* to deal with a single class for ranged hashing. |
*/ |
#ifndef PB_DS_RANGED_HASH_FN_HPP |
#define PB_DS_RANGED_HASH_FN_HPP |
#include <utility> |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Primary template. |
template<typename Key, typename Hash_Fn, typename _Alloc, |
typename Comb_Hash_Fn, bool Store_Hash> |
class ranged_hash_fn; |
#define PB_DS_CLASS_T_DEC \ |
template<typename Key, typename Hash_Fn, typename _Alloc, \ |
typename Comb_Hash_Fn> |
#define PB_DS_CLASS_C_DEC \ |
ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, false> |
/** |
* Specialization 1 |
* The client supplies a hash function and a ranged hash function, |
* and requests that hash values not be stored. |
**/ |
template<typename Key, typename Hash_Fn, typename _Alloc, |
typename Comb_Hash_Fn> |
class ranged_hash_fn< Key, Hash_Fn, _Alloc, Comb_Hash_Fn, false> |
: public Hash_Fn, public Comb_Hash_Fn |
{ |
protected: |
typedef typename _Alloc::size_type size_type; |
typedef Hash_Fn hash_fn_base; |
typedef Comb_Hash_Fn comb_hash_fn_base; |
typedef typename _Alloc::template rebind< Key>::other key_allocator; |
typedef typename key_allocator::const_reference key_const_reference; |
ranged_hash_fn(size_type); |
ranged_hash_fn(size_type, const Hash_Fn&); |
ranged_hash_fn(size_type, const Hash_Fn&, const Comb_Hash_Fn&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
void |
notify_resized(size_type); |
inline size_type |
operator()(key_const_reference) const; |
}; |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size) |
{ Comb_Hash_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) |
: Hash_Fn(r_hash_fn) |
{ Comb_Hash_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, |
const Comb_Hash_Fn& r_comb_hash_fn) |
: Hash_Fn(r_hash_fn), Comb_Hash_Fn(r_comb_hash_fn) |
{ comb_hash_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ |
comb_hash_fn_base::swap(other); |
std::swap((Hash_Fn& )(*this), (Hash_Fn& )other); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_resized(size_type size) |
{ comb_hash_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
operator()(key_const_reference r_key) const |
{ return (comb_hash_fn_base::operator()(hash_fn_base::operator()(r_key)));} |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC \ |
template<typename Key, typename Hash_Fn, typename _Alloc, \ |
typename Comb_Hash_Fn> |
#define PB_DS_CLASS_C_DEC \ |
ranged_hash_fn<Key,Hash_Fn, _Alloc, Comb_Hash_Fn, true> |
/** |
* Specialization 2 |
* The client supplies a hash function and a ranged hash function, |
* and requests that hash values be stored. |
**/ |
template<typename Key, typename Hash_Fn, typename _Alloc, |
typename Comb_Hash_Fn> |
class ranged_hash_fn<Key, Hash_Fn, _Alloc, Comb_Hash_Fn, true> |
: public Hash_Fn, public Comb_Hash_Fn |
{ |
protected: |
typedef typename _Alloc::size_type size_type; |
typedef std::pair<size_type, size_type> comp_hash; |
typedef Hash_Fn hash_fn_base; |
typedef Comb_Hash_Fn comb_hash_fn_base; |
typedef typename _Alloc::template rebind<Key>::other key_allocator; |
typedef typename key_allocator::const_reference key_const_reference; |
ranged_hash_fn(size_type); |
ranged_hash_fn(size_type, const Hash_Fn&); |
ranged_hash_fn(size_type, const Hash_Fn&, const Comb_Hash_Fn&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
void |
notify_resized(size_type); |
inline comp_hash |
operator()(key_const_reference) const; |
inline comp_hash |
operator()(key_const_reference, size_type) const; |
}; |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size) |
{ Comb_Hash_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn) : |
Hash_Fn(r_hash_fn) |
{ Comb_Hash_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size, const Hash_Fn& r_hash_fn, |
const Comb_Hash_Fn& r_comb_hash_fn) |
: Hash_Fn(r_hash_fn), Comb_Hash_Fn(r_comb_hash_fn) |
{ comb_hash_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ |
comb_hash_fn_base::swap(other); |
std::swap((Hash_Fn& )(*this), (Hash_Fn& )other); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_resized(size_type size) |
{ comb_hash_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::comp_hash |
PB_DS_CLASS_C_DEC:: |
operator()(key_const_reference r_key) const |
{ |
const size_type hash = hash_fn_base::operator()(r_key); |
return std::make_pair(comb_hash_fn_base::operator()(hash), hash); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::comp_hash |
PB_DS_CLASS_C_DEC:: |
operator() |
#ifdef _GLIBCXX_DEBUG |
(key_const_reference r_key, size_type hash) const |
#else |
(key_const_reference /*r_key*/, size_type hash) const |
#endif |
{ |
_GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key)); |
return std::make_pair(comb_hash_fn_base::operator()(hash), hash); |
} |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC \ |
template<typename Key, typename _Alloc, typename Comb_Hash_Fn> |
#define PB_DS_CLASS_C_DEC \ |
ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, false> |
/** |
* Specialization 3 |
* The client does not supply a hash function (by specifying |
* null_type as the Hash_Fn parameter), and requests that hash |
* values not be stored. |
**/ |
template<typename Key, typename _Alloc, typename Comb_Hash_Fn> |
class ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, false> |
: public Comb_Hash_Fn |
{ |
protected: |
typedef typename _Alloc::size_type size_type; |
typedef Comb_Hash_Fn comb_hash_fn_base; |
ranged_hash_fn(size_type); |
ranged_hash_fn(size_type, const Comb_Hash_Fn&); |
ranged_hash_fn(size_type, const null_type&, const Comb_Hash_Fn&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
}; |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size) |
{ Comb_Hash_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn) : |
Comb_Hash_Fn(r_comb_hash_fn) |
{ } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size, const null_type& r_null_type, |
const Comb_Hash_Fn& r_comb_hash_fn) |
: Comb_Hash_Fn(r_comb_hash_fn) |
{ } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ comb_hash_fn_base::swap(other); } |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC \ |
template<typename Key, typename _Alloc, typename Comb_Hash_Fn> |
#define PB_DS_CLASS_C_DEC \ |
ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, true> |
/** |
* Specialization 4 |
* The client does not supply a hash function (by specifying |
* null_type as the Hash_Fn parameter), and requests that hash |
* values be stored. |
**/ |
template<typename Key, typename _Alloc, typename Comb_Hash_Fn> |
class ranged_hash_fn<Key, null_type, _Alloc, Comb_Hash_Fn, true> |
: public Comb_Hash_Fn |
{ |
protected: |
typedef typename _Alloc::size_type size_type; |
typedef Comb_Hash_Fn comb_hash_fn_base; |
ranged_hash_fn(size_type); |
ranged_hash_fn(size_type, const Comb_Hash_Fn&); |
ranged_hash_fn(size_type, const null_type&, const Comb_Hash_Fn&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
}; |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size) |
{ Comb_Hash_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size, const Comb_Hash_Fn& r_comb_hash_fn) |
: Comb_Hash_Fn(r_comb_hash_fn) |
{ } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_hash_fn(size_type size, const null_type& r_null_type, |
const Comb_Hash_Fn& r_comb_hash_fn) |
: Comb_Hash_Fn(r_comb_hash_fn) |
{ } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ comb_hash_fn_base::swap(other); } |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp |
---|
0,0 → 1,327 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ranged_probe_fn.hpp |
* Contains a unified ranged probe functor, allowing the probe tables to deal with |
* a single class for ranged probeing. |
*/ |
#ifndef PB_DS_RANGED_PROBE_FN_HPP |
#define PB_DS_RANGED_PROBE_FN_HPP |
#include <utility> |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Primary template. |
template<typename Key, typename Hash_Fn, typename _Alloc, |
typename Comb_Probe_Fn, typename Probe_Fn, bool Store_Hash> |
class ranged_probe_fn; |
#define PB_DS_CLASS_T_DEC \ |
template<typename Key, typename Hash_Fn, typename _Alloc, \ |
typename Comb_Probe_Fn, typename Probe_Fn> |
#define PB_DS_CLASS_C_DEC \ |
ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, Probe_Fn, false> |
/** |
* Specialization 1 |
* The client supplies a probe function and a ranged probe |
* function, and requests that hash values not be stored. |
**/ |
template<typename Key, typename Hash_Fn, typename _Alloc, |
typename Comb_Probe_Fn, typename Probe_Fn> |
class ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, |
Probe_Fn, false> |
: public Hash_Fn, public Comb_Probe_Fn, public Probe_Fn |
{ |
protected: |
typedef typename _Alloc::size_type size_type; |
typedef Comb_Probe_Fn comb_probe_fn_base; |
typedef Hash_Fn hash_fn_base; |
typedef Probe_Fn probe_fn_base; |
typedef typename _Alloc::template rebind<Key>::other key_allocator; |
typedef typename key_allocator::const_reference key_const_reference; |
ranged_probe_fn(size_type); |
ranged_probe_fn(size_type, const Hash_Fn&); |
ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&); |
ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&, |
const Probe_Fn&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
void |
notify_resized(size_type); |
inline size_type |
operator()(key_const_reference) const; |
inline size_type |
operator()(key_const_reference, size_type, size_type) const; |
}; |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_probe_fn(size_type size) |
{ Comb_Probe_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn) |
: Hash_Fn(r_hash_fn) |
{ Comb_Probe_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, |
const Comb_Probe_Fn& r_comb_probe_fn) |
: Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn) |
{ comb_probe_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, |
const Comb_Probe_Fn& r_comb_probe_fn, |
const Probe_Fn& r_probe_fn) |
: Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn), Probe_Fn(r_probe_fn) |
{ comb_probe_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ |
comb_probe_fn_base::swap(other); |
std::swap((Hash_Fn& )(*this), (Hash_Fn&)other); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_resized(size_type size) |
{ comb_probe_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
operator()(key_const_reference r_key) const |
{ return comb_probe_fn_base::operator()(hash_fn_base::operator()(r_key)); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
operator()(key_const_reference, size_type hash, size_type i) const |
{ |
return comb_probe_fn_base::operator()(hash + probe_fn_base::operator()(i)); |
} |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC \ |
template<typename Key, typename Hash_Fn, typename _Alloc, \ |
typename Comb_Probe_Fn, typename Probe_Fn> |
#define PB_DS_CLASS_C_DEC \ |
ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, Probe_Fn, true> |
/** |
* Specialization 2- The client supplies a probe function and a ranged |
* probe function, and requests that hash values not be stored. |
**/ |
template<typename Key, typename Hash_Fn, typename _Alloc, |
typename Comb_Probe_Fn, typename Probe_Fn> |
class ranged_probe_fn<Key, Hash_Fn, _Alloc, Comb_Probe_Fn, |
Probe_Fn, true> |
: public Hash_Fn, public Comb_Probe_Fn, public Probe_Fn |
{ |
protected: |
typedef typename _Alloc::size_type size_type; |
typedef std::pair<size_type, size_type> comp_hash; |
typedef Comb_Probe_Fn comb_probe_fn_base; |
typedef Hash_Fn hash_fn_base; |
typedef Probe_Fn probe_fn_base; |
typedef typename _Alloc::template rebind<Key>::other key_allocator; |
typedef typename key_allocator::const_reference key_const_reference; |
ranged_probe_fn(size_type); |
ranged_probe_fn(size_type, const Hash_Fn&); |
ranged_probe_fn(size_type, const Hash_Fn&, |
const Comb_Probe_Fn&); |
ranged_probe_fn(size_type, const Hash_Fn&, const Comb_Probe_Fn&, |
const Probe_Fn&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
void |
notify_resized(size_type); |
inline comp_hash |
operator()(key_const_reference) const; |
inline size_type |
operator()(key_const_reference, size_type, size_type) const; |
inline size_type |
operator()(key_const_reference, size_type) const; |
}; |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_probe_fn(size_type size) |
{ Comb_Probe_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn) |
: Hash_Fn(r_hash_fn) |
{ Comb_Probe_Fn::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, |
const Comb_Probe_Fn& r_comb_probe_fn) |
: Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn) |
{ comb_probe_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
ranged_probe_fn(size_type size, const Hash_Fn& r_hash_fn, |
const Comb_Probe_Fn& r_comb_probe_fn, |
const Probe_Fn& r_probe_fn) |
: Hash_Fn(r_hash_fn), Comb_Probe_Fn(r_comb_probe_fn), Probe_Fn(r_probe_fn) |
{ comb_probe_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ |
comb_probe_fn_base::swap(other); |
std::swap((Hash_Fn& )(*this), (Hash_Fn& )other); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_resized(size_type size) |
{ comb_probe_fn_base::notify_resized(size); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::comp_hash |
PB_DS_CLASS_C_DEC:: |
operator()(key_const_reference r_key) const |
{ |
const size_type hash = hash_fn_base::operator()(r_key); |
return std::make_pair(comb_probe_fn_base::operator()(hash), hash); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
operator()(key_const_reference, size_type hash, size_type i) const |
{ |
return comb_probe_fn_base::operator()(hash + probe_fn_base::operator()(i)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
operator() |
#ifdef _GLIBCXX_DEBUG |
(key_const_reference r_key, size_type hash) const |
#else |
(key_const_reference /*r_key*/, size_type hash) const |
#endif |
{ |
_GLIBCXX_DEBUG_ASSERT(hash == hash_fn_base::operator()(r_key)); |
return hash; |
} |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
/** |
* Specialization 3 and 4 |
* The client does not supply a hash function or probe function, |
* and requests that hash values not be stored. |
**/ |
template<typename Key, typename _Alloc, typename Comb_Probe_Fn> |
class ranged_probe_fn<Key, null_type, _Alloc, Comb_Probe_Fn, |
null_type, false> |
: public Comb_Probe_Fn |
{ |
protected: |
typedef typename _Alloc::size_type size_type; |
typedef Comb_Probe_Fn comb_probe_fn_base; |
typedef typename _Alloc::template rebind<Key>::other key_allocator; |
typedef typename key_allocator::const_reference key_const_reference; |
ranged_probe_fn(size_type size) |
{ Comb_Probe_Fn::notify_resized(size); } |
ranged_probe_fn(size_type, const Comb_Probe_Fn& r_comb_probe_fn) |
: Comb_Probe_Fn(r_comb_probe_fn) |
{ } |
ranged_probe_fn(size_type, const null_type&, |
const Comb_Probe_Fn& r_comb_probe_fn, |
const null_type&) |
: Comb_Probe_Fn(r_comb_probe_fn) |
{ } |
void |
swap(ranged_probe_fn& other) |
{ comb_probe_fn_base::swap(other); } |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp |
---|
0,0 → 1,68 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 sample_probe_fn.hpp |
* Contains a sample probe policy. |
*/ |
#ifndef PB_DS_SAMPLE_PROBE_FN_HPP |
#define PB_DS_SAMPLE_PROBE_FN_HPP |
namespace __gnu_pbds |
{ |
/// A sample probe policy. |
class sample_probe_fn |
{ |
public: |
typedef std::size_t size_type; |
/// Default constructor. |
sample_probe_fn(); |
/// Copy constructor. |
sample_probe_fn(const sample_probe_fn&); |
/// Swaps content. |
inline void |
swap(sample_probe_fn&); |
protected: |
/// Returns the i-th offset from the hash value of some key r_key. |
inline size_type |
operator()(key_const_reference r_key, size_type i) const; |
}; |
} |
#endif // #ifndef PB_DS_SAMPLE_PROBE_FN_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp |
---|
0,0 → 1,74 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 sample_range_hashing.hpp |
* Contains a range hashing policy. |
*/ |
#ifndef PB_DS_SAMPLE_RANGE_HASHING_HPP |
#define PB_DS_SAMPLE_RANGE_HASHING_HPP |
namespace __gnu_pbds |
{ |
/// A sample range-hashing functor. |
class sample_range_hashing |
{ |
public: |
/// Size type. |
typedef std::size_t size_type; |
/// Default constructor. |
sample_range_hashing(); |
/// Copy constructor. |
sample_range_hashing(const sample_range_hashing& other); |
/// Swaps content. |
inline void |
swap(sample_range_hashing& other); |
protected: |
/// Notifies the policy object that the container's size has |
/// changed to argument's size. |
void |
notify_resized(size_type); |
/// Transforms the __hash value hash into a ranged-hash value. |
inline size_type |
operator()(size_type ) const; |
}; |
} |
#endif // #ifndef PB_DS_SAMPLE_RANGE_HASHING_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp |
---|
0,0 → 1,75 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 sample_ranged_hash_fn.hpp |
* Contains a ranged hash policy. |
*/ |
#ifndef PB_DS_SAMPLE_RANGED_HASH_FN_HPP |
#define PB_DS_SAMPLE_RANGED_HASH_FN_HPP |
namespace __gnu_pbds |
{ |
/// A sample ranged-hash functor. |
class sample_ranged_hash_fn |
{ |
public: |
typedef std::size_t size_type; |
/// Default constructor. |
sample_ranged_hash_fn(); |
/// Copy constructor. |
sample_ranged_hash_fn(const sample_ranged_hash_fn&); |
/// Swaps content. |
inline void |
swap(sample_ranged_hash_fn&); |
protected: |
/// Notifies the policy object that the container's __size has |
/// changed to size. |
void |
notify_resized(size_type); |
/// Transforms key_const_reference into a position within the table. |
inline size_type |
operator()(key_const_reference) const; |
}; |
} |
#endif // #ifndef PB_DS_SAMPLE_RANGED_HASH_FN_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp |
---|
0,0 → 1,77 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 sample_ranged_probe_fn.hpp |
* Contains a ranged probe policy. |
*/ |
#ifndef PB_DS_SAMPLE_RANGED_PROBE_FN_HPP |
#define PB_DS_SAMPLE_RANGED_PROBE_FN_HPP |
namespace __gnu_pbds |
{ |
/// A sample ranged-probe functor. |
class sample_ranged_probe_fn |
{ |
public: |
typedef std::size_t size_type; |
// Default constructor. |
sample_ranged_probe_fn(); |
// Copy constructor. |
sample_ranged_probe_fn(const sample_ranged_probe_fn&); |
// Swaps content. |
inline void |
swap(sample_ranged_probe_fn&); |
protected: |
// Notifies the policy object that the container's __size has |
// changed to size. |
void |
notify_resized(size_type); |
// Transforms the const key reference r_key into the i-th position |
// within the table. This method is called for each collision within |
// the probe sequence. |
inline size_type |
operator()(key_const_reference, std::size_t, size_type) const; |
}; |
} |
#endif // #ifndef PB_DS_SAMPLE_RANGED_PROBE_FN_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp |
---|
0,0 → 1,159 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/const_iterator.hpp |
* Contains an iterator class returned by the table's const find and insert |
* methods. |
*/ |
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP |
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_ITERATOR_HPP |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp> |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#define PB_DS_CLASS_C_DEC \ |
left_child_next_sibling_heap_const_iterator_<Node, _Alloc> |
#define PB_DS_BASIC_HEAP_CIT_BASE \ |
left_child_next_sibling_heap_node_point_const_iterator_<Node, _Alloc> |
/// Const point-type iterator. |
template<typename Node, typename _Alloc> |
class left_child_next_sibling_heap_const_iterator_ |
: public PB_DS_BASIC_HEAP_CIT_BASE |
{ |
private: |
typedef PB_DS_BASIC_HEAP_CIT_BASE base_type; |
typedef typename base_type::node_pointer node_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 |
left_child_next_sibling_heap_const_iterator_(node_pointer p_nd) |
: base_type(p_nd) |
{ } |
/// Default constructor. |
inline |
left_child_next_sibling_heap_const_iterator_() |
{ } |
/// Copy constructor. |
inline |
left_child_next_sibling_heap_const_iterator_(const PB_DS_CLASS_C_DEC& other) : base_type(other) |
{ } |
/// Compares content to a different iterator object. |
bool |
operator==(const PB_DS_CLASS_C_DEC& other) const |
{ return (base_type::m_p_nd == other.m_p_nd); } |
/// Compares content (negatively) to a different iterator object. |
bool |
operator!=(const PB_DS_CLASS_C_DEC& other) const |
{ return (base_type::m_p_nd != other.m_p_nd); } |
PB_DS_CLASS_C_DEC& |
operator++() |
{ |
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd != 0); |
inc(); |
return (*this); |
} |
PB_DS_CLASS_C_DEC |
operator++(int) |
{ |
PB_DS_CLASS_C_DEC ret_it(base_type::m_p_nd); |
operator++(); |
return (ret_it); |
} |
private: |
void |
inc() |
{ |
if (base_type::m_p_nd->m_p_next_sibling != 0) |
{ |
base_type::m_p_nd = base_type::m_p_nd->m_p_next_sibling; |
while (base_type::m_p_nd->m_p_l_child != 0) |
base_type::m_p_nd = base_type::m_p_nd->m_p_l_child; |
return; |
} |
while (true) |
{ |
node_pointer p_next = base_type::m_p_nd; |
base_type::m_p_nd = base_type::m_p_nd->m_p_prev_or_parent; |
if (base_type::m_p_nd == 0 |
|| base_type::m_p_nd->m_p_l_child == p_next) |
return; |
} |
} |
}; |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_BASIC_HEAP_CIT_BASE |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,152 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp |
* Contains an implementation class for left_child_next_sibling_heap_. |
*/ |
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 |
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 |
PB_DS_CLASS_C_DEC:: |
left_child_next_sibling_heap() : |
m_p_root(0), |
m_size(0) |
{ |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
left_child_next_sibling_heap(const Cmp_Fn& r_cmp_fn) : |
Cmp_Fn(r_cmp_fn), |
m_p_root(0), |
m_size(0) |
{ |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
left_child_next_sibling_heap(const PB_DS_CLASS_C_DEC& other) |
: Cmp_Fn(other), m_p_root(0), m_size(0) |
{ |
m_size = other.m_size; |
PB_DS_ASSERT_VALID(other) |
m_p_root = recursive_copy_node(other.m_p_root); |
m_size = other.m_size; |
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) |
value_swap(other); |
std::swap((Cmp_Fn& )(*this), (Cmp_Fn& )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_p_root, other.m_p_root); |
std::swap(m_size, other.m_size); |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
~left_child_next_sibling_heap() |
{ |
clear(); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
recursive_copy_node(node_const_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_l_child = p_ret->m_p_next_sibling = |
p_ret->m_p_prev_or_parent = 0; |
__try |
{ |
p_ret->m_p_l_child = recursive_copy_node(p_nd->m_p_l_child); |
p_ret->m_p_next_sibling = recursive_copy_node(p_nd->m_p_next_sibling); |
} |
__catch(...) |
{ |
clear_imp(p_ret); |
__throw_exception_again; |
} |
if (p_ret->m_p_l_child != 0) |
p_ret->m_p_l_child->m_p_prev_or_parent = p_ret; |
if (p_ret->m_p_next_sibling != 0) |
p_ret->m_p_next_sibling->m_p_prev_or_parent = |
p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd ? p_ret : 0; |
return p_ret; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp |
---|
0,0 → 1,137 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/debug_fn_imps.hpp |
* Contains an implementation class for left_child_next_sibling_heap_. |
*/ |
#ifdef _GLIBCXX_DEBUG |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_valid(const char* __file, int __line) const |
{ |
PB_DS_DEBUG_VERIFY(m_p_root == 0 || m_p_root->m_p_prev_or_parent == 0); |
if (m_p_root != 0) |
assert_node_consistent(m_p_root, Single_Link_Roots, __file, __line); |
assert_size(__file, __line); |
assert_iterators(__file, __line); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_node_consistent(node_const_pointer p_nd, bool single_link, |
const char* __file, int __line) const |
{ |
if (p_nd == 0) |
return; |
assert_node_consistent(p_nd->m_p_l_child, false, __file, __line); |
assert_node_consistent(p_nd->m_p_next_sibling, single_link, __file, __line); |
if (single_link) |
PB_DS_DEBUG_VERIFY(p_nd->m_p_prev_or_parent == 0); |
else if (p_nd->m_p_next_sibling != 0) |
PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling->m_p_prev_or_parent == p_nd); |
if (p_nd->m_p_l_child == 0) |
return; |
node_const_pointer p_child = p_nd->m_p_l_child; |
while (p_child != 0) |
{ |
node_const_pointer p_next_child = p_child->m_p_next_sibling; |
PB_DS_DEBUG_VERIFY(!Cmp_Fn::operator()(p_nd->m_value, p_child->m_value)); |
p_child = p_next_child; |
} |
PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_p_prev_or_parent == p_nd); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_iterators(const char* __file, int __line) const |
{ |
PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) == size()); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_size(const char* __file, int __line) const |
{ |
PB_DS_DEBUG_VERIFY(size_from_node(m_p_root) == m_size); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
size_under_node(node_const_pointer p_nd) |
{ return 1 + size_from_node(p_nd->m_p_l_child); } |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
size_from_node(node_const_pointer p_nd) |
{ |
size_type ret = 0; |
while (p_nd != 0) |
{ |
ret += 1 + size_from_node(p_nd->m_p_l_child); |
p_nd = p_nd->m_p_next_sibling; |
} |
return ret; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
degree(node_const_pointer p_nd) |
{ |
size_type ret = 0; |
node_const_pointer p_child = p_nd->m_p_l_child; |
while (p_child != 0) |
{ |
++ret; |
p_child = p_child->m_p_next_sibling; |
} |
return ret; |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp |
---|
0,0 → 1,150 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/erase_fn_imps.hpp |
* Contains an implementation class for left_child_next_sibling_heap_. |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
clear() |
{ |
clear_imp(m_p_root); |
_GLIBCXX_DEBUG_ASSERT(m_size == 0); |
m_p_root = 0; |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
actual_erase_node(node_pointer p_nd) |
{ |
_GLIBCXX_DEBUG_ASSERT(m_size > 0); |
--m_size; |
p_nd->~node(); |
s_node_allocator.deallocate(p_nd, 1); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
clear_imp(node_pointer p_nd) |
{ |
while (p_nd != 0) |
{ |
clear_imp(p_nd->m_p_l_child); |
node_pointer p_next = p_nd->m_p_next_sibling; |
actual_erase_node(p_nd); |
p_nd = p_next; |
} |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
to_linked_list() |
{ |
PB_DS_ASSERT_VALID((*this)) |
node_pointer p_cur = m_p_root; |
while (p_cur != 0) |
if (p_cur->m_p_l_child != 0) |
{ |
node_pointer p_child_next = p_cur->m_p_l_child->m_p_next_sibling; |
p_cur->m_p_l_child->m_p_next_sibling = p_cur->m_p_next_sibling; |
p_cur->m_p_next_sibling = p_cur->m_p_l_child; |
p_cur->m_p_l_child = p_child_next; |
} |
else |
p_cur = p_cur->m_p_next_sibling; |
#ifdef _GLIBCXX_DEBUG |
node_const_pointer p_counter = m_p_root; |
size_type count = 0; |
while (p_counter != 0) |
{ |
++count; |
_GLIBCXX_DEBUG_ASSERT(p_counter->m_p_l_child == 0); |
p_counter = p_counter->m_p_next_sibling; |
} |
_GLIBCXX_DEBUG_ASSERT(count == m_size); |
#endif |
} |
PB_DS_CLASS_T_DEC |
template<typename Pred> |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
prune(Pred pred) |
{ |
node_pointer p_cur = m_p_root; |
m_p_root = 0; |
node_pointer p_out = 0; |
while (p_cur != 0) |
{ |
node_pointer p_next = p_cur->m_p_next_sibling; |
if (pred(p_cur->m_value)) |
{ |
p_cur->m_p_next_sibling = p_out; |
if (p_out != 0) |
p_out->m_p_prev_or_parent = p_cur; |
p_out = p_cur; |
} |
else |
{ |
p_cur->m_p_next_sibling = m_p_root; |
if (m_p_root != 0) |
m_p_root->m_p_prev_or_parent = p_cur; |
m_p_root = p_cur; |
} |
p_cur = p_next; |
} |
return p_out; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
bubble_to_top(node_pointer p_nd) |
{ |
node_pointer p_parent = parent(p_nd); |
while (p_parent != 0) |
{ |
swap_with_parent(p_nd, p_parent); |
p_parent = parent(p_nd); |
} |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp |
---|
0,0 → 1,64 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/info_fn_imps.hpp |
* Contains an implementation class for left_child_next_sibling_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_node_allocator.max_size()); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp |
---|
0,0 → 1,175 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/insert_fn_imps.hpp |
* Contains an implementation class for left_child_next_sibling_heap_. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
get_new_node_for_insert(const_reference r_val) |
{ |
return get_new_node_for_insert(r_val, s_no_throw_copies_ind); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
get_new_node_for_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(); |
++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_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); |
++m_size; |
return (p_new_nd); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
make_child_of(node_pointer p_nd, node_pointer p_new_parent) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
_GLIBCXX_DEBUG_ASSERT(p_new_parent != 0); |
p_nd->m_p_next_sibling = p_new_parent->m_p_l_child; |
if (p_new_parent->m_p_l_child != 0) |
p_new_parent->m_p_l_child->m_p_prev_or_parent = p_nd; |
p_nd->m_p_prev_or_parent = p_new_parent; |
p_new_parent->m_p_l_child = p_nd; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
parent(node_pointer p_nd) |
{ |
while (true) |
{ |
node_pointer p_pot = p_nd->m_p_prev_or_parent; |
if (p_pot == 0 || p_pot->m_p_l_child == p_nd) |
return p_pot; |
p_nd = p_pot; |
} |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
swap_with_parent(node_pointer p_nd, node_pointer p_parent) |
{ |
if (p_parent == m_p_root) |
m_p_root = p_nd; |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
_GLIBCXX_DEBUG_ASSERT(p_parent != 0); |
_GLIBCXX_DEBUG_ASSERT(parent(p_nd) == p_parent); |
const bool nd_direct_child = p_parent->m_p_l_child == p_nd; |
const bool parent_root = p_parent->m_p_prev_or_parent == 0; |
const bool parent_direct_child = |
!parent_root&& p_parent->m_p_prev_or_parent->m_p_l_child == p_parent; |
std::swap(p_parent->m_p_prev_or_parent, p_nd->m_p_prev_or_parent); |
std::swap(p_parent->m_p_next_sibling, p_nd->m_p_next_sibling); |
std::swap(p_parent->m_p_l_child, p_nd->m_p_l_child); |
std::swap(p_parent->m_metadata, p_nd->m_metadata); |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child != 0); |
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent != 0); |
if (p_nd->m_p_next_sibling != 0) |
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_nd; |
if (p_parent->m_p_next_sibling != 0) |
p_parent->m_p_next_sibling->m_p_prev_or_parent = p_parent; |
if (p_parent->m_p_l_child != 0) |
p_parent->m_p_l_child->m_p_prev_or_parent = p_parent; |
if (parent_direct_child) |
p_nd->m_p_prev_or_parent->m_p_l_child = p_nd; |
else if (!parent_root) |
p_nd->m_p_prev_or_parent->m_p_next_sibling = p_nd; |
if (!nd_direct_child) |
{ |
p_nd->m_p_l_child->m_p_prev_or_parent = p_nd; |
p_parent->m_p_prev_or_parent->m_p_next_sibling = p_parent; |
} |
else |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_l_child == p_nd); |
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_prev_or_parent == p_parent); |
p_nd->m_p_l_child = p_parent; |
p_parent->m_p_prev_or_parent = p_nd; |
} |
_GLIBCXX_DEBUG_ASSERT(parent(p_parent) == p_nd); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp |
---|
0,0 → 1,88 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/iterators_fn_imps.hpp |
* Contains an implementation class for left_child_next_sibling_heap_. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
begin() |
{ |
node_pointer p_nd = m_p_root; |
if (p_nd == 0) |
return (iterator(0)); |
while (p_nd->m_p_l_child != 0) |
p_nd = p_nd->m_p_l_child; |
return (iterator(p_nd)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
begin() const |
{ |
node_pointer p_nd = m_p_root; |
if (p_nd == 0) |
return (const_iterator(0)); |
while (p_nd->m_p_l_child != 0) |
p_nd = p_nd->m_p_l_child; |
return (const_iterator(p_nd)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
end() |
{ |
return (iterator(0)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
end() const |
{ |
return (const_iterator(0)); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp |
---|
0,0 → 1,286 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp |
* Contains an implementation class for a basic heap. |
*/ |
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_HPP |
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_HPP |
/* |
* Based on CLRS. |
*/ |
#include <iterator> |
#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_/node.hpp> |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp> |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp> |
#ifdef PB_DS_LC_NS_HEAP_TRACE_ |
#include <iostream> |
#endif |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#ifdef _GLIBCXX_DEBUG |
#define PB_DS_CLASS_T_DEC \ |
template<typename Value_Type, typename Cmp_Fn, typename Node_Metadata, \ |
typename _Alloc, bool Single_Link_Roots> |
#define PB_DS_CLASS_C_DEC \ |
left_child_next_sibling_heap<Value_Type, Cmp_Fn, Node_Metadata, \ |
_Alloc, Single_Link_Roots> |
#else |
#define PB_DS_CLASS_T_DEC \ |
template<typename Value_Type, typename Cmp_Fn, typename Node_Metadata, \ |
typename _Alloc> |
#define PB_DS_CLASS_C_DEC \ |
left_child_next_sibling_heap<Value_Type, Cmp_Fn, Node_Metadata, _Alloc> |
#endif |
/// Base class for a basic heap. |
template<typename Value_Type, |
typename Cmp_Fn, |
typename Node_Metadata, |
typename _Alloc |
#ifdef _GLIBCXX_DEBUG |
,bool Single_Link_Roots> |
#else |
> |
#endif |
class left_child_next_sibling_heap : public Cmp_Fn |
{ |
protected: |
typedef |
typename _Alloc::template rebind< |
left_child_next_sibling_heap_node_<Value_Type, Node_Metadata, |
_Alloc> >::other |
node_allocator; |
typedef typename node_allocator::value_type node; |
typedef typename node_allocator::pointer node_pointer; |
typedef typename node_allocator::const_pointer node_const_pointer; |
typedef Node_Metadata node_metadata; |
typedef std::pair< node_pointer, node_pointer> node_pointer_pair; |
private: |
typedef cond_dealtor< node, _Alloc> cond_dealtor_t; |
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; |
public: |
typedef typename _Alloc::size_type size_type; |
typedef typename _Alloc::difference_type difference_type; |
typedef Value_Type value_type; |
typedef typename __rebind_v::other::pointer pointer; |
typedef typename __rebind_v::other::const_pointer const_pointer; |
typedef typename __rebind_v::other::reference reference; |
typedef typename __rebind_v::other::const_reference const_reference; |
typedef left_child_next_sibling_heap_node_point_const_iterator_<node, _Alloc> |
point_const_iterator; |
typedef point_const_iterator point_iterator; |
typedef left_child_next_sibling_heap_const_iterator_<node, _Alloc> |
const_iterator; |
typedef const_iterator iterator; |
typedef Cmp_Fn cmp_fn; |
typedef _Alloc allocator_type; |
left_child_next_sibling_heap(); |
left_child_next_sibling_heap(const Cmp_Fn&); |
left_child_next_sibling_heap(const left_child_next_sibling_heap&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
~left_child_next_sibling_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 iterator |
begin(); |
inline const_iterator |
begin() const; |
inline iterator |
end(); |
inline const_iterator |
end() const; |
void |
clear(); |
#ifdef PB_DS_LC_NS_HEAP_TRACE_ |
void |
trace() const; |
#endif |
protected: |
inline node_pointer |
get_new_node_for_insert(const_reference); |
inline static void |
make_child_of(node_pointer, node_pointer); |
void |
value_swap(left_child_next_sibling_heap&); |
inline static node_pointer |
parent(node_pointer); |
inline void |
swap_with_parent(node_pointer, node_pointer); |
void |
bubble_to_top(node_pointer); |
inline void |
actual_erase_node(node_pointer); |
void |
clear_imp(node_pointer); |
void |
to_linked_list(); |
template<typename Pred> |
node_pointer |
prune(Pred); |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char*, int) const; |
void |
assert_node_consistent(node_const_pointer, bool, const char*, int) const; |
static size_type |
size_under_node(node_const_pointer); |
static size_type |
degree(node_const_pointer); |
#endif |
#ifdef PB_DS_LC_NS_HEAP_TRACE_ |
static void |
trace_node(node_const_pointer, size_type); |
#endif |
private: |
#ifdef _GLIBCXX_DEBUG |
void |
assert_iterators(const char*, int) const; |
void |
assert_size(const char*, int) const; |
static size_type |
size_from_node(node_const_pointer); |
#endif |
node_pointer |
recursive_copy_node(node_const_pointer); |
inline node_pointer |
get_new_node_for_insert(const_reference, false_type); |
inline node_pointer |
get_new_node_for_insert(const_reference, true_type); |
#ifdef PB_DS_LC_NS_HEAP_TRACE_ |
template<typename Metadata_> |
static void |
trace_node_metadata(node_const_pointer, type_to_type<Metadata_>); |
static void |
trace_node_metadata(node_const_pointer, type_to_type<null_type>); |
#endif |
static node_allocator s_node_allocator; |
static no_throw_copies_t s_no_throw_copies_ind; |
protected: |
node_pointer m_p_root; |
size_type m_size; |
}; |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp> |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp> |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp> |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp> |
#include <ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp> |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_CLASS_T_DEC |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp |
---|
0,0 → 1,90 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/node.hpp |
* Contains an implementation struct for this type of heap's node. |
*/ |
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP |
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Node. |
template<typename _Value, typename _Metadata, typename _Alloc> |
struct left_child_next_sibling_heap_node_ |
{ |
private: |
typedef left_child_next_sibling_heap_node_<_Value, _Metadata, _Alloc> this_type; |
public: |
typedef _Value value_type; |
typedef typename _Alloc::size_type size_type; |
typedef _Metadata metadata_type; |
typedef typename _Alloc::template rebind<this_type>::other::pointer node_pointer; |
value_type m_value; |
metadata_type m_metadata; |
node_pointer m_p_l_child; |
node_pointer m_p_next_sibling; |
node_pointer m_p_prev_or_parent; |
}; |
template<typename _Value, typename _Alloc> |
struct left_child_next_sibling_heap_node_<_Value, null_type, _Alloc> |
{ |
private: |
typedef left_child_next_sibling_heap_node_<_Value, null_type, _Alloc> this_type; |
public: |
typedef _Value value_type; |
typedef typename _Alloc::size_type size_type; |
typedef typename _Alloc::template rebind<this_type>::other::pointer node_pointer; |
value_type m_value; |
node_pointer m_p_l_child; |
node_pointer m_p_next_sibling; |
node_pointer m_p_prev_or_parent; |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp |
---|
0,0 → 1,149 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/point_const_iterator.hpp |
* Contains an iterator class returned by the table's const find and insert |
* methods. |
*/ |
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP |
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_CONST_FIND_ITERATOR_HPP |
#include <ext/pb_ds/tag_and_trait.hpp> |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#define PB_DS_CLASS_T_DEC \ |
template<typename Node, typename _Alloc> |
#define PB_DS_CLASS_C_DEC \ |
left_child_next_sibling_heap_node_point_const_iterator_<Node, _Alloc> |
/// Const point-type iterator. |
template<typename Node, typename _Alloc> |
class left_child_next_sibling_heap_node_point_const_iterator_ |
{ |
protected: |
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 typename Node::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 |
left_child_next_sibling_heap_node_point_const_iterator_(node_pointer p_nd) : m_p_nd(p_nd) |
{ } |
/// Default constructor. |
inline |
left_child_next_sibling_heap_node_point_const_iterator_() : m_p_nd(0) |
{ } |
/// Copy constructor. |
inline |
left_child_next_sibling_heap_node_point_const_iterator_(const PB_DS_CLASS_C_DEC& other) : m_p_nd(other.m_p_nd) |
{ } |
/// Access. |
const_pointer |
operator->() const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0); |
return &m_p_nd->m_value; |
} |
/// Access. |
const_reference |
operator*() const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_nd != 0); |
return m_p_nd->m_value; |
} |
/// Compares content to a different iterator object. |
bool |
operator==(const PB_DS_CLASS_C_DEC& other) const |
{ return m_p_nd == other.m_p_nd; } |
/// Compares content (negatively) to a different iterator object. |
bool |
operator!=(const PB_DS_CLASS_C_DEC& other) const |
{ return m_p_nd != other.m_p_nd; } |
node_pointer m_p_nd; |
}; |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp |
---|
0,0 → 1,52 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/policy_access_fn_imps.hpp |
* Contains an implementation class for left_child_next_sibling_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; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp |
---|
0,0 → 1,90 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 left_child_next_sibling_heap_/trace_fn_imps.hpp |
* Contains an implementation class for left_child_next_sibling_heap_. |
*/ |
#ifdef PB_DS_LC_NS_HEAP_TRACE_ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace() const |
{ |
std::cerr << std::endl; |
trace_node(m_p_root, 0); |
std::cerr << std::endl; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace_node(node_const_pointer p_nd, size_type level) |
{ |
while (p_nd != 0) |
{ |
for (size_type i = 0; i < level; ++i) |
std::cerr << ' '; |
std::cerr << p_nd << |
" prev = " << p_nd->m_p_prev_or_parent << |
" next " << p_nd->m_p_next_sibling << |
" left = " << p_nd->m_p_l_child << " "; |
trace_node_metadata(p_nd, type_to_type<node_metadata>()); |
std::cerr << p_nd->m_value << std::endl; |
trace_node(p_nd->m_p_l_child, level + 1); |
p_nd = p_nd->m_p_next_sibling; |
} |
} |
PB_DS_CLASS_T_DEC |
template<typename Metadata_> |
void |
PB_DS_CLASS_C_DEC:: |
trace_node_metadata(node_const_pointer p_nd, type_to_type<Metadata_>) |
{ |
std::cerr << "(" << p_nd->m_metadata << ") "; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace_node_metadata(node_const_pointer, type_to_type<null_type>) |
{ } |
#endif // #ifdef PB_DS_LC_NS_HEAP_TRACE_ |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp |
---|
0,0 → 1,136 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_map_/constructor_destructor_fn_imps.hpp |
*/ |
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 |
Eq_Fn PB_DS_CLASS_C_DEC::s_eq_fn; |
PB_DS_CLASS_T_DEC |
null_type PB_DS_CLASS_C_DEC::s_null_type; |
PB_DS_CLASS_T_DEC |
Update_Policy PB_DS_CLASS_C_DEC::s_update_policy; |
PB_DS_CLASS_T_DEC |
type_to_type< |
typename PB_DS_CLASS_C_DEC::update_metadata> PB_DS_CLASS_C_DEC::s_metadata_type_indicator; |
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_LU_NAME() : m_p_l(0) |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
template<typename It> |
PB_DS_CLASS_C_DEC:: |
PB_DS_LU_NAME(It first_it, It last_it) : m_p_l(0) |
{ |
copy_from_range(first_it, last_it); |
PB_DS_ASSERT_VALID((*this)); |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC& other) : |
m_p_l(0) |
{ |
__try |
{ |
for (const_iterator it = other.begin(); it != other.end(); ++it) |
{ |
entry_pointer p_l = allocate_new_entry(*it, |
traits_base::m_no_throw_copies_indicator); |
p_l->m_p_next = m_p_l; |
m_p_l = p_l; |
} |
} |
__catch(...) |
{ |
deallocate_all(); |
__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_ONLY(debug_base::swap(other);) |
std::swap(m_p_l, other.m_p_l); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
deallocate_all() |
{ |
entry_pointer p_l = m_p_l; |
while (p_l != 0) |
{ |
entry_pointer p_next_l = p_l->m_p_next; |
actual_erase_entry(p_l); |
p_l = p_next_l; |
} |
m_p_l = 0; |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
~PB_DS_LU_NAME() |
{ deallocate_all(); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp |
---|
0,0 → 1,57 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_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 |
{ |
size_type calc_size = 0; |
for (const_iterator it = begin(); it != end(); ++it) |
{ |
debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); |
++calc_size; |
} |
debug_base::check_size(calc_size, __file, __line); |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp |
---|
0,0 → 1,60 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_map_/entry_metadata_base.hpp |
* Contains an implementation for a list update map. |
*/ |
#ifndef PB_DS_LU_MAP_ENTRY_METADATA_BASE_HPP |
#define PB_DS_LU_MAP_ENTRY_METADATA_BASE_HPP |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
template<typename Metadata> |
struct lu_map_entry_metadata_base |
{ |
Metadata m_update_metadata; |
}; |
template<> |
struct lu_map_entry_metadata_base<null_type> |
{ }; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp |
---|
0,0 → 1,134 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_map_/erase_fn_imps.hpp |
* Contains implementations of lu_map_. |
*/ |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
erase(key_const_reference r_key) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (m_p_l == 0) |
return false; |
if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value))) |
{ |
entry_pointer p_next = m_p_l->m_p_next; |
actual_erase_entry(m_p_l); |
m_p_l = p_next; |
return true; |
} |
entry_pointer p_l = m_p_l; |
while (p_l->m_p_next != 0) |
if (s_eq_fn(r_key, PB_DS_V2F(p_l->m_p_next->m_value))) |
{ |
erase_next(p_l); |
return true; |
} |
else |
p_l = p_l->m_p_next; |
return false; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
clear() |
{ |
deallocate_all(); |
} |
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) |
{ |
PB_DS_ASSERT_VALID((*this)) |
size_type num_ersd = 0; |
while (m_p_l != 0 && pred(m_p_l->m_value)) |
{ |
entry_pointer p_next = m_p_l->m_p_next; |
++num_ersd; |
actual_erase_entry(m_p_l); |
m_p_l = p_next; |
} |
if (m_p_l == 0) |
return num_ersd; |
entry_pointer p_l = m_p_l; |
while (p_l->m_p_next != 0) |
{ |
if (pred(p_l->m_p_next->m_value)) |
{ |
++num_ersd; |
erase_next(p_l); |
} |
else |
p_l = p_l->m_p_next; |
} |
PB_DS_ASSERT_VALID((*this)) |
return num_ersd; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
erase_next(entry_pointer p_l) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_l != 0); |
_GLIBCXX_DEBUG_ASSERT(p_l->m_p_next != 0); |
entry_pointer p_next_l = p_l->m_p_next->m_p_next; |
actual_erase_entry(p_l->m_p_next); |
p_l->m_p_next = p_next_l; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
actual_erase_entry(entry_pointer p_l) |
{ |
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->m_value));) |
p_l->~entry(); |
s_entry_allocator.deallocate(p_l, 1); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp |
---|
0,0 → 1,90 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_map_/find_fn_imps.hpp |
* Contains implementations of lu_map_. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::entry_pointer |
PB_DS_CLASS_C_DEC:: |
find_imp(key_const_reference r_key) const |
{ |
if (m_p_l == 0) |
return 0; |
if (s_eq_fn(r_key, PB_DS_V2F(m_p_l->m_value))) |
{ |
apply_update(m_p_l, s_metadata_type_indicator); |
PB_DS_CHECK_KEY_EXISTS(r_key) |
return m_p_l; |
} |
entry_pointer p_l = m_p_l; |
while (p_l->m_p_next != 0) |
{ |
entry_pointer p_next = p_l->m_p_next; |
if (s_eq_fn(r_key, PB_DS_V2F(p_next->m_value))) |
{ |
if (apply_update(p_next, s_metadata_type_indicator)) |
{ |
p_l->m_p_next = p_next->m_p_next; |
p_next->m_p_next = m_p_l; |
m_p_l = p_next; |
return m_p_l; |
} |
return p_next; |
} |
else |
p_l = p_next; |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return 0; |
} |
PB_DS_CLASS_T_DEC |
template<typename Metadata> |
inline bool |
PB_DS_CLASS_C_DEC:: |
apply_update(entry_pointer p_l, type_to_type<Metadata>) |
{ return s_update_policy(p_l->m_update_metadata); } |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
apply_update(entry_pointer, type_to_type<null_type>) |
{ return s_update_policy(s_null_type); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp |
---|
0,0 → 1,57 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_map_/info_fn_imps.hpp |
* Contains implementations of lu_map_. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
size() const |
{ return std::distance(begin(), end()); } |
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(); } |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
empty() const |
{ return (m_p_l == 0); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp |
---|
0,0 → 1,106 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_map_/insert_fn_imps.hpp |
* Contains implementations of lu_map_. |
*/ |
PB_DS_CLASS_T_DEC |
inline std::pair< |
typename PB_DS_CLASS_C_DEC::point_iterator, |
bool> |
PB_DS_CLASS_C_DEC:: |
insert(const_reference r_val) |
{ |
PB_DS_ASSERT_VALID((*this)) |
entry_pointer p_l = find_imp(PB_DS_V2F(r_val)); |
if (p_l != 0) |
{ |
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val)) |
return std::make_pair(point_iterator(&p_l->m_value), false); |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val)) |
p_l = allocate_new_entry(r_val, traits_base::m_no_throw_copies_indicator); |
p_l->m_p_next = m_p_l; |
m_p_l = p_l; |
PB_DS_ASSERT_VALID((*this)) |
return std::make_pair(point_iterator(&p_l->m_value), true); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::entry_pointer |
PB_DS_CLASS_C_DEC:: |
allocate_new_entry(const_reference r_val, false_type) |
{ |
entry_pointer p_l = s_entry_allocator.allocate(1); |
cond_dealtor_t cond(p_l); |
new (const_cast<void* >(static_cast<const void* >(&p_l->m_value))) |
value_type(r_val); |
cond.set_no_action(); |
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) |
init_entry_metadata(p_l, s_metadata_type_indicator); |
return p_l; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::entry_pointer |
PB_DS_CLASS_C_DEC:: |
allocate_new_entry(const_reference r_val, true_type) |
{ |
entry_pointer p_l = s_entry_allocator.allocate(1); |
new (&p_l->m_value) value_type(r_val); |
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) |
init_entry_metadata(p_l, s_metadata_type_indicator); |
return p_l; |
} |
PB_DS_CLASS_T_DEC |
template<typename Metadata> |
inline void |
PB_DS_CLASS_C_DEC:: |
init_entry_metadata(entry_pointer p_l, type_to_type<Metadata>) |
{ new (&p_l->m_update_metadata) Metadata(s_update_policy()); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
init_entry_metadata(entry_pointer, type_to_type<null_type>) |
{ } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp |
---|
0,0 → 1,80 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_map_/iterators_fn_imps.hpp |
* Contains implementations of lu_map_. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
begin() |
{ |
if (m_p_l == 0) |
{ |
_GLIBCXX_DEBUG_ASSERT(empty()); |
return end(); |
} |
return iterator(&m_p_l->m_value, m_p_l, this); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
begin() const |
{ |
if (m_p_l == 0) |
{ |
_GLIBCXX_DEBUG_ASSERT(empty()); |
return end(); |
} |
return iterator(&m_p_l->m_value, m_p_l, const_cast<PB_DS_CLASS_C_DEC* >(this)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
end() |
{ return iterator(0, 0, this); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
end() const |
{ |
return const_iterator(0, 0, const_cast<PB_DS_CLASS_C_DEC* const>(this)); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp |
---|
0,0 → 1,343 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_map_/lu_map_.hpp |
* Contains a list update 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/types_traits.hpp> |
#include <ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp> |
#include <ext/pb_ds/exception.hpp> |
#ifdef _GLIBCXX_DEBUG |
#include <ext/pb_ds/detail/debug_map_base.hpp> |
#endif |
#ifdef PB_DS_LU_MAP_TRACE_ |
#include <iostream> |
#endif |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
#define PB_DS_LU_NAME lu_map |
#endif |
#ifdef PB_DS_DATA_FALSE_INDICATOR |
#define PB_DS_LU_NAME lu_set |
#endif |
#define PB_DS_CLASS_T_DEC \ |
template<typename Key, typename Mapped, typename Eq_Fn, \ |
typename _Alloc, typename Update_Policy> |
#define PB_DS_CLASS_C_DEC \ |
PB_DS_LU_NAME<Key, Mapped, Eq_Fn, _Alloc, Update_Policy> |
#define PB_DS_LU_TRAITS_BASE \ |
types_traits<Key, Mapped, _Alloc, false> |
#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 |
/// list-based (with updates) associative container. |
/// Skip to the lu, my darling. |
template<typename Key, |
typename Mapped, |
typename Eq_Fn, |
typename _Alloc, |
typename Update_Policy> |
class PB_DS_LU_NAME : |
#ifdef _GLIBCXX_DEBUG |
protected PB_DS_DEBUG_MAP_BASE_C_DEC, |
#endif |
public PB_DS_LU_TRAITS_BASE |
{ |
private: |
typedef PB_DS_LU_TRAITS_BASE traits_base; |
struct entry |
: public lu_map_entry_metadata_base<typename Update_Policy::metadata_type> |
{ |
typename traits_base::value_type m_value; |
typename _Alloc::template rebind<entry>::other::pointer m_p_next; |
}; |
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 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_; |
#define PB_DS_GEN_POS entry_pointer |
#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 |
#ifdef _GLIBCXX_DEBUG |
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; |
#endif |
typedef cond_dealtor<entry, _Alloc> cond_dealtor_t; |
public: |
typedef _Alloc allocator_type; |
typedef typename _Alloc::size_type size_type; |
typedef typename _Alloc::difference_type difference_type; |
typedef Eq_Fn eq_fn; |
typedef Update_Policy update_policy; |
typedef typename Update_Policy::metadata_type update_metadata; |
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; |
public: |
PB_DS_LU_NAME(); |
PB_DS_LU_NAME(const PB_DS_CLASS_C_DEC&); |
virtual |
~PB_DS_LU_NAME(); |
template<typename It> |
PB_DS_LU_NAME(It, It); |
void |
swap(PB_DS_CLASS_C_DEC&); |
inline size_type |
size() const; |
inline size_type |
max_size() const; |
inline bool |
empty() const; |
inline mapped_reference |
operator[](key_const_reference r_key) |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
return insert(std::make_pair(r_key, mapped_type())).first->second; |
#else |
insert(r_key); |
return traits_base::s_null_type; |
#endif |
} |
inline std::pair<point_iterator, bool> |
insert(const_reference); |
inline point_iterator |
find(key_const_reference r_key) |
{ |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
entry_pointer p_e = find_imp(r_key); |
return point_iterator(p_e == 0 ? 0: &p_e->m_value); |
} |
inline point_const_iterator |
find(key_const_reference r_key) const |
{ |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
entry_pointer p_e = find_imp(r_key); |
return point_const_iterator(p_e == 0 ? 0: &p_e->m_value); |
} |
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* file, int line) const; |
#endif |
#ifdef PB_DS_LU_MAP_TRACE_ |
void |
trace() const; |
#endif |
protected: |
template<typename It> |
void |
copy_from_range(It, It); |
private: |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
friend class iterator_; |
#endif |
friend class const_iterator_; |
inline entry_pointer |
allocate_new_entry(const_reference, false_type); |
inline entry_pointer |
allocate_new_entry(const_reference, true_type); |
template<typename Metadata> |
inline static void |
init_entry_metadata(entry_pointer, type_to_type<Metadata>); |
inline static void |
init_entry_metadata(entry_pointer, type_to_type<null_type>); |
void |
deallocate_all(); |
void |
erase_next(entry_pointer); |
void |
actual_erase_entry(entry_pointer); |
void |
inc_it_state(const_pointer& r_p_value, entry_pointer& r_pos) const |
{ |
r_pos = r_pos->m_p_next; |
r_p_value = (r_pos == 0) ? 0 : &r_pos->m_value; |
} |
template<typename Metadata> |
inline static bool |
apply_update(entry_pointer, type_to_type<Metadata>); |
inline static bool |
apply_update(entry_pointer, type_to_type<null_type>); |
inline entry_pointer |
find_imp(key_const_reference) const; |
static entry_allocator s_entry_allocator; |
static Eq_Fn s_eq_fn; |
static Update_Policy s_update_policy; |
static type_to_type<update_metadata> s_metadata_type_indicator; |
static null_type s_null_type; |
mutable entry_pointer m_p_l; |
}; |
#include <ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp> |
#include <ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp> |
#include <ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp> |
#include <ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp> |
#include <ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_LU_TRAITS_BASE |
#undef PB_DS_DEBUG_MAP_BASE_C_DEC |
#undef PB_DS_LU_NAME |
} // namespace detail |
} // namespace __gnu_pbds |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp |
---|
0,0 → 1,59 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_map_/trace_fn_imps.hpp |
* Contains implementations of lu_map_. |
*/ |
#ifdef PB_DS_LU_MAP_TRACE_ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace() const |
{ |
std::cerr << m_p_l << std::endl << std::endl; |
const_entry_pointer p_l = m_p_l; |
while (p_l != 0) |
{ |
std::cerr << PB_DS_V2F(p_l->m_value) << std::endl; |
p_l = p_l->m_p_next; |
} |
std::cerr << std::endl; |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp |
---|
0,0 → 1,87 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 lu_counter_metadata.hpp |
* Contains implementation of a lu counter policy's metadata. |
*/ |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
template<typename Size_Type> |
class lu_counter_policy_base; |
/// A list-update metadata type that moves elements to the front of |
/// the list based on the counter algorithm. |
template<typename Size_Type = std::size_t> |
class lu_counter_metadata |
{ |
public: |
typedef Size_Type size_type; |
private: |
lu_counter_metadata(size_type init_count) : m_count(init_count) |
{ } |
friend class lu_counter_policy_base<size_type>; |
mutable size_type m_count; |
}; |
/// Base class for list-update counter policy. |
template<typename Size_Type> |
class lu_counter_policy_base |
{ |
protected: |
typedef Size_Type size_type; |
lu_counter_metadata<size_type> |
operator()(size_type max_size) const |
{ return lu_counter_metadata<Size_Type>(std::rand() % max_size); } |
template<typename Metadata_Reference> |
bool |
operator()(Metadata_Reference r_data, size_type m_max_count) const |
{ |
if (++r_data.m_count != m_max_count) |
return false; |
r_data.m_count = 0; |
return true; |
} |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp |
---|
0,0 → 1,76 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 sample_update_policy.hpp |
* Contains a sample policy for list update containers. |
*/ |
#ifndef PB_DS_SAMPLE_UPDATE_POLICY_HPP |
#define PB_DS_SAMPLE_UPDATE_POLICY_HPP |
namespace __gnu_pbds |
{ |
/// A sample list-update policy. |
struct sample_update_policy |
{ |
/// Default constructor. |
sample_update_policy(); |
/// Copy constructor. |
sample_update_policy(const sample_update_policy&); |
/// Swaps content. |
inline void |
swap(sample_update_policy& other); |
protected: |
/// Metadata on which this functor operates. |
typedef some_metadata_type metadata_type; |
/// Creates a metadata object. |
metadata_type |
operator()() const; |
/// Decides whether a metadata object should be moved to the front |
/// of the list. A list-update based containers object will call |
/// this method to decide whether to move a node to the front of |
/// the list. The method shoule return true if the node should be |
/// moved to the front of the list. |
bool |
operator()(metadata_reference) const; |
}; |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,257 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/constructors_destructor_fn_imps.hpp |
* Contains an implementation class for ov_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::value_allocator |
PB_DS_CLASS_C_DEC::s_value_alloc; |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::metadata_allocator |
PB_DS_CLASS_C_DEC::s_metadata_alloc; |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_OV_TREE_NAME() : |
m_a_values(0), |
m_a_metadata(0), |
m_end_it(0), |
m_size(0) |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_OV_TREE_NAME(const Cmp_Fn& r_cmp_fn) : |
cmp_fn(r_cmp_fn), |
m_a_values(0), |
m_a_metadata(0), |
m_end_it(0), |
m_size(0) |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_OV_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_nodeu) : |
cmp_fn(r_cmp_fn), |
node_update(r_nodeu), |
m_a_values(0), |
m_a_metadata(0), |
m_end_it(0), |
m_size(0) |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_OV_TREE_NAME(const PB_DS_CLASS_C_DEC& other) : |
#ifdef PB_DS_TREE_TRACE |
trace_base(other), |
#endif |
cmp_fn(other), |
node_update(other), |
m_a_values(0), |
m_a_metadata(0), |
m_end_it(0), |
m_size(0) |
{ |
copy_from_ordered_range(other.begin(), other.end()); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
template<typename It> |
inline void |
PB_DS_CLASS_C_DEC:: |
copy_from_range(It first_it, It last_it) |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
typedef std::map<key_type, mapped_type, Cmp_Fn, |
typename _Alloc::template rebind<value_type>::other> |
map_type; |
#else |
typedef std::set<key_type, Cmp_Fn, |
typename _Alloc::template rebind<Key>::other> |
map_type; |
#endif |
map_type m(first_it, last_it); |
copy_from_ordered_range(m.begin(), m.end()); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
template<typename It> |
void |
PB_DS_CLASS_C_DEC:: |
copy_from_ordered_range(It first_it, It last_it) |
{ |
const size_type len = std::distance(first_it, last_it); |
if (len == 0) |
return; |
value_vector a_values = s_value_alloc.allocate(len); |
iterator target_it = a_values; |
It source_it = first_it; |
It source_end_it = last_it; |
cond_dtor<size_type> cd(a_values, target_it, len); |
while (source_it != source_end_it) |
{ |
void* __v = const_cast<void*>(static_cast<const void*>(target_it)); |
new (__v) value_type(*source_it++); |
++target_it; |
} |
reallocate_metadata((node_update*)this, len); |
cd.set_no_action(); |
m_a_values = a_values; |
m_size = len; |
m_end_it = m_a_values + m_size; |
update(PB_DS_node_begin_imp(), (node_update*)this); |
#ifdef _GLIBCXX_DEBUG |
for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it) |
debug_base::insert_new(PB_DS_V2F(*dbg_it)); |
#endif |
} |
PB_DS_CLASS_T_DEC |
template<typename It> |
void |
PB_DS_CLASS_C_DEC:: |
copy_from_ordered_range(It first_it, It last_it, It other_first_it, |
It other_last_it) |
{ |
clear(); |
const size_type len = std::distance(first_it, last_it) |
+ std::distance(other_first_it, other_last_it); |
value_vector a_values = s_value_alloc.allocate(len); |
iterator target_it = a_values; |
It source_it = first_it; |
It source_end_it = last_it; |
cond_dtor<size_type> cd(a_values, target_it, len); |
while (source_it != source_end_it) |
{ |
new (const_cast<void* >(static_cast<const void* >(target_it))) |
value_type(*source_it++); |
++target_it; |
} |
source_it = other_first_it; |
source_end_it = other_last_it; |
while (source_it != source_end_it) |
{ |
new (const_cast<void* >(static_cast<const void* >(target_it))) |
value_type(*source_it++); |
++target_it; |
} |
reallocate_metadata((node_update* )this, len); |
cd.set_no_action(); |
m_a_values = a_values; |
m_size = len; |
m_end_it = m_a_values + m_size; |
update(PB_DS_node_begin_imp(), (node_update* )this); |
#ifdef _GLIBCXX_DEBUG |
for (const_iterator dbg_it = m_a_values; dbg_it != m_end_it; ++dbg_it) |
debug_base::insert_new(PB_DS_V2F(*dbg_it)); |
#endif |
} |
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) |
value_swap(other); |
std::swap(static_cast<cmp_fn&>(*this), |
static_cast<cmp_fn&>(other)); |
std::swap(static_cast<traits_base&>(*this), |
static_cast<traits_base&>(other)); |
PB_DS_ASSERT_VALID(other) |
PB_DS_ASSERT_VALID((*this)) |
} |
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_a_values, other.m_a_values); |
std::swap(m_a_metadata, other.m_a_metadata); |
std::swap(m_size, other.m_size); |
std::swap(m_end_it, other.m_end_it); |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
~PB_DS_OV_TREE_NAME() |
{ |
PB_DS_ASSERT_VALID((*this)) |
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size); |
reallocate_metadata((node_update*)this, 0); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
update(node_iterator, null_node_update_pointer) |
{ } |
PB_DS_CLASS_T_DEC |
template<typename Node_Update> |
void |
PB_DS_CLASS_C_DEC:: |
update(node_iterator nd_it, Node_Update* p_update) |
{ |
node_const_iterator end_it = PB_DS_node_end_imp(); |
if (nd_it != end_it) |
{ |
update(nd_it.get_l_child(), p_update); |
update(nd_it.get_r_child(), p_update); |
node_update::operator()(nd_it, end_it); |
} |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp |
---|
0,0 → 1,79 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/debug_fn_imps.hpp |
* Contains an implementation class for ov_tree_. |
*/ |
#ifdef _GLIBCXX_DEBUG |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_valid(const char* __file, int __line) const |
{ |
if (m_a_values == 0 || m_end_it == 0 || m_size == 0) |
PB_DS_DEBUG_VERIFY(m_a_values == 0 && m_end_it == 0 && m_size == 0); |
assert_iterators(__file, __line); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_iterators(const char* __file, int __line) const |
{ |
debug_base::check_size(m_size, __file, __line); |
size_type iterated_num = 0; |
const_iterator prev_it = end(); |
PB_DS_DEBUG_VERIFY(m_end_it == m_a_values + m_size); |
for (const_iterator it = begin(); it != end(); ++it) |
{ |
++iterated_num; |
debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); |
PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it); |
const_iterator upper_bound_it = upper_bound(PB_DS_V2F(*it)); |
--upper_bound_it; |
PB_DS_DEBUG_VERIFY(upper_bound_it == it); |
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); |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp |
---|
0,0 → 1,191 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/erase_fn_imps.hpp |
* Contains an implementation class for ov_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
clear() |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (m_size == 0) |
{ |
return; |
} |
else |
{ |
reallocate_metadata((node_update* )this, 0); |
cond_dtor<size_type> cd(m_a_values, m_end_it, m_size); |
} |
_GLIBCXX_DEBUG_ONLY(debug_base::clear();) |
m_a_values = 0; |
m_size = 0; |
m_end_it = m_a_values; |
PB_DS_ASSERT_VALID((*this)) |
} |
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) |
{ |
PB_DS_ASSERT_VALID((*this)) |
#ifdef PB_DS_REGRESSION |
typename _Alloc::group_adjustor adjust(m_size); |
#endif |
size_type new_size = 0; |
size_type num_val_ersd = 0; |
for (iterator source_it = begin(); source_it != m_end_it; ++source_it) |
if (!pred(*source_it)) |
++new_size; |
else |
++num_val_ersd; |
if (new_size == 0) |
{ |
clear(); |
return num_val_ersd; |
} |
value_vector a_new_values = s_value_alloc.allocate(new_size); |
iterator target_it = a_new_values; |
cond_dtor<size_type> cd(a_new_values, target_it, new_size); |
_GLIBCXX_DEBUG_ONLY(debug_base::clear()); |
for (iterator source_it = begin(); source_it != m_end_it; ++source_it) |
{ |
if (!pred(*source_it)) |
{ |
new (const_cast<void*>(static_cast<const void*>(target_it))) |
value_type(*source_it); |
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(*source_it))); |
++target_it; |
} |
} |
reallocate_metadata((node_update*)this, new_size); |
cd.set_no_action(); |
{ |
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size); |
} |
m_a_values = a_new_values; |
m_size = new_size; |
m_end_it = target_it; |
update(node_begin(), (node_update*)this); |
PB_DS_ASSERT_VALID((*this)) |
return num_val_ersd; |
} |
PB_DS_CLASS_T_DEC |
template<typename It> |
It |
PB_DS_CLASS_C_DEC:: |
erase_imp(It it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (it == end()) |
return end(); |
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(*it)) |
#ifdef PB_DS_REGRESSION |
typename _Alloc::group_adjustor adjust(m_size); |
#endif |
_GLIBCXX_DEBUG_ASSERT(m_size > 0); |
value_vector a_values = s_value_alloc.allocate(m_size - 1); |
iterator source_it = begin(); |
iterator source_end_it = end(); |
iterator target_it = a_values; |
iterator ret_it = end(); |
cond_dtor<size_type> cd(a_values, target_it, m_size - 1); |
_GLIBCXX_DEBUG_ONLY(size_type cnt = 0;) |
while (source_it != source_end_it) |
{ |
if (source_it != it) |
{ |
_GLIBCXX_DEBUG_ONLY(++cnt;) |
_GLIBCXX_DEBUG_ASSERT(cnt != m_size); |
new (const_cast<void*>(static_cast<const void*>(target_it))) |
value_type(*source_it); |
++target_it; |
} |
else |
ret_it = target_it; |
++source_it; |
} |
_GLIBCXX_DEBUG_ASSERT(m_size > 0); |
reallocate_metadata((node_update*)this, m_size - 1); |
cd.set_no_action(); |
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(*it));) |
{ |
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size); |
} |
m_a_values = a_values; |
--m_size; |
m_end_it = m_a_values + m_size; |
update(node_begin(), (node_update*)this); |
PB_DS_ASSERT_VALID((*this)) |
return It(ret_it); |
} |
PB_DS_CLASS_T_DEC |
bool |
PB_DS_CLASS_C_DEC:: |
erase(key_const_reference r_key) |
{ |
point_iterator it = find(r_key); |
if (it == end()) |
return false; |
erase(it); |
return true; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp |
---|
0,0 → 1,60 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/info_fn_imps.hpp |
* Contains an implementation class for ov_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
size() const |
{ |
PB_DS_ASSERT_VALID((*this)) |
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_value_alloc.max_size(); } |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
empty() const |
{ return size() == 0; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp |
---|
0,0 → 1,63 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/insert_fn_imps.hpp |
* Contains an implementation class for ov_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
reallocate_metadata(null_node_update_pointer, size_type) |
{ } |
PB_DS_CLASS_T_DEC |
template<typename Node_Update_> |
void |
PB_DS_CLASS_C_DEC:: |
reallocate_metadata(Node_Update_* , size_type new_size) |
{ |
metadata_pointer a_new_metadata_vec =(new_size == 0) ? 0 : s_metadata_alloc.allocate(new_size); |
if (m_a_metadata != 0) |
{ |
for (size_type i = 0; i < m_size; ++i) |
m_a_metadata[i].~metadata_type(); |
s_metadata_alloc.deallocate(m_a_metadata, m_size); |
} |
std::swap(m_a_metadata, a_new_metadata_vec); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp |
---|
0,0 → 1,103 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/iterators_fn_imps.hpp |
* Contains an implementation class for ov_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_const_iterator |
PB_DS_CLASS_C_DEC:: |
node_begin() const |
{ return PB_DS_node_begin_imp(); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_const_iterator |
PB_DS_CLASS_C_DEC:: |
node_end() const |
{ return PB_DS_node_end_imp(); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_iterator |
PB_DS_CLASS_C_DEC:: |
node_begin() |
{ return PB_DS_node_begin_imp(); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_iterator |
PB_DS_CLASS_C_DEC:: |
node_end() |
{ return PB_DS_node_end_imp(); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_const_iterator |
PB_DS_CLASS_C_DEC:: |
PB_DS_node_begin_imp() const |
{ |
return node_const_iterator(const_cast<pointer>(mid_pointer(begin(), end())), |
const_cast<pointer>(begin()), |
const_cast<pointer>(end()),(m_a_metadata == 0)? |
0 : |
mid_pointer(m_a_metadata, m_a_metadata + m_size)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_const_iterator |
PB_DS_CLASS_C_DEC:: |
PB_DS_node_end_imp() const |
{ |
return node_const_iterator(end(), end(), end(), |
(m_a_metadata == 0) ? 0 : m_a_metadata + m_size); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_iterator |
PB_DS_CLASS_C_DEC:: |
PB_DS_node_begin_imp() |
{ |
return node_iterator(mid_pointer(begin(), end()), begin(), end(), |
(m_a_metadata == 0) ? 0 : mid_pointer(m_a_metadata, m_a_metadata + m_size)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_iterator |
PB_DS_CLASS_C_DEC:: |
PB_DS_node_end_imp() |
{ |
return node_iterator(end(), end(), |
end(),(m_a_metadata == 0) ? 0 : m_a_metadata + m_size); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp |
---|
0,0 → 1,291 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/node_iterators.hpp |
* Contains an implementation class for ov_tree_. |
*/ |
#ifndef PB_DS_OV_TREE_NODE_ITERATORS_HPP |
#define PB_DS_OV_TREE_NODE_ITERATORS_HPP |
#include <ext/pb_ds/tag_and_trait.hpp> |
#include <ext/pb_ds/detail/type_utils.hpp> |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#define PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC \ |
ov_tree_node_const_it_<Value_Type, Metadata_Type, _Alloc> |
/// Const node reference. |
template<typename Value_Type, typename Metadata_Type, typename _Alloc> |
class ov_tree_node_const_it_ |
{ |
protected: |
typedef |
typename _Alloc::template rebind< |
Value_Type>::other::pointer |
pointer; |
typedef |
typename _Alloc::template rebind< |
Value_Type>::other::const_pointer |
const_pointer; |
typedef |
typename _Alloc::template rebind< |
Metadata_Type>::other::const_pointer |
const_metadata_pointer; |
typedef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC this_type; |
protected: |
template<typename Ptr> |
inline static Ptr |
mid_pointer(Ptr p_begin, Ptr p_end) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_end >= p_begin); |
return (p_begin + (p_end - p_begin) / 2); |
} |
public: |
typedef trivial_iterator_tag iterator_category; |
typedef trivial_iterator_difference_type difference_type; |
typedef |
typename _Alloc::template rebind< |
Value_Type>::other::const_pointer |
value_type; |
typedef |
typename _Alloc::template rebind< |
typename remove_const< |
Value_Type>::type>::other::const_pointer |
reference; |
typedef |
typename _Alloc::template rebind< |
typename remove_const< |
Value_Type>::type>::other::const_pointer |
const_reference; |
typedef Metadata_Type metadata_type; |
typedef |
typename _Alloc::template rebind< |
metadata_type>::other::const_reference |
metadata_const_reference; |
public: |
inline |
ov_tree_node_const_it_(const_pointer p_nd = 0, const_pointer p_begin_nd = 0, const_pointer p_end_nd = 0, const_metadata_pointer p_metadata = 0) : m_p_value(const_cast<pointer>(p_nd)), m_p_begin_value(const_cast<pointer>(p_begin_nd)), m_p_end_value(const_cast<pointer>(p_end_nd)), m_p_metadata(p_metadata) |
{ } |
inline const_reference |
operator*() const |
{ return m_p_value; } |
inline metadata_const_reference |
get_metadata() const |
{ |
enum |
{ |
has_metadata = !is_same<Metadata_Type, null_type>::value |
}; |
PB_DS_STATIC_ASSERT(should_have_metadata, has_metadata); |
_GLIBCXX_DEBUG_ASSERT(m_p_metadata != 0); |
return *m_p_metadata; |
} |
/// Returns the node iterator associated with the left node. |
inline this_type |
get_l_child() const |
{ |
if (m_p_begin_value == m_p_value) |
return (this_type(m_p_begin_value, m_p_begin_value, m_p_begin_value)); |
const_metadata_pointer p_begin_metadata = |
m_p_metadata - (m_p_value - m_p_begin_value); |
return (this_type(mid_pointer(m_p_begin_value, m_p_value), |
m_p_begin_value, |
m_p_value, |
mid_pointer(p_begin_metadata, m_p_metadata))); |
} |
/// Returns the node iterator associated with the right node. |
inline this_type |
get_r_child() const |
{ |
if (m_p_value == m_p_end_value) |
return (this_type(m_p_end_value, m_p_end_value, m_p_end_value)); |
const_metadata_pointer p_end_metadata = |
m_p_metadata + (m_p_end_value - m_p_value); |
return (this_type(mid_pointer(m_p_value + 1, m_p_end_value), |
m_p_value + 1, |
m_p_end_value,(m_p_metadata == 0) ? |
0 : mid_pointer(m_p_metadata + 1, p_end_metadata))); |
} |
inline bool |
operator==(const this_type& other) const |
{ |
const bool is_end = m_p_begin_value == m_p_end_value; |
const bool is_other_end = other.m_p_begin_value == other.m_p_end_value; |
if (is_end) |
return (is_other_end); |
if (is_other_end) |
return (is_end); |
return m_p_value == other.m_p_value; |
} |
inline bool |
operator!=(const this_type& other) const |
{ return !operator==(other); } |
public: |
pointer m_p_value; |
pointer m_p_begin_value; |
pointer m_p_end_value; |
const_metadata_pointer m_p_metadata; |
}; |
#define PB_DS_OV_TREE_NODE_ITERATOR_C_DEC \ |
ov_tree_node_it_<Value_Type, Metadata_Type, _Alloc> |
/// Node reference. |
template<typename Value_Type, typename Metadata_Type, typename _Alloc> |
class ov_tree_node_it_ : public PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC |
{ |
private: |
typedef PB_DS_OV_TREE_NODE_ITERATOR_C_DEC this_type; |
typedef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC base_type; |
typedef typename base_type::pointer pointer; |
typedef typename base_type::const_pointer const_pointer; |
typedef |
typename base_type::const_metadata_pointer |
const_metadata_pointer; |
public: |
typedef trivial_iterator_tag iterator_category; |
typedef trivial_iterator_difference_type difference_type; |
typedef |
typename _Alloc::template rebind< |
Value_Type>::other::pointer |
value_type; |
typedef |
typename _Alloc::template rebind< |
typename remove_const< |
Value_Type>::type>::other::pointer |
reference; |
typedef |
typename _Alloc::template rebind< |
typename remove_const< |
Value_Type>::type>::other::pointer |
const_reference; |
inline |
ov_tree_node_it_(const_pointer p_nd = 0, const_pointer p_begin_nd = 0, const_pointer p_end_nd = 0, const_metadata_pointer p_metadata = 0) : base_type(p_nd, p_begin_nd, p_end_nd, p_metadata) |
{ } |
/// Access. |
inline reference |
operator*() const |
{ return reference(base_type::m_p_value); } |
/// Returns the node reference associated with the left node. |
inline ov_tree_node_it_ |
get_l_child() const |
{ |
if (base_type::m_p_begin_value == base_type::m_p_value) |
return (this_type(base_type::m_p_begin_value, base_type::m_p_begin_value, base_type::m_p_begin_value)); |
const_metadata_pointer p_begin_metadata = |
base_type::m_p_metadata - (base_type::m_p_value - base_type::m_p_begin_value); |
return (this_type(base_type::mid_pointer(base_type::m_p_begin_value, base_type::m_p_value), |
base_type::m_p_begin_value, |
base_type::m_p_value, |
base_type::mid_pointer(p_begin_metadata, base_type::m_p_metadata))); |
} |
/// Returns the node reference associated with the right node. |
inline ov_tree_node_it_ |
get_r_child() const |
{ |
if (base_type::m_p_value == base_type::m_p_end_value) |
return this_type(base_type::m_p_end_value, base_type::m_p_end_value, |
base_type::m_p_end_value); |
const_metadata_pointer p_end_metadata = |
base_type::m_p_metadata + (base_type::m_p_end_value - base_type::m_p_value); |
return (this_type(base_type::mid_pointer(base_type::m_p_value + 1, base_type::m_p_end_value), |
base_type::m_p_value + 1, |
base_type::m_p_end_value,(base_type::m_p_metadata == 0)? |
0 : base_type::mid_pointer(base_type::m_p_metadata + 1, p_end_metadata))); |
} |
}; |
#undef PB_DS_OV_TREE_NODE_ITERATOR_C_DEC |
#undef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp |
---|
0,0 → 1,542 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/ov_tree_map_.hpp |
* Contains an implementation class for ov_tree. |
*/ |
#include <map> |
#include <set> |
#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/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 <algorithm> |
#include <vector> |
#include <assert.h> |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
#define PB_DS_OV_TREE_NAME ov_tree_map |
#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_node_const_iterator_map |
#endif |
#ifdef PB_DS_DATA_FALSE_INDICATOR |
#define PB_DS_OV_TREE_NAME ov_tree_set |
#define PB_DS_CONST_NODE_ITERATOR_NAME ov_tree_node_const_iterator_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_OV_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc> |
#define PB_DS_OV_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, false, _Alloc> |
#endif |
#ifndef PB_DS_CHECK_KEY_EXISTS |
# error Missing definition |
#endif |
/** |
* @brief Ordered-vector tree associative-container. |
* @ingroup branch-detail |
*/ |
template<typename Key, typename Mapped, typename Cmp_Fn, |
typename Node_And_It_Traits, typename _Alloc> |
class PB_DS_OV_TREE_NAME : |
#ifdef _GLIBCXX_DEBUG |
protected 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 Node_And_It_Traits::node_update, |
public PB_DS_OV_TREE_TRAITS_BASE |
{ |
private: |
typedef PB_DS_OV_TREE_TRAITS_BASE traits_base; |
typedef Node_And_It_Traits traits_type; |
typedef typename remove_const<typename traits_base::value_type>::type non_const_value_type; |
typedef typename _Alloc::template rebind<non_const_value_type>::other value_allocator; |
typedef typename value_allocator::pointer value_vector; |
#ifdef _GLIBCXX_DEBUG |
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; |
#endif |
#ifdef PB_DS_TREE_TRACE |
typedef PB_DS_TREE_TRACE_BASE_C_DEC trace_base; |
#endif |
typedef typename traits_base::pointer mapped_pointer_; |
typedef typename traits_base::const_pointer mapped_const_pointer_; |
typedef typename traits_type::metadata_type metadata_type; |
typedef typename _Alloc::template rebind<metadata_type>::other metadata_allocator; |
typedef typename metadata_allocator::pointer metadata_pointer; |
typedef typename metadata_allocator::const_reference metadata_const_reference; |
typedef typename metadata_allocator::reference metadata_reference; |
typedef typename traits_type::null_node_update_pointer |
null_node_update_pointer; |
public: |
typedef ov_tree_tag container_category; |
typedef _Alloc allocator_type; |
typedef typename _Alloc::size_type size_type; |
typedef typename _Alloc::difference_type difference_type; |
typedef Cmp_Fn cmp_fn; |
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; |
typedef const_pointer point_const_iterator; |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
typedef pointer point_iterator; |
#else |
typedef point_const_iterator point_iterator; |
#endif |
typedef point_iterator iterator; |
typedef point_const_iterator const_iterator; |
/// Conditional destructor. |
template<typename Size_Type> |
class cond_dtor |
{ |
public: |
cond_dtor(value_vector a_vec, iterator& r_last_it, |
Size_Type total_size) |
: m_a_vec(a_vec), m_r_last_it(r_last_it), m_max_size(total_size), |
m_no_action(false) |
{ } |
~cond_dtor() |
{ |
if (m_no_action) |
return; |
iterator it = m_a_vec; |
while (it != m_r_last_it) |
{ |
it->~value_type(); |
++it; |
} |
if (m_max_size > 0) |
value_allocator().deallocate(m_a_vec, m_max_size); |
} |
inline void |
set_no_action() |
{ m_no_action = true; } |
protected: |
value_vector m_a_vec; |
iterator& m_r_last_it; |
const Size_Type m_max_size; |
bool m_no_action; |
}; |
typedef typename traits_type::node_update node_update; |
typedef typename traits_type::node_iterator node_iterator; |
typedef typename traits_type::node_const_iterator node_const_iterator; |
PB_DS_OV_TREE_NAME(); |
PB_DS_OV_TREE_NAME(const Cmp_Fn&); |
PB_DS_OV_TREE_NAME(const Cmp_Fn&, const node_update&); |
PB_DS_OV_TREE_NAME(const PB_DS_CLASS_C_DEC&); |
~PB_DS_OV_TREE_NAME(); |
void |
swap(PB_DS_CLASS_C_DEC&); |
template<typename It> |
void |
copy_from_range(It, It); |
inline size_type |
max_size() const; |
inline bool |
empty() const; |
inline size_type |
size() const; |
Cmp_Fn& |
get_cmp_fn(); |
const Cmp_Fn& |
get_cmp_fn() const; |
inline mapped_reference |
operator[](key_const_reference r_key) |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
PB_DS_ASSERT_VALID((*this)) |
point_iterator it = lower_bound(r_key); |
if (it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it))) |
{ |
PB_DS_CHECK_KEY_EXISTS(r_key) |
PB_DS_ASSERT_VALID((*this)) |
return it->second; |
} |
return insert_new_val(it, std::make_pair(r_key, mapped_type()))->second; |
#else |
insert(r_key); |
return traits_base::s_null_type; |
#endif |
} |
inline std::pair<point_iterator, bool> |
insert(const_reference r_value) |
{ |
PB_DS_ASSERT_VALID((*this)) |
key_const_reference r_key = PB_DS_V2F(r_value); |
point_iterator it = lower_bound(r_key); |
if (it != end()&& !Cmp_Fn::operator()(r_key, PB_DS_V2F(*it))) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_CHECK_KEY_EXISTS(r_key) |
return std::make_pair(it, false); |
} |
return std::make_pair(insert_new_val(it, r_value), true); |
} |
inline point_iterator |
lower_bound(key_const_reference r_key) |
{ |
pointer it = m_a_values; |
pointer e_it = m_a_values + m_size; |
while (it != e_it) |
{ |
pointer mid_it = it + ((e_it - it) >> 1); |
if (cmp_fn::operator()(PB_DS_V2F(*mid_it), r_key)) |
it = ++mid_it; |
else |
e_it = mid_it; |
} |
return it; |
} |
inline point_const_iterator |
lower_bound(key_const_reference r_key) const |
{ return const_cast<PB_DS_CLASS_C_DEC& >(*this).lower_bound(r_key); } |
inline point_iterator |
upper_bound(key_const_reference r_key) |
{ |
iterator pot_it = lower_bound(r_key); |
if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) |
{ |
PB_DS_CHECK_KEY_EXISTS(r_key) |
return ++pot_it; |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return pot_it; |
} |
inline point_const_iterator |
upper_bound(key_const_reference r_key) const |
{ return const_cast<PB_DS_CLASS_C_DEC&>(*this).upper_bound(r_key); } |
inline point_iterator |
find(key_const_reference r_key) |
{ |
PB_DS_ASSERT_VALID((*this)) |
iterator pot_it = lower_bound(r_key); |
if (pot_it != end() && !Cmp_Fn::operator()(r_key, PB_DS_V2F(*pot_it))) |
{ |
PB_DS_CHECK_KEY_EXISTS(r_key) |
return pot_it; |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return end(); |
} |
inline point_const_iterator |
find(key_const_reference r_key) const |
{ return (const_cast<PB_DS_CLASS_C_DEC&>(*this).find(r_key)); } |
bool |
erase(key_const_reference); |
template<typename Pred> |
inline size_type |
erase_if(Pred); |
inline iterator |
erase(iterator it) |
{ return erase_imp<iterator>(it); } |
void |
clear(); |
void |
join(PB_DS_CLASS_C_DEC&); |
void |
split(key_const_reference, PB_DS_CLASS_C_DEC&); |
inline iterator |
begin() |
{ return m_a_values; } |
inline const_iterator |
begin() const |
{ return m_a_values; } |
inline iterator |
end() |
{ return m_end_it; } |
inline const_iterator |
end() const |
{ return m_end_it; } |
/// 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(); |
private: |
inline void |
update(node_iterator, null_node_update_pointer); |
template<typename Node_Update> |
void |
update(node_iterator, Node_Update*); |
void |
reallocate_metadata(null_node_update_pointer, size_type); |
template<typename Node_Update_> |
void |
reallocate_metadata(Node_Update_*, size_type); |
template<typename It> |
void |
copy_from_ordered_range(It, It); |
void |
value_swap(PB_DS_CLASS_C_DEC&); |
template<typename It> |
void |
copy_from_ordered_range(It, It, It, It); |
template<typename Ptr> |
inline static Ptr |
mid_pointer(Ptr p_begin, Ptr p_end) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_end >= p_begin); |
return (p_begin + (p_end - p_begin) / 2); |
} |
inline iterator |
insert_new_val(iterator it, const_reference r_value) |
{ |
#ifdef PB_DS_REGRESSION |
typename _Alloc::group_adjustor adjust(m_size); |
#endif |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_value)) |
value_vector a_values = s_value_alloc.allocate(m_size + 1); |
iterator source_it = begin(); |
iterator source_end_it = end(); |
iterator target_it = a_values; |
iterator ret_it; |
cond_dtor<size_type> cd(a_values, target_it, m_size + 1); |
while (source_it != it) |
{ |
new (const_cast<void*>(static_cast<const void*>(target_it))) |
value_type(*source_it++); |
++target_it; |
} |
new (const_cast<void*>(static_cast<const void*>(ret_it = target_it))) |
value_type(r_value); |
++target_it; |
while (source_it != source_end_it) |
{ |
new (const_cast<void*>(static_cast<const void*>(target_it))) |
value_type(*source_it++); |
++target_it; |
} |
reallocate_metadata((node_update*)this, m_size + 1); |
cd.set_no_action(); |
if (m_size != 0) |
{ |
cond_dtor<size_type> cd1(m_a_values, m_end_it, m_size); |
} |
++m_size; |
m_a_values = a_values; |
m_end_it = m_a_values + m_size; |
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_value))); |
update(node_begin(), (node_update* )this); |
PB_DS_ASSERT_VALID((*this)) |
return ret_it; |
} |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char*, int) const; |
void |
assert_iterators(const char*, int) const; |
#endif |
template<typename It> |
It |
erase_imp(It); |
inline node_const_iterator |
PB_DS_node_begin_imp() const; |
inline node_const_iterator |
PB_DS_node_end_imp() const; |
inline node_iterator |
PB_DS_node_begin_imp(); |
inline node_iterator |
PB_DS_node_end_imp(); |
private: |
static value_allocator s_value_alloc; |
static metadata_allocator s_metadata_alloc; |
value_vector m_a_values; |
metadata_pointer m_a_metadata; |
iterator m_end_it; |
size_type m_size; |
}; |
#include <ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp> |
#include <ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp> |
#include <ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp> |
#include <ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp> |
#include <ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp> |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_OV_TREE_NAME |
#undef PB_DS_OV_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 |
#undef PB_DS_CONST_NODE_ITERATOR_NAME |
} // namespace detail |
} // namespace __gnu_pbds |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp |
---|
0,0 → 1,51 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/policy_access_fn_imps.hpp |
* Contains an implementation class for ov_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; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp |
---|
0,0 → 1,132 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/split_join_fn_imps.hpp |
* Contains an implementation class for ov_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
if (m_size == 0) |
{ |
other.clear(); |
return; |
} |
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(*begin()))) |
{ |
value_swap(other); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(*(end() - 1)))) |
{ |
return; |
} |
if (m_size == 1) |
{ |
value_swap(other); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
iterator it = upper_bound(r_key); |
PB_DS_CLASS_C_DEC new_other(other, other); |
new_other.copy_from_ordered_range(it, end()); |
PB_DS_CLASS_C_DEC new_this(*this, *this); |
new_this.copy_from_ordered_range(begin(), it); |
// No exceptions from this point. |
other.update(other.node_begin(), (node_update*)(&other)); |
update(node_begin(), (node_update*)this); |
other.value_swap(new_other); |
value_swap(new_this); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
join(PB_DS_CLASS_C_DEC& other) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
if (other.m_size == 0) |
return; |
if (m_size == 0) |
{ |
value_swap(other); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
const bool greater = Cmp_Fn::operator()(PB_DS_V2F(*(end() - 1)), |
PB_DS_V2F(*other.begin())); |
const bool lesser = Cmp_Fn::operator()(PB_DS_V2F(*(other.end() - 1)), |
PB_DS_V2F(*begin())); |
if (!greater && !lesser) |
__throw_join_error(); |
PB_DS_CLASS_C_DEC new_this(*this, *this); |
if (greater) |
new_this.copy_from_ordered_range(begin(), end(), |
other.begin(), other.end()); |
else |
new_this.copy_from_ordered_range(other.begin(), other.end(), |
begin(), end()); |
// No exceptions from this point. |
value_swap(new_this); |
other.clear(); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/ov_tree_map_/traits.hpp |
---|
0,0 → 1,190 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 ov_tree_map_/traits.hpp |
* Contains an implementation class for ov_tree_. |
*/ |
#ifndef PB_DS_OV_TREE_NODE_AND_IT_TRAITS_HPP |
#define PB_DS_OV_TREE_NODE_AND_IT_TRAITS_HPP |
#include <ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Tree traits. |
/// @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, |
typename _Alloc> |
struct tree_traits< |
Key, |
Mapped, |
Cmp_Fn, |
Node_Update, |
ov_tree_tag, |
_Alloc> |
{ |
private: |
typedef |
typename types_traits< |
Key, |
Mapped, |
_Alloc, |
false>::value_type |
value_type; |
public: |
typedef |
typename tree_node_metadata_dispatch< |
Key, |
Mapped, |
Cmp_Fn, |
Node_Update, |
_Alloc>::type |
metadata_type; |
/// This is an iterator to an iterator: it iterates over nodes, |
/// and de-referencing it returns one of the tree's iterators. |
typedef |
ov_tree_node_const_it_< |
value_type, |
metadata_type, |
_Alloc> |
node_const_iterator; |
typedef |
ov_tree_node_it_< |
value_type, |
metadata_type, |
_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, |
typename _Alloc> |
struct tree_traits< |
Key, |
null_type, |
Cmp_Fn, |
Node_Update, |
ov_tree_tag, |
_Alloc> |
{ |
private: |
typedef |
typename types_traits< |
Key, |
null_type, |
_Alloc, |
false>::value_type |
value_type; |
public: |
typedef |
typename tree_node_metadata_dispatch< |
Key, |
null_type, |
Cmp_Fn, |
Node_Update, |
_Alloc>::type |
metadata_type; |
/// This is an iterator to an iterator: it iterates over nodes, |
/// and de-referencing it returns one of the tree's iterators. |
typedef |
ov_tree_node_const_it_< |
value_type, |
metadata_type, |
_Alloc> |
node_const_iterator; |
typedef node_const_iterator node_iterator; |
typedef |
Node_Update< |
node_const_iterator, |
node_const_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_OV_TREE_NODE_AND_IT_TRAITS_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,82 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pairing_heap_/constructors_destructor_fn_imps.hpp |
* Contains an implementation class for a pairing heap. |
*/ |
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((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
pairing_heap() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
pairing_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:: |
pairing_heap(const PB_DS_CLASS_C_DEC& other) |
: base_type(other) |
{ 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)) |
base_type::swap(other); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
~pairing_heap() |
{ } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp |
---|
0,0 → 1,53 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pairing_heap_/debug_fn_imps.hpp |
* Contains an implementation class for a pairing heap. |
*/ |
#ifdef _GLIBCXX_DEBUG |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_valid(const char* __file, int __line) const |
{ |
PB_DS_DEBUG_VERIFY(base_type::m_p_root == 0 |
|| base_type::m_p_root->m_p_next_sibling == 0); |
base_type::assert_valid(__file, __line); |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp |
---|
0,0 → 1,233 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pairing_heap_/erase_fn_imps.hpp |
* Contains an implementation class for a pairing heap. |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
pop() |
{ |
PB_DS_ASSERT_VALID((*this)) |
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); |
node_pointer p_new_root = join_node_children(base_type::m_p_root); |
PB_DS_ASSERT_NODE_CONSISTENT(p_new_root, false) |
if (p_new_root != 0) |
p_new_root->m_p_prev_or_parent = 0; |
base_type::actual_erase_node(base_type::m_p_root); |
base_type::m_p_root = p_new_root; |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
erase(point_iterator it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); |
remove_node(it.m_p_nd); |
base_type::actual_erase_node(it.m_p_nd); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
remove_node(node_pointer p_nd) |
{ |
PB_DS_ASSERT_VALID((*this)) |
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); |
node_pointer p_new_child = join_node_children(p_nd); |
PB_DS_ASSERT_NODE_CONSISTENT(p_new_child, false) |
if (p_nd == base_type::m_p_root) |
{ |
if (p_new_child != 0) |
p_new_child->m_p_prev_or_parent = 0; |
base_type::m_p_root = p_new_child; |
PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false) |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_prev_or_parent != 0); |
if (p_nd->m_p_prev_or_parent->m_p_l_child == p_nd) |
{ |
if (p_new_child != 0) |
{ |
p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; |
p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling; |
if (p_new_child->m_p_next_sibling != 0) |
p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; |
p_nd->m_p_prev_or_parent->m_p_l_child = p_new_child; |
PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) |
return; |
} |
p_nd->m_p_prev_or_parent->m_p_l_child = 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; |
PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) |
return; |
} |
if (p_new_child != 0) |
{ |
p_new_child->m_p_prev_or_parent = p_nd->m_p_prev_or_parent; |
p_new_child->m_p_next_sibling = p_nd->m_p_next_sibling; |
if (p_new_child->m_p_next_sibling != 0) |
p_new_child->m_p_next_sibling->m_p_prev_or_parent = p_new_child; |
p_new_child->m_p_prev_or_parent->m_p_next_sibling = p_new_child; |
PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) |
return; |
} |
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; |
PB_DS_ASSERT_NODE_CONSISTENT(p_nd->m_p_prev_or_parent, false) |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
join_node_children(node_pointer p_nd) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
node_pointer p_ret = p_nd->m_p_l_child; |
if (p_ret == 0) |
return 0; |
while (p_ret->m_p_next_sibling != 0) |
p_ret = forward_join(p_ret, p_ret->m_p_next_sibling); |
while (p_ret->m_p_prev_or_parent != p_nd) |
p_ret = back_join(p_ret->m_p_prev_or_parent, p_ret); |
PB_DS_ASSERT_NODE_CONSISTENT(p_ret, false) |
return p_ret; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
forward_join(node_pointer p_nd, node_pointer p_next) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling == p_next); |
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; |
base_type::make_child_of(p_nd, p_next); |
return p_next->m_p_next_sibling == 0 |
? p_next : p_next->m_p_next_sibling; |
} |
if (p_next->m_p_next_sibling != 0) |
{ |
p_next->m_p_next_sibling->m_p_prev_or_parent = p_nd; |
p_nd->m_p_next_sibling = p_next->m_p_next_sibling; |
base_type::make_child_of(p_next, p_nd); |
return p_nd->m_p_next_sibling; |
} |
p_nd->m_p_next_sibling = 0; |
base_type::make_child_of(p_next, p_nd); |
PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false) |
return p_nd; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
back_join(node_pointer p_nd, node_pointer p_next) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
_GLIBCXX_DEBUG_ASSERT(p_next->m_p_next_sibling == 0); |
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; |
base_type::make_child_of(p_nd, p_next); |
PB_DS_ASSERT_NODE_CONSISTENT(p_next, false) |
return p_next; |
} |
p_nd->m_p_next_sibling = 0; |
base_type::make_child_of(p_next, p_nd); |
PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false) |
return p_nd; |
} |
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)) |
if (base_type::empty()) |
{ |
PB_DS_ASSERT_VALID((*this)) |
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_next_sibling = p_cur->m_p_prev_or_parent = 0; |
push_imp(p_cur); |
p_cur = p_next; |
} |
PB_DS_ASSERT_VALID((*this)) |
return ersd; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp |
---|
0,0 → 1,49 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pairing_heap_/find_fn_imps.hpp |
* Contains an implementation class for a pairing 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(!base_type::empty()); |
return base_type::m_p_root->m_value; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp |
---|
0,0 → 1,88 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pairing_heap_/insert_fn_imps.hpp |
* Contains an implementation class for a pairing 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)) |
node_pointer p_new_nd = base_type::get_new_node_for_insert(r_val); |
push_imp(p_new_nd); |
PB_DS_ASSERT_VALID((*this)) |
return point_iterator(p_new_nd); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
push_imp(node_pointer p_nd) |
{ |
p_nd->m_p_l_child = 0; |
if (base_type::m_p_root == 0) |
{ |
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0; |
base_type::m_p_root = p_nd; |
} |
else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, p_nd->m_value)) |
{ |
p_nd->m_p_next_sibling = p_nd->m_p_prev_or_parent = 0; |
base_type::make_child_of(base_type::m_p_root, p_nd); |
PB_DS_ASSERT_NODE_CONSISTENT(p_nd, false) |
base_type::m_p_root = p_nd; |
} |
else |
{ |
base_type::make_child_of(p_nd, base_type::m_p_root); |
PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false) |
} |
} |
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)) |
remove_node(it.m_p_nd); |
it.m_p_nd->m_value = r_new_val; |
push_imp(it.m_p_nd); |
PB_DS_ASSERT_VALID((*this)) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp |
---|
0,0 → 1,185 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pairing_heap_/pairing_heap_.hpp |
* Contains an implementation class for a pairing heap. |
*/ |
/* |
* Pairing heap: |
* Michael L. Fredman, Robert Sedgewick, Daniel Dominic Sleator, |
* and Robert Endre Tarjan, The Pairing Heap: |
* A New Form of Self-Adjusting Heap, Algorithmica, 1(1):111-129, 1986. |
*/ |
#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> |
#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 \ |
pairing_heap<Value_Type, Cmp_Fn, _Alloc> |
#ifdef _GLIBCXX_DEBUG |
#define PB_DS_P_HEAP_BASE \ |
left_child_next_sibling_heap<Value_Type, Cmp_Fn, null_type, _Alloc, false> |
#else |
#define PB_DS_P_HEAP_BASE \ |
left_child_next_sibling_heap<Value_Type, Cmp_Fn, null_type, _Alloc> |
#endif |
/** |
* Pairing heap. |
* |
* @ingroup heap-detail |
*/ |
template<typename Value_Type, typename Cmp_Fn, typename _Alloc> |
class pairing_heap : public PB_DS_P_HEAP_BASE |
{ |
private: |
typedef PB_DS_P_HEAP_BASE base_type; |
typedef typename base_type::node_pointer node_pointer; |
typedef typename _Alloc::template rebind<Value_Type>::other __rebind_a; |
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_a::pointer pointer; |
typedef typename __rebind_a::const_pointer const_pointer; |
typedef typename __rebind_a::reference reference; |
typedef typename __rebind_a::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; |
pairing_heap(); |
pairing_heap(const Cmp_Fn&); |
pairing_heap(const pairing_heap&); |
void |
swap(pairing_heap&); |
~pairing_heap(); |
inline point_iterator |
push(const_reference); |
void |
modify(point_iterator, const_reference); |
inline const_reference |
top() const; |
void |
pop(); |
void |
erase(point_iterator); |
template<typename Pred> |
size_type |
erase_if(Pred); |
template<typename Pred> |
void |
split(Pred, pairing_heap&); |
void |
join(pairing_heap&); |
protected: |
template<typename It> |
void |
copy_from_range(It, It); |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char*, int) const; |
#endif |
private: |
inline void |
push_imp(node_pointer); |
node_pointer |
join_node_children(node_pointer); |
node_pointer |
forward_join(node_pointer, node_pointer); |
node_pointer |
back_join(node_pointer, node_pointer); |
void |
remove_node(node_pointer); |
}; |
#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \ |
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, _Bool, \ |
__FILE__, __LINE__);) |
#include <ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp> |
#include <ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp> |
#include <ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp> |
#undef PB_DS_ASSERT_NODE_CONSISTENT |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_P_HEAP_BASE |
} // namespace detail |
} // namespace __gnu_pbds |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp |
---|
0,0 → 1,123 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pairing_heap_/split_join_fn_imps.hpp |
* Contains an implementation class for a pairing 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)) |
PB_DS_ASSERT_VALID(other) |
other.clear(); |
if (base_type::empty()) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
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_next_sibling = p_out->m_p_prev_or_parent = 0; |
other.push_imp(p_out); |
p_out = p_next; |
} |
PB_DS_ASSERT_VALID(other) |
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_next_sibling = p_cur->m_p_prev_or_parent = 0; |
push_imp(p_cur); |
p_cur = p_next; |
} |
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) |
if (other.m_p_root == 0) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
if (base_type::m_p_root == 0) |
base_type::m_p_root = other.m_p_root; |
else if (Cmp_Fn::operator()(base_type::m_p_root->m_value, other.m_p_root->m_value)) |
{ |
base_type::make_child_of(base_type::m_p_root, other.m_p_root); |
PB_DS_ASSERT_NODE_CONSISTENT(other.m_p_root, false) |
base_type::m_p_root = other.m_p_root; |
} |
else |
{ |
base_type::make_child_of(other.m_p_root, base_type::m_p_root); |
PB_DS_ASSERT_NODE_CONSISTENT(base_type::m_p_root, false) |
} |
base_type::m_size += other.m_size; |
other.m_p_root = 0; |
other.m_size = 0; |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,214 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/constructors_destructor_fn_imps.hpp |
* Contains an implementation class for pat_trie. |
*/ |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::head_allocator |
PB_DS_CLASS_C_DEC::s_head_allocator; |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::inode_allocator |
PB_DS_CLASS_C_DEC::s_inode_allocator; |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::leaf_allocator |
PB_DS_CLASS_C_DEC::s_leaf_allocator; |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_PAT_TRIE_NAME() : |
m_p_head(s_head_allocator.allocate(1)), |
m_size(0) |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_PAT_TRIE_NAME(const access_traits& r_access_traits) : |
synth_access_traits(r_access_traits), |
m_p_head(s_head_allocator.allocate(1)), |
m_size(0) |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_PAT_TRIE_NAME(const PB_DS_CLASS_C_DEC& other) : |
#ifdef _GLIBCXX_DEBUG |
debug_base(other), |
#endif |
synth_access_traits(other), |
node_update(other), |
m_p_head(s_head_allocator.allocate(1)), |
m_size(0) |
{ |
initialize(); |
m_size = other.m_size; |
PB_DS_ASSERT_VALID(other) |
if (other.m_p_head->m_p_parent == 0) |
{ |
PB_DS_ASSERT_VALID((*this)) |
return; |
} |
__try |
{ |
m_p_head->m_p_parent = recursive_copy_node(other.m_p_head->m_p_parent); |
} |
__catch(...) |
{ |
s_head_allocator.deallocate(m_p_head, 1); |
__throw_exception_again; |
} |
m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); |
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); |
m_p_head->m_p_parent->m_p_parent = m_p_head; |
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) |
value_swap(other); |
std::swap((access_traits& )(*this), (access_traits& )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) |
{ |
_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_PAT_TRIE_NAME() |
{ |
clear(); |
s_head_allocator.deallocate(m_p_head, 1); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
initialize() |
{ |
new (m_p_head) head(); |
m_p_head->m_p_parent = 0; |
m_p_head->m_p_min = m_p_head; |
m_p_head->m_p_max = m_p_head; |
m_size = 0; |
} |
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 |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
recursive_copy_node(node_const_pointer p_ncp) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_ncp != 0); |
if (p_ncp->m_type == leaf_node) |
{ |
leaf_const_pointer p_other_lf = static_cast<leaf_const_pointer>(p_ncp); |
leaf_pointer p_new_lf = s_leaf_allocator.allocate(1); |
cond_dealtor cond(p_new_lf); |
new (p_new_lf) leaf(p_other_lf->value()); |
apply_update(p_new_lf, (node_update*)this); |
cond.set_no_action_dtor(); |
return (p_new_lf); |
} |
_GLIBCXX_DEBUG_ASSERT(p_ncp->m_type == i_node); |
node_pointer a_p_children[inode::arr_size]; |
size_type child_i = 0; |
inode_const_pointer p_icp = static_cast<inode_const_pointer>(p_ncp); |
typename inode::const_iterator child_it = p_icp->begin(); |
inode_pointer p_ret; |
__try |
{ |
while (child_it != p_icp->end()) |
{ |
a_p_children[child_i] = recursive_copy_node(*(child_it)); |
child_i++; |
child_it++; |
} |
p_ret = s_inode_allocator.allocate(1); |
} |
__catch(...) |
{ |
while (child_i-- > 0) |
clear_imp(a_p_children[child_i]); |
__throw_exception_again; |
} |
new (p_ret) inode(p_icp->get_e_ind(), pref_begin(a_p_children[0])); |
--child_i; |
_GLIBCXX_DEBUG_ASSERT(child_i >= 1); |
do |
p_ret->add_child(a_p_children[child_i], pref_begin(a_p_children[child_i]), |
pref_end(a_p_children[child_i]), this); |
while (child_i-- > 0); |
apply_update(p_ret, (node_update*)this); |
return p_ret; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp |
---|
0,0 → 1,115 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/debug_fn_imps.hpp |
* Contains an implementation class for pat_trie_. |
*/ |
#ifdef _GLIBCXX_DEBUG |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_valid(const char* __file, int __line) const |
{ |
if (m_p_head->m_p_parent != 0) |
m_p_head->m_p_parent->assert_valid(this, __file, __line); |
assert_iterators(__file, __line); |
assert_reverse_iterators(__file, __line); |
if (m_p_head->m_p_parent == 0) |
{ |
PB_DS_DEBUG_VERIFY(m_p_head->m_p_min == m_p_head); |
PB_DS_DEBUG_VERIFY(m_p_head->m_p_max == m_p_head); |
PB_DS_DEBUG_VERIFY(empty()); |
return; |
} |
PB_DS_DEBUG_VERIFY(m_p_head->m_p_min->m_type == leaf_node); |
PB_DS_DEBUG_VERIFY(m_p_head->m_p_max->m_type == leaf_node); |
PB_DS_DEBUG_VERIFY(!empty()); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_iterators(const char* __file, int __line) const |
{ |
size_type calc_size = 0; |
for (const_iterator it = begin(); it != end(); ++it) |
{ |
++calc_size; |
debug_base::check_key_exists(PB_DS_V2F(*it), __file, __line); |
PB_DS_DEBUG_VERIFY(lower_bound(PB_DS_V2F(*it)) == it); |
PB_DS_DEBUG_VERIFY(--upper_bound(PB_DS_V2F(*it)) == it); |
} |
PB_DS_DEBUG_VERIFY(calc_size == m_size); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_reverse_iterators(const char* __file, int __line) const |
{ |
size_type calc_size = 0; |
for (const_reverse_iterator it = rbegin(); it != rend(); ++it) |
{ |
++calc_size; |
node_const_pointer p_nd = |
const_cast<PB_DS_CLASS_C_DEC*>(this)->find_imp(PB_DS_V2F(*it)); |
PB_DS_DEBUG_VERIFY(p_nd == it.m_p_nd); |
} |
PB_DS_DEBUG_VERIFY(calc_size == m_size); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
recursive_count_leafs(node_const_pointer p_nd, const char* __file, int __line) |
{ |
if (p_nd == 0) |
return (0); |
if (p_nd->m_type == leaf_node) |
return (1); |
PB_DS_DEBUG_VERIFY(p_nd->m_type == i_node); |
size_type ret = 0; |
for (typename inode::const_iterator it = static_cast<inode_const_pointer>(p_nd)->begin(); |
it != static_cast<inode_const_pointer>(p_nd)->end(); |
++it) |
ret += recursive_count_leafs(*it, __file, __line); |
return ret; |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp |
---|
0,0 → 1,315 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/erase_fn_imps.hpp |
* Contains an implementation class for pat_trie. |
*/ |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
erase(key_const_reference r_key) |
{ |
node_pointer p_nd = find_imp(r_key); |
if (p_nd == 0 || p_nd->m_type == i_node) |
{ |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return false; |
} |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node); |
if (!synth_access_traits::equal_keys(PB_DS_V2F(reinterpret_cast<leaf_pointer>(p_nd)->value()), r_key)) |
{ |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return false; |
} |
PB_DS_CHECK_KEY_EXISTS(r_key) |
erase_leaf(static_cast<leaf_pointer>(p_nd)); |
PB_DS_ASSERT_VALID((*this)) |
return true; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
erase_fixup(inode_pointer p_nd) |
{ |
_GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) >= 1); |
if (std::distance(p_nd->begin(), p_nd->end()) == 1) |
{ |
node_pointer p_parent = p_nd->m_p_parent; |
if (p_parent == m_p_head) |
m_p_head->m_p_parent = *p_nd->begin(); |
else |
{ |
_GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node); |
node_pointer p_new_child = *p_nd->begin(); |
typedef inode_pointer inode_ptr; |
inode_ptr p_internal = static_cast<inode_ptr>(p_parent); |
p_internal->replace_child(p_new_child, pref_begin(p_new_child), |
pref_end(p_new_child), this); |
} |
(*p_nd->begin())->m_p_parent = p_nd->m_p_parent; |
p_nd->~inode(); |
s_inode_allocator.deallocate(p_nd, 1); |
if (p_parent == m_p_head) |
return; |
_GLIBCXX_DEBUG_ASSERT(p_parent->m_type == i_node); |
p_nd = static_cast<inode_pointer>(p_parent); |
} |
while (true) |
{ |
_GLIBCXX_DEBUG_ASSERT(std::distance(p_nd->begin(), p_nd->end()) > 1); |
p_nd->update_prefixes(this); |
apply_update(p_nd, (node_update*)this); |
PB_DS_ASSERT_NODE_VALID(p_nd) |
if (p_nd->m_p_parent->m_type == head_node) |
return; |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_parent->m_type == i_node); |
p_nd = static_cast<inode_pointer>(p_nd->m_p_parent); |
} |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
actual_erase_leaf(leaf_pointer p_l) |
{ |
_GLIBCXX_DEBUG_ASSERT(m_size > 0); |
--m_size; |
_GLIBCXX_DEBUG_ONLY(debug_base::erase_existing(PB_DS_V2F(p_l->value()))); |
p_l->~leaf(); |
s_leaf_allocator.deallocate(p_l, 1); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
clear() |
{ |
if (!empty()) |
{ |
clear_imp(m_p_head->m_p_parent); |
m_size = 0; |
initialize(); |
_GLIBCXX_DEBUG_ONLY(debug_base::clear();) |
PB_DS_ASSERT_VALID((*this)) |
} |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
clear_imp(node_pointer p_nd) |
{ |
if (p_nd->m_type == i_node) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); |
for (typename inode::iterator it = |
static_cast<inode_pointer>(p_nd)->begin(); |
it != static_cast<inode_pointer>(p_nd)->end(); |
++it) |
{ |
node_pointer p_child =* it; |
clear_imp(p_child); |
} |
s_inode_allocator.deallocate(static_cast<inode_pointer>(p_nd), 1); |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node); |
static_cast<leaf_pointer>(p_nd)->~leaf(); |
s_leaf_allocator.deallocate(static_cast<leaf_pointer>(p_nd), 1); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
erase(const_iterator it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (it == end()) |
return it; |
const_iterator ret_it = it; |
++ret_it; |
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node); |
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd)); |
PB_DS_ASSERT_VALID((*this)) |
return ret_it; |
} |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
erase(iterator it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (it == end()) |
return it; |
iterator ret_it = it; |
++ret_it; |
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node); |
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd)); |
PB_DS_ASSERT_VALID((*this)) |
return ret_it; |
} |
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_reverse_iterator |
PB_DS_CLASS_C_DEC:: |
erase(const_reverse_iterator it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (it.m_p_nd == m_p_head) |
return it; |
const_reverse_iterator ret_it = it; |
++ret_it; |
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node); |
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd)); |
PB_DS_ASSERT_VALID((*this)) |
return ret_it; |
} |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::reverse_iterator |
PB_DS_CLASS_C_DEC:: |
erase(reverse_iterator it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (it.m_p_nd == m_p_head) |
return it; |
reverse_iterator ret_it = it; |
++ret_it; |
_GLIBCXX_DEBUG_ASSERT(it.m_p_nd->m_type == leaf_node); |
erase_leaf(static_cast<leaf_pointer>(it.m_p_nd)); |
PB_DS_ASSERT_VALID((*this)) |
return ret_it; |
} |
#endif // #ifdef PB_DS_DATA_TRUE_INDICATOR |
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; |
PB_DS_ASSERT_VALID((*this)) |
iterator it = begin(); |
while (it != end()) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (pred(*it)) |
{ |
++num_ersd; |
it = erase(it); |
} |
else |
++it; |
} |
PB_DS_ASSERT_VALID((*this)) |
return num_ersd; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
erase_leaf(leaf_pointer p_l) |
{ |
update_min_max_for_erased_leaf(p_l); |
if (p_l->m_p_parent->m_type == head_node) |
{ |
_GLIBCXX_DEBUG_ASSERT(size() == 1); |
clear(); |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(size() > 1); |
_GLIBCXX_DEBUG_ASSERT(p_l->m_p_parent->m_type == i_node); |
inode_pointer p_parent = static_cast<inode_pointer>(p_l->m_p_parent); |
p_parent->remove_child(p_l); |
erase_fixup(p_parent); |
actual_erase_leaf(p_l); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
update_min_max_for_erased_leaf(leaf_pointer p_l) |
{ |
if (m_size == 1) |
{ |
m_p_head->m_p_min = m_p_head; |
m_p_head->m_p_max = m_p_head; |
return; |
} |
if (p_l == static_cast<leaf_const_pointer>(m_p_head->m_p_min)) |
{ |
iterator it(p_l); |
++it; |
m_p_head->m_p_min = it.m_p_nd; |
return; |
} |
if (p_l == static_cast<leaf_const_pointer>(m_p_head->m_p_max)) |
{ |
iterator it(p_l); |
--it; |
m_p_head->m_p_max = it.m_p_nd; |
} |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp |
---|
0,0 → 1,269 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/find_fn_imps.hpp |
* Contains an implementation class for pat_trie. |
*/ |
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)) |
node_pointer p_nd = find_imp(r_key); |
if (p_nd == 0 || p_nd->m_type != leaf_node) |
{ |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return end(); |
} |
if (synth_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_nd)->value()), r_key)) |
{ |
PB_DS_CHECK_KEY_EXISTS(r_key) |
return iterator(p_nd); |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return end(); |
} |
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)) |
node_const_pointer p_nd = const_cast<PB_DS_CLASS_C_DEC* >(this)->find_imp(r_key); |
if (p_nd == 0 || p_nd->m_type != leaf_node) |
{ |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return end(); |
} |
if (synth_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()), r_key)) |
{ |
PB_DS_CHECK_KEY_EXISTS(r_key) |
return const_iterator(const_cast<node_pointer>(p_nd)); |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(r_key) |
return end(); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
find_imp(key_const_reference r_key) |
{ |
if (empty()) |
return 0; |
typename synth_access_traits::const_iterator b_it = |
synth_access_traits::begin(r_key); |
typename synth_access_traits::const_iterator e_it = |
synth_access_traits::end(r_key); |
node_pointer p_nd = m_p_head->m_p_parent; |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
while (p_nd->m_type != leaf_node) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); |
node_pointer p_next_nd = static_cast<inode_pointer>(p_nd)->get_child_node(b_it, e_it, this); |
if (p_next_nd == 0) |
return p_nd; |
p_nd = p_next_nd; |
} |
return p_nd; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
lower_bound_imp(key_const_reference r_key) |
{ |
if (empty()) |
return (m_p_head); |
node_pointer p_nd = m_p_head->m_p_parent; |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
typename PB_DS_CLASS_C_DEC::a_const_iterator b_it = |
synth_access_traits::begin(r_key); |
typename PB_DS_CLASS_C_DEC::a_const_iterator e_it = |
synth_access_traits::end(r_key); |
size_type checked_ind = 0; |
while (true) |
{ |
if (p_nd->m_type == leaf_node) |
{ |
if (!synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()), r_key)) |
return p_nd; |
iterator it(p_nd); |
++it; |
return it.m_p_nd; |
} |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); |
const size_type new_checked_ind = |
static_cast<inode_pointer>(p_nd)->get_e_ind(); |
p_nd = |
static_cast<inode_pointer>(p_nd)->get_lower_bound_child_node( b_it, e_it, checked_ind, this); |
checked_ind = new_checked_ind; |
} |
} |
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) |
{ return point_iterator(lower_bound_imp(r_key)); } |
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 |
{ |
return point_const_iterator(const_cast<PB_DS_CLASS_C_DEC* >(this)->lower_bound_imp(r_key)); |
} |
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) |
{ |
point_iterator l_bound_it = lower_bound(r_key); |
_GLIBCXX_DEBUG_ASSERT(l_bound_it == end() || |
!synth_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it), |
r_key)); |
if (l_bound_it == end() || |
synth_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it))) |
return l_bound_it; |
return ++l_bound_it; |
} |
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 |
{ |
point_const_iterator l_bound_it = lower_bound(r_key); |
_GLIBCXX_DEBUG_ASSERT(l_bound_it == end() || |
!synth_access_traits::cmp_keys(PB_DS_V2F(*l_bound_it), |
r_key)); |
if (l_bound_it == end() || |
synth_access_traits::cmp_keys(r_key, PB_DS_V2F(*l_bound_it))) |
return l_bound_it; |
return ++l_bound_it; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::a_const_iterator |
PB_DS_CLASS_C_DEC:: |
pref_begin(node_const_pointer p_nd) |
{ |
if (p_nd->m_type == leaf_node) |
return (synth_access_traits::begin(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()))); |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); |
return static_cast<inode_const_pointer>(p_nd)->pref_b_it(); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::a_const_iterator |
PB_DS_CLASS_C_DEC:: |
pref_end(node_const_pointer p_nd) |
{ |
if (p_nd->m_type == leaf_node) |
return (synth_access_traits::end(PB_DS_V2F(static_cast<leaf_const_pointer>(p_nd)->value()))); |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); |
return static_cast<inode_const_pointer>(p_nd)->pref_e_it(); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer |
PB_DS_CLASS_C_DEC:: |
leftmost_descendant(node_const_pointer p_nd) |
{ |
if (p_nd->m_type == leaf_node) |
return static_cast<leaf_const_pointer>(p_nd); |
return static_cast<inode_const_pointer>(p_nd)->leftmost_descendant(); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::leaf_pointer |
PB_DS_CLASS_C_DEC:: |
leftmost_descendant(node_pointer p_nd) |
{ |
if (p_nd->m_type == leaf_node) |
return static_cast<leaf_pointer>(p_nd); |
return static_cast<inode_pointer>(p_nd)->leftmost_descendant(); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::leaf_const_pointer |
PB_DS_CLASS_C_DEC:: |
rightmost_descendant(node_const_pointer p_nd) |
{ |
if (p_nd->m_type == leaf_node) |
return static_cast<leaf_const_pointer>(p_nd); |
return static_cast<inode_const_pointer>(p_nd)->rightmost_descendant(); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::leaf_pointer |
PB_DS_CLASS_C_DEC:: |
rightmost_descendant(node_pointer p_nd) |
{ |
if (p_nd->m_type == leaf_node) |
return static_cast<leaf_pointer>(p_nd); |
return static_cast<inode_pointer>(p_nd)->rightmost_descendant(); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp |
---|
0,0 → 1,58 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/info_fn_imps.hpp |
* Contains an implementation class for pat_trie. |
*/ |
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_inode_allocator.max_size(); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp |
---|
0,0 → 1,472 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/insert_join_fn_imps.hpp |
* Contains an implementation class for pat_trie. |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
join(PB_DS_CLASS_C_DEC& other) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
branch_bag bag; |
if (!join_prep(other, bag)) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent, |
other.m_p_head->m_p_parent, 0, bag); |
m_p_head->m_p_parent->m_p_parent = m_p_head; |
m_size += other.m_size; |
other.initialize(); |
PB_DS_ASSERT_VALID(other) |
m_p_head->m_p_min = leftmost_descendant(m_p_head->m_p_parent); |
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
bool |
PB_DS_CLASS_C_DEC:: |
join_prep(PB_DS_CLASS_C_DEC& other, branch_bag& r_bag) |
{ |
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 = |
synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value()), |
PB_DS_V2F(static_cast<leaf_const_pointer>(other.m_p_head->m_p_min)->value())); |
const bool lesser = |
synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(other.m_p_head->m_p_max)->value()), |
PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value())); |
if (!greater && !lesser) |
__throw_join_error(); |
rec_join_prep(m_p_head->m_p_parent, other.m_p_head->m_p_parent, r_bag); |
_GLIBCXX_DEBUG_ONLY(debug_base::join(other, false);) |
return true; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
rec_join_prep(node_const_pointer p_l, node_const_pointer p_r, |
branch_bag& r_bag) |
{ |
if (p_l->m_type == leaf_node) |
{ |
if (p_r->m_type == leaf_node) |
{ |
rec_join_prep(static_cast<leaf_const_pointer>(p_l), |
static_cast<leaf_const_pointer>(p_r), r_bag); |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node); |
rec_join_prep(static_cast<leaf_const_pointer>(p_l), |
static_cast<inode_const_pointer>(p_r), r_bag); |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(p_l->m_type == i_node); |
if (p_r->m_type == leaf_node) |
{ |
rec_join_prep(static_cast<inode_const_pointer>(p_l), |
static_cast<leaf_const_pointer>(p_r), r_bag); |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node); |
rec_join_prep(static_cast<inode_const_pointer>(p_l), |
static_cast<inode_const_pointer>(p_r), r_bag); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
rec_join_prep(leaf_const_pointer /*p_l*/, leaf_const_pointer /*p_r*/, |
branch_bag& r_bag) |
{ r_bag.add_branch(); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
rec_join_prep(leaf_const_pointer /*p_l*/, inode_const_pointer /*p_r*/, |
branch_bag& r_bag) |
{ r_bag.add_branch(); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
rec_join_prep(inode_const_pointer /*p_l*/, leaf_const_pointer /*p_r*/, |
branch_bag& r_bag) |
{ r_bag.add_branch(); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
rec_join_prep(inode_const_pointer p_l, inode_const_pointer p_r, |
branch_bag& r_bag) |
{ |
if (p_l->get_e_ind() == p_r->get_e_ind() && |
synth_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(), |
p_r->pref_b_it(), p_r->pref_e_it())) |
{ |
for (typename inode::const_iterator it = p_r->begin(); |
it != p_r->end(); ++ it) |
{ |
node_const_pointer p_l_join_child = p_l->get_join_child(*it, this); |
if (p_l_join_child != 0) |
rec_join_prep(p_l_join_child, * it, r_bag); |
} |
return; |
} |
if (p_r->get_e_ind() < p_l->get_e_ind() && |
p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this)) |
{ |
node_const_pointer p_r_join_child = p_r->get_join_child(p_l, this); |
if (p_r_join_child != 0) |
rec_join_prep(p_r_join_child, p_l, r_bag); |
return; |
} |
if (p_r->get_e_ind() < p_l->get_e_ind() && |
p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this)) |
{ |
node_const_pointer p_r_join_child = p_r->get_join_child(p_l, this); |
if (p_r_join_child != 0) |
rec_join_prep(p_r_join_child, p_l, r_bag); |
return; |
} |
r_bag.add_branch(); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
rec_join(node_pointer p_l, node_pointer p_r, size_type checked_ind, |
branch_bag& r_bag) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_r != 0); |
if (p_l == 0) |
{ |
apply_update(p_r, (node_update*)this); |
return (p_r); |
} |
if (p_l->m_type == leaf_node) |
{ |
if (p_r->m_type == leaf_node) |
{ |
node_pointer p_ret = rec_join(static_cast<leaf_pointer>(p_l), |
static_cast<leaf_pointer>(p_r), r_bag); |
apply_update(p_ret, (node_update*)this); |
return p_ret; |
} |
_GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node); |
node_pointer p_ret = rec_join(static_cast<leaf_pointer>(p_l), |
static_cast<inode_pointer>(p_r), |
checked_ind, r_bag); |
apply_update(p_ret, (node_update*)this); |
return p_ret; |
} |
_GLIBCXX_DEBUG_ASSERT(p_l->m_type == i_node); |
if (p_r->m_type == leaf_node) |
{ |
node_pointer p_ret = rec_join(static_cast<inode_pointer>(p_l), |
static_cast<leaf_pointer>(p_r), |
checked_ind, r_bag); |
apply_update(p_ret, (node_update*)this); |
return p_ret; |
} |
_GLIBCXX_DEBUG_ASSERT(p_r->m_type == i_node); |
node_pointer p_ret = rec_join(static_cast<inode_pointer>(p_l), |
static_cast<inode_pointer>(p_r), |
r_bag); |
apply_update(p_ret, (node_update*)this); |
return p_ret; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
rec_join(leaf_pointer p_l, leaf_pointer p_r, branch_bag& r_bag) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_r != 0); |
if (p_l == 0) |
return (p_r); |
node_pointer p_ret = insert_branch(p_l, p_r, r_bag); |
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == 2); |
return p_ret; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
rec_join(leaf_pointer p_l, inode_pointer p_r, size_type checked_ind, |
branch_bag& r_bag) |
{ |
#ifdef _GLIBCXX_DEBUG |
const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l); |
const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r); |
#endif |
_GLIBCXX_DEBUG_ASSERT(p_r != 0); |
node_pointer p_ret = rec_join(p_r, p_l, checked_ind, r_bag); |
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs); |
return p_ret; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
rec_join(inode_pointer p_l, leaf_pointer p_r, size_type checked_ind, branch_bag& r_bag) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_l != 0); |
_GLIBCXX_DEBUG_ASSERT(p_r != 0); |
#ifdef _GLIBCXX_DEBUG |
const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l); |
const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r); |
#endif |
if (!p_l->should_be_mine(pref_begin(p_r), pref_end(p_r), checked_ind, this)) |
{ |
node_pointer p_ret = insert_branch(p_l, p_r, r_bag); |
PB_DS_ASSERT_NODE_VALID(p_ret) |
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == |
lhs_leafs + rhs_leafs); |
return p_ret; |
} |
node_pointer p_pot_child = p_l->add_child(p_r, pref_begin(p_r), |
pref_end(p_r), this); |
if (p_pot_child != p_r) |
{ |
node_pointer p_new_child = rec_join(p_pot_child, p_r, p_l->get_e_ind(), |
r_bag); |
p_l->replace_child(p_new_child, pref_begin(p_new_child), |
pref_end(p_new_child), this); |
} |
PB_DS_ASSERT_NODE_VALID(p_l) |
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs); |
return p_l; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
rec_join(inode_pointer p_l, inode_pointer p_r, |
branch_bag& r_bag) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_l != 0); |
_GLIBCXX_DEBUG_ASSERT(p_r != 0); |
#ifdef _GLIBCXX_DEBUG |
const size_type lhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_l); |
const size_type rhs_leafs = PB_DS_RECURSIVE_COUNT_LEAFS(p_r); |
#endif |
if (p_l->get_e_ind() == p_r->get_e_ind() && |
synth_access_traits::equal_prefixes(p_l->pref_b_it(), p_l->pref_e_it(), |
p_r->pref_b_it(), p_r->pref_e_it())) |
{ |
for (typename inode::iterator it = p_r->begin(); |
it != p_r->end(); ++ it) |
{ |
node_pointer p_new_child = rec_join(p_l->get_join_child(*it, this), |
* it, 0, r_bag); |
p_l->replace_child(p_new_child, pref_begin(p_new_child), |
pref_end(p_new_child), this); |
} |
p_r->~inode(); |
s_inode_allocator.deallocate(p_r, 1); |
PB_DS_ASSERT_NODE_VALID(p_l) |
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_l) == lhs_leafs + rhs_leafs); |
return p_l; |
} |
if (p_l->get_e_ind() < p_r->get_e_ind() && |
p_l->should_be_mine(p_r->pref_b_it(), p_r->pref_e_it(), 0, this)) |
{ |
node_pointer p_new_child = rec_join(p_l->get_join_child(p_r, this), |
p_r, 0, r_bag); |
p_l->replace_child(p_new_child, pref_begin(p_new_child), |
pref_end(p_new_child), this); |
PB_DS_ASSERT_NODE_VALID(p_l) |
return p_l; |
} |
if (p_r->get_e_ind() < p_l->get_e_ind() && |
p_r->should_be_mine(p_l->pref_b_it(), p_l->pref_e_it(), 0, this)) |
{ |
node_pointer p_new_child = rec_join(p_r->get_join_child(p_l, this), p_l, |
0, r_bag); |
p_r->replace_child(p_new_child, pref_begin(p_new_child), |
pref_end(p_new_child), this); |
PB_DS_ASSERT_NODE_VALID(p_r) |
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_r) == lhs_leafs + rhs_leafs); |
return p_r; |
} |
node_pointer p_ret = insert_branch(p_l, p_r, r_bag); |
PB_DS_ASSERT_NODE_VALID(p_ret) |
_GLIBCXX_DEBUG_ASSERT(PB_DS_RECURSIVE_COUNT_LEAFS(p_ret) == lhs_leafs + rhs_leafs); |
return p_ret; |
} |
PB_DS_CLASS_T_DEC |
inline std::pair<typename PB_DS_CLASS_C_DEC::iterator, bool> |
PB_DS_CLASS_C_DEC:: |
insert(const_reference r_val) |
{ |
node_pointer p_lf = find_imp(PB_DS_V2F(r_val)); |
if (p_lf != 0 && p_lf->m_type == leaf_node && |
synth_access_traits::equal_keys(PB_DS_V2F(static_cast<leaf_pointer>(p_lf)->value()), PB_DS_V2F(r_val))) |
{ |
PB_DS_CHECK_KEY_EXISTS(PB_DS_V2F(r_val)) |
PB_DS_ASSERT_VALID((*this)) |
return std::make_pair(iterator(p_lf), false); |
} |
PB_DS_CHECK_KEY_DOES_NOT_EXIST(PB_DS_V2F(r_val)) |
leaf_pointer p_new_lf = s_leaf_allocator.allocate(1); |
cond_dealtor cond(p_new_lf); |
new (p_new_lf) leaf(r_val); |
apply_update(p_new_lf, (node_update*)this); |
cond.set_call_destructor(); |
branch_bag bag; |
bag.add_branch(); |
m_p_head->m_p_parent = rec_join(m_p_head->m_p_parent, p_new_lf, 0, bag); |
m_p_head->m_p_parent->m_p_parent = m_p_head; |
cond.set_no_action_dtor(); |
++m_size; |
update_min_max_for_inserted_leaf(p_new_lf); |
_GLIBCXX_DEBUG_ONLY(debug_base::insert_new(PB_DS_V2F(r_val));) |
PB_DS_ASSERT_VALID((*this)) |
return std::make_pair(point_iterator(p_new_lf), true); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
keys_diff_ind(typename access_traits::const_iterator b_l, |
typename access_traits::const_iterator e_l, |
typename access_traits::const_iterator b_r, |
typename access_traits::const_iterator e_r) |
{ |
size_type diff_pos = 0; |
while (b_l != e_l) |
{ |
if (b_r == e_r) |
return (diff_pos); |
if (access_traits::e_pos(*b_l) != access_traits::e_pos(*b_r)) |
return (diff_pos); |
++b_l; |
++b_r; |
++diff_pos; |
} |
_GLIBCXX_DEBUG_ASSERT(b_r != e_r); |
return diff_pos; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::inode_pointer |
PB_DS_CLASS_C_DEC:: |
insert_branch(node_pointer p_l, node_pointer p_r, branch_bag& r_bag) |
{ |
typename synth_access_traits::const_iterator left_b_it = pref_begin(p_l); |
typename synth_access_traits::const_iterator left_e_it = pref_end(p_l); |
typename synth_access_traits::const_iterator right_b_it = pref_begin(p_r); |
typename synth_access_traits::const_iterator right_e_it = pref_end(p_r); |
const size_type diff_ind = keys_diff_ind(left_b_it, left_e_it, |
right_b_it, right_e_it); |
inode_pointer p_new_nd = r_bag.get_branch(); |
new (p_new_nd) inode(diff_ind, left_b_it); |
p_new_nd->add_child(p_l, left_b_it, left_e_it, this); |
p_new_nd->add_child(p_r, right_b_it, right_e_it, this); |
p_l->m_p_parent = p_new_nd; |
p_r->m_p_parent = p_new_nd; |
PB_DS_ASSERT_NODE_VALID(p_new_nd) |
return (p_new_nd); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
update_min_max_for_inserted_leaf(leaf_pointer p_new_lf) |
{ |
if (m_p_head->m_p_min == m_p_head || |
synth_access_traits::cmp_keys(PB_DS_V2F(p_new_lf->value()), |
PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value()))) |
m_p_head->m_p_min = p_new_lf; |
if (m_p_head->m_p_max == m_p_head || |
synth_access_traits::cmp_keys(PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value()), PB_DS_V2F(p_new_lf->value()))) |
m_p_head->m_p_max = p_new_lf; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp |
---|
0,0 → 1,120 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/iterators_fn_imps.hpp |
* Contains an implementation class for pat_trie. |
*/ |
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_min); } |
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_min); } |
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 |
{ |
if (empty()) |
return rend(); |
return --end(); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::reverse_iterator |
PB_DS_CLASS_C_DEC:: |
rbegin() |
{ |
if (empty()) |
return rend(); |
return --end(); |
} |
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, this); } |
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, this); } |
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, this); } |
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, this); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp |
---|
0,0 → 1,596 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/pat_trie_.hpp |
* Contains an implementation class for a patricia tree. |
*/ |
#include <iterator> |
#include <utility> |
#include <algorithm> |
#include <functional> |
#include <assert.h> |
#include <list> |
#include <ext/pb_ds/exception.hpp> |
#include <ext/pb_ds/tag_and_trait.hpp> |
#include <ext/pb_ds/tree_policy.hpp> |
#include <ext/pb_ds/detail/cond_dealtor.hpp> |
#include <ext/pb_ds/detail/type_utils.hpp> |
#include <ext/pb_ds/detail/types_traits.hpp> |
#include <ext/pb_ds/detail/eq_fn/eq_by_less.hpp> |
#include <ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp> |
#include <ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp> |
#ifdef _GLIBCXX_DEBUG |
#include <ext/pb_ds/detail/debug_map_base.hpp> |
#endif |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
#define PB_DS_PAT_TRIE_NAME pat_trie_map |
#endif |
#ifdef PB_DS_DATA_FALSE_INDICATOR |
#define PB_DS_PAT_TRIE_NAME pat_trie_set |
#endif |
#define PB_DS_CLASS_T_DEC \ |
template<typename Key, typename Mapped, typename Node_And_It_Traits, \ |
typename _Alloc> |
#define PB_DS_CLASS_C_DEC \ |
PB_DS_PAT_TRIE_NAME<Key, Mapped, Node_And_It_Traits, _Alloc> |
#define PB_DS_PAT_TRIE_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, std::less<Key> >, \ |
typename _Alloc::template rebind<Key>::other::const_reference> |
#endif |
/** |
* @brief PATRICIA trie. |
* @ingroup branch-detail |
* |
* This implementation loosely borrows ideas from: |
* 1) Fast Mergeable Integer Maps, Okasaki, Gill 1998 |
* 2) Ptset: Sets of integers implemented as Patricia trees, |
* Jean-Christophe Filliatr, 2000 |
*/ |
template<typename Key, typename Mapped, typename Node_And_It_Traits, |
typename _Alloc> |
class PB_DS_PAT_TRIE_NAME : |
#ifdef _GLIBCXX_DEBUG |
public PB_DS_DEBUG_MAP_BASE_C_DEC, |
#endif |
public Node_And_It_Traits::synth_access_traits, |
public Node_And_It_Traits::node_update, |
public PB_DS_PAT_TRIE_TRAITS_BASE, |
public pat_trie_base |
{ |
private: |
typedef pat_trie_base base_type; |
typedef PB_DS_PAT_TRIE_TRAITS_BASE traits_base; |
typedef Node_And_It_Traits traits_type; |
typedef typename traits_type::synth_access_traits synth_access_traits; |
typedef typename synth_access_traits::const_iterator a_const_iterator; |
typedef typename traits_type::node node; |
typedef typename _Alloc::template rebind<node> __rebind_n; |
typedef typename __rebind_n::other::const_pointer node_const_pointer; |
typedef typename __rebind_n::other::pointer node_pointer; |
typedef typename traits_type::head head; |
typedef typename _Alloc::template rebind<head> __rebind_h; |
typedef typename __rebind_h::other head_allocator; |
typedef typename head_allocator::pointer head_pointer; |
typedef typename traits_type::leaf leaf; |
typedef typename _Alloc::template rebind<leaf> __rebind_l; |
typedef typename __rebind_l::other leaf_allocator; |
typedef typename leaf_allocator::pointer leaf_pointer; |
typedef typename leaf_allocator::const_pointer leaf_const_pointer; |
typedef typename traits_type::inode inode; |
typedef typename inode::iterator inode_iterator; |
typedef typename _Alloc::template rebind<inode> __rebind_in; |
typedef typename __rebind_in::other __rebind_ina; |
typedef typename __rebind_in::other inode_allocator; |
typedef typename __rebind_ina::pointer inode_pointer; |
typedef typename __rebind_ina::const_pointer inode_const_pointer; |
/// Conditional deallocator. |
class cond_dealtor |
{ |
protected: |
leaf_pointer m_p_nd; |
bool m_no_action_dtor; |
bool m_call_destructor; |
public: |
cond_dealtor(leaf_pointer p_nd) |
: m_p_nd(p_nd), m_no_action_dtor(false), m_call_destructor(false) |
{ } |
void |
set_no_action_dtor() |
{ m_no_action_dtor = true; } |
void |
set_call_destructor() |
{ m_call_destructor = true; } |
~cond_dealtor() |
{ |
if (m_no_action_dtor) |
return; |
if (m_call_destructor) |
m_p_nd->~leaf(); |
s_leaf_allocator.deallocate(m_p_nd, 1); |
} |
}; |
/// Branch bag, for split-join. |
class branch_bag |
{ |
private: |
typedef inode_pointer __inp; |
typedef typename _Alloc::template rebind<__inp>::other __rebind_inp; |
#ifdef _GLIBCXX_DEBUG |
typedef std::_GLIBCXX_STD_C::list<__inp, __rebind_inp> bag_type; |
#else |
typedef std::list<__inp, __rebind_inp> bag_type; |
#endif |
bag_type m_bag; |
public: |
void |
add_branch() |
{ |
inode_pointer p_nd = s_inode_allocator.allocate(1); |
__try |
{ |
m_bag.push_back(p_nd); |
} |
__catch(...) |
{ |
s_inode_allocator.deallocate(p_nd, 1); |
__throw_exception_again; |
} |
} |
inode_pointer |
get_branch() |
{ |
_GLIBCXX_DEBUG_ASSERT(!m_bag.empty()); |
inode_pointer p_nd = *m_bag.begin(); |
m_bag.pop_front(); |
return p_nd; |
} |
~branch_bag() |
{ |
while (!m_bag.empty()) |
{ |
inode_pointer p_nd = *m_bag.begin(); |
s_inode_allocator.deallocate(p_nd, 1); |
m_bag.pop_front(); |
} |
} |
inline bool |
empty() const |
{ return m_bag.empty(); } |
}; |
#ifdef _GLIBCXX_DEBUG |
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base; |
#endif |
typedef typename traits_type::null_node_update_pointer null_node_update_pointer; |
public: |
typedef pat_trie_tag container_category; |
typedef _Alloc allocator_type; |
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; |
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; |
typedef typename traits_type::access_traits access_traits; |
typedef typename traits_type::const_iterator point_const_iterator; |
typedef typename traits_type::iterator point_iterator; |
typedef point_const_iterator const_iterator; |
typedef point_iterator iterator; |
typedef typename traits_type::reverse_iterator reverse_iterator; |
typedef typename traits_type::const_reverse_iterator const_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; |
PB_DS_PAT_TRIE_NAME(); |
PB_DS_PAT_TRIE_NAME(const access_traits&); |
PB_DS_PAT_TRIE_NAME(const PB_DS_CLASS_C_DEC&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
~PB_DS_PAT_TRIE_NAME(); |
inline bool |
empty() const; |
inline size_type |
size() const; |
inline size_type |
max_size() const; |
access_traits& |
get_access_traits(); |
const access_traits& |
get_access_traits() const; |
node_update& |
get_node_update(); |
const node_update& |
get_node_update() const; |
inline std::pair<point_iterator, bool> |
insert(const_reference); |
inline mapped_reference |
operator[](key_const_reference r_key) |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
return insert(std::make_pair(r_key, mapped_type())).first->second; |
#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 |
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; |
void |
clear(); |
inline bool |
erase(key_const_reference); |
inline const_iterator |
erase(const_iterator); |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
inline iterator |
erase(iterator); |
#endif |
inline const_reverse_iterator |
erase(const_reverse_iterator); |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
inline reverse_iterator |
erase(reverse_iterator); |
#endif |
template<typename Pred> |
inline size_type |
erase_if(Pred); |
void |
join(PB_DS_CLASS_C_DEC&); |
void |
split(key_const_reference, PB_DS_CLASS_C_DEC&); |
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(); |
#ifdef PB_DS_PAT_TRIE_TRACE_ |
void |
trace() const; |
#endif |
protected: |
template<typename It> |
void |
copy_from_range(It, It); |
void |
value_swap(PB_DS_CLASS_C_DEC&); |
node_pointer |
recursive_copy_node(node_const_pointer); |
private: |
void |
initialize(); |
inline void |
apply_update(node_pointer, null_node_update_pointer); |
template<typename Node_Update_> |
inline void |
apply_update(node_pointer, Node_Update_*); |
bool |
join_prep(PB_DS_CLASS_C_DEC&, branch_bag&); |
void |
rec_join_prep(node_const_pointer, node_const_pointer, branch_bag&); |
void |
rec_join_prep(leaf_const_pointer, leaf_const_pointer, branch_bag&); |
void |
rec_join_prep(leaf_const_pointer, inode_const_pointer, branch_bag&); |
void |
rec_join_prep(inode_const_pointer, leaf_const_pointer, branch_bag&); |
void |
rec_join_prep(inode_const_pointer, inode_const_pointer, branch_bag&); |
node_pointer |
rec_join(node_pointer, node_pointer, size_type, branch_bag&); |
node_pointer |
rec_join(leaf_pointer, leaf_pointer, branch_bag&); |
node_pointer |
rec_join(leaf_pointer, inode_pointer, size_type, branch_bag&); |
node_pointer |
rec_join(inode_pointer, leaf_pointer, size_type, branch_bag&); |
node_pointer |
rec_join(inode_pointer, inode_pointer, branch_bag&); |
size_type |
keys_diff_ind(typename access_traits::const_iterator, |
typename access_traits::const_iterator, |
typename access_traits::const_iterator, |
typename access_traits::const_iterator); |
inode_pointer |
insert_branch(node_pointer, node_pointer, branch_bag&); |
void |
update_min_max_for_inserted_leaf(leaf_pointer); |
void |
erase_leaf(leaf_pointer); |
inline void |
actual_erase_leaf(leaf_pointer); |
void |
clear_imp(node_pointer); |
void |
erase_fixup(inode_pointer); |
void |
update_min_max_for_erased_leaf(leaf_pointer); |
static inline a_const_iterator |
pref_begin(node_const_pointer); |
static inline a_const_iterator |
pref_end(node_const_pointer); |
inline node_pointer |
find_imp(key_const_reference); |
inline node_pointer |
lower_bound_imp(key_const_reference); |
inline node_pointer |
upper_bound_imp(key_const_reference); |
inline static leaf_const_pointer |
leftmost_descendant(node_const_pointer); |
inline static leaf_pointer |
leftmost_descendant(node_pointer); |
inline static leaf_const_pointer |
rightmost_descendant(node_const_pointer); |
inline static leaf_pointer |
rightmost_descendant(node_pointer); |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char*, int) const; |
void |
assert_iterators(const char*, int) const; |
void |
assert_reverse_iterators(const char*, int) const; |
static size_type |
recursive_count_leafs(node_const_pointer, const char*, int); |
#endif |
#ifdef PB_DS_PAT_TRIE_TRACE_ |
static void |
trace_node(node_const_pointer, size_type); |
template<typename Metadata_> |
static void |
trace_node_metadata(node_const_pointer, type_to_type<Metadata_>); |
static void |
trace_node_metadata(node_const_pointer, type_to_type<null_type>); |
#endif |
leaf_pointer |
split_prep(key_const_reference, PB_DS_CLASS_C_DEC&, branch_bag&); |
node_pointer |
rec_split(node_pointer, a_const_iterator, a_const_iterator, |
PB_DS_CLASS_C_DEC&, branch_bag&); |
void |
split_insert_branch(size_type, a_const_iterator, inode_iterator, |
size_type, branch_bag&); |
static head_allocator s_head_allocator; |
static inode_allocator s_inode_allocator; |
static leaf_allocator s_leaf_allocator; |
head_pointer m_p_head; |
size_type m_size; |
}; |
#define PB_DS_ASSERT_NODE_VALID(X) \ |
_GLIBCXX_DEBUG_ONLY(X->assert_valid(this, __FILE__, __LINE__);) |
#define PB_DS_RECURSIVE_COUNT_LEAFS(X) \ |
recursive_count_leafs(X, __FILE__, __LINE__) |
#include <ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp> |
#include <ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp> |
#undef PB_DS_RECURSIVE_COUNT_LEAFS |
#undef PB_DS_ASSERT_NODE_VALID |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_PAT_TRIE_NAME |
#undef PB_DS_PAT_TRIE_TRAITS_BASE |
#undef PB_DS_DEBUG_MAP_BASE_C_DEC |
} // namespace detail |
} // namespace __gnu_pbds |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp |
---|
0,0 → 1,1361 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/pat_trie_base.hpp |
* Contains the base class for a patricia tree. |
*/ |
#ifndef PB_DS_PAT_TRIE_BASE |
#define PB_DS_PAT_TRIE_BASE |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Base type for PATRICIA trees. |
struct pat_trie_base |
{ |
/** |
* @brief Three types of nodes. |
* |
* i_node is used by _Inode, leaf_node by _Leaf, and head_node by _Head. |
*/ |
enum node_type |
{ |
i_node, |
leaf_node, |
head_node |
}; |
/// Metadata base primary template. |
template<typename Metadata, typename _Alloc> |
struct _Metadata |
{ |
typedef Metadata metadata_type; |
typedef _Alloc allocator_type; |
typedef typename _Alloc::template rebind<Metadata> __rebind_m; |
typedef typename __rebind_m::other::const_reference const_reference; |
const_reference |
get_metadata() const |
{ return m_metadata; } |
metadata_type m_metadata; |
}; |
/// Specialization for null metadata. |
template<typename _Alloc> |
struct _Metadata<null_type, _Alloc> |
{ |
typedef null_type metadata_type; |
typedef _Alloc allocator_type; |
}; |
/// Node base. |
template<typename _ATraits, typename Metadata> |
struct _Node_base |
: public Metadata |
{ |
private: |
typedef typename Metadata::allocator_type _Alloc; |
public: |
typedef _Alloc allocator_type; |
typedef _ATraits access_traits; |
typedef typename _ATraits::type_traits type_traits; |
typedef typename _Alloc::template rebind<_Node_base> __rebind_n; |
typedef typename __rebind_n::other::pointer node_pointer; |
node_pointer m_p_parent; |
const node_type m_type; |
_Node_base(node_type type) : m_type(type) |
{ } |
typedef typename _Alloc::template rebind<_ATraits> __rebind_at; |
typedef typename __rebind_at::other::const_pointer a_const_pointer; |
typedef typename _ATraits::const_iterator a_const_iterator; |
#ifdef _GLIBCXX_DEBUG |
typedef std::pair<a_const_iterator, a_const_iterator> node_debug_info; |
void |
assert_valid(a_const_pointer p_traits, |
const char* __file, int __line) const |
{ assert_valid_imp(p_traits, __file, __line); } |
virtual node_debug_info |
assert_valid_imp(a_const_pointer, const char*, int) const = 0; |
#endif |
}; |
/// Head node for PATRICIA tree. |
template<typename _ATraits, typename Metadata> |
struct _Head |
: public _Node_base<_ATraits, Metadata> |
{ |
typedef _Node_base<_ATraits, Metadata> base_type; |
typedef typename base_type::type_traits type_traits; |
typedef typename base_type::node_pointer node_pointer; |
node_pointer m_p_min; |
node_pointer m_p_max; |
_Head() : base_type(head_node) { } |
#ifdef _GLIBCXX_DEBUG |
typedef typename base_type::node_debug_info node_debug_info; |
typedef typename base_type::a_const_pointer a_const_pointer; |
virtual node_debug_info |
assert_valid_imp(a_const_pointer, const char* __file, int __line) const |
{ |
_GLIBCXX_DEBUG_VERIFY_AT(false, |
_M_message("Assertion from %1;:%2;") |
._M_string(__FILE__)._M_integer(__LINE__), |
__file, __line); |
return node_debug_info(); |
} |
#endif |
}; |
/// Leaf node for PATRICIA tree. |
template<typename _ATraits, typename Metadata> |
struct _Leaf |
: public _Node_base<_ATraits, Metadata> |
{ |
typedef _Node_base<_ATraits, Metadata> base_type; |
typedef typename base_type::type_traits type_traits; |
typedef typename type_traits::value_type value_type; |
typedef typename type_traits::reference reference; |
typedef typename type_traits::const_reference const_reference; |
private: |
value_type m_value; |
_Leaf(const _Leaf&); |
public: |
_Leaf(const_reference other) |
: base_type(leaf_node), m_value(other) { } |
reference |
value() |
{ return m_value; } |
const_reference |
value() const |
{ return m_value; } |
#ifdef _GLIBCXX_DEBUG |
typedef typename base_type::node_debug_info node_debug_info; |
typedef typename base_type::a_const_pointer a_const_pointer; |
virtual node_debug_info |
assert_valid_imp(a_const_pointer p_traits, |
const char* __file, int __line) const |
{ |
PB_DS_DEBUG_VERIFY(base_type::m_type == leaf_node); |
node_debug_info ret; |
const_reference r_val = value(); |
return std::make_pair(p_traits->begin(p_traits->extract_key(r_val)), |
p_traits->end(p_traits->extract_key(r_val))); |
} |
virtual |
~_Leaf() { } |
#endif |
}; |
/// Internal node type, PATRICIA tree. |
template<typename _ATraits, typename Metadata> |
struct _Inode |
: public _Node_base<_ATraits, Metadata> |
{ |
typedef _Node_base<_ATraits, Metadata> base_type; |
typedef typename base_type::type_traits type_traits; |
typedef typename base_type::access_traits access_traits; |
typedef typename type_traits::value_type value_type; |
typedef typename base_type::allocator_type _Alloc; |
typedef _Alloc allocator_type; |
typedef typename _Alloc::size_type size_type; |
private: |
typedef typename base_type::a_const_pointer a_const_pointer; |
typedef typename base_type::a_const_iterator a_const_iterator; |
typedef typename base_type::node_pointer node_pointer; |
typedef typename _Alloc::template rebind<base_type> __rebind_n; |
typedef typename __rebind_n::other::const_pointer node_const_pointer; |
typedef _Leaf<_ATraits, Metadata> leaf; |
typedef typename _Alloc::template rebind<leaf>::other __rebind_l; |
typedef typename __rebind_l::pointer leaf_pointer; |
typedef typename __rebind_l::const_pointer leaf_const_pointer; |
typedef typename _Alloc::template rebind<_Inode>::other __rebind_in; |
typedef typename __rebind_in::pointer inode_pointer; |
typedef typename __rebind_in::const_pointer inode_const_pointer; |
inline size_type |
get_pref_pos(a_const_iterator, a_const_iterator, a_const_pointer) const; |
public: |
typedef typename _Alloc::template rebind<node_pointer>::other __rebind_np; |
typedef typename __rebind_np::pointer node_pointer_pointer; |
typedef typename __rebind_np::reference node_pointer_reference; |
enum |
{ |
arr_size = _ATraits::max_size + 1 |
}; |
PB_DS_STATIC_ASSERT(min_arr_size, arr_size >= 2); |
/// Constant child iterator. |
struct const_iterator |
{ |
node_pointer_pointer m_p_p_cur; |
node_pointer_pointer m_p_p_end; |
typedef std::forward_iterator_tag iterator_category; |
typedef typename _Alloc::difference_type difference_type; |
typedef node_pointer value_type; |
typedef node_pointer_pointer pointer; |
typedef node_pointer_reference reference; |
const_iterator(node_pointer_pointer p_p_cur = 0, |
node_pointer_pointer p_p_end = 0) |
: m_p_p_cur(p_p_cur), m_p_p_end(p_p_end) |
{ } |
bool |
operator==(const const_iterator& other) const |
{ return m_p_p_cur == other.m_p_p_cur; } |
bool |
operator!=(const const_iterator& other) const |
{ return m_p_p_cur != other.m_p_p_cur; } |
const_iterator& |
operator++() |
{ |
do |
++m_p_p_cur; |
while (m_p_p_cur != m_p_p_end && *m_p_p_cur == 0); |
return *this; |
} |
const_iterator |
operator++(int) |
{ |
const_iterator ret_it(*this); |
operator++(); |
return ret_it; |
} |
const node_pointer_pointer |
operator->() const |
{ |
_GLIBCXX_DEBUG_ONLY(assert_referencible();) |
return m_p_p_cur; |
} |
node_const_pointer |
operator*() const |
{ |
_GLIBCXX_DEBUG_ONLY(assert_referencible();) |
return *m_p_p_cur; |
} |
protected: |
#ifdef _GLIBCXX_DEBUG |
void |
assert_referencible() const |
{ _GLIBCXX_DEBUG_ASSERT(m_p_p_cur != m_p_p_end && *m_p_p_cur != 0); } |
#endif |
}; |
/// Child iterator. |
struct iterator : public const_iterator |
{ |
public: |
typedef std::forward_iterator_tag iterator_category; |
typedef typename _Alloc::difference_type difference_type; |
typedef node_pointer value_type; |
typedef node_pointer_pointer pointer; |
typedef node_pointer_reference reference; |
inline |
iterator(node_pointer_pointer p_p_cur = 0, |
node_pointer_pointer p_p_end = 0) |
: const_iterator(p_p_cur, p_p_end) { } |
bool |
operator==(const iterator& other) const |
{ return const_iterator::m_p_p_cur == other.m_p_p_cur; } |
bool |
operator!=(const iterator& other) const |
{ return const_iterator::m_p_p_cur != other.m_p_p_cur; } |
iterator& |
operator++() |
{ |
const_iterator::operator++(); |
return *this; |
} |
iterator |
operator++(int) |
{ |
iterator ret_it(*this); |
operator++(); |
return ret_it; |
} |
node_pointer_pointer |
operator->() |
{ |
_GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();) |
return const_iterator::m_p_p_cur; |
} |
node_pointer |
operator*() |
{ |
_GLIBCXX_DEBUG_ONLY(const_iterator::assert_referencible();) |
return *const_iterator::m_p_p_cur; |
} |
}; |
_Inode(size_type, const a_const_iterator); |
void |
update_prefixes(a_const_pointer); |
const_iterator |
begin() const; |
iterator |
begin(); |
const_iterator |
end() const; |
iterator |
end(); |
inline node_pointer |
get_child_node(a_const_iterator, a_const_iterator, a_const_pointer); |
inline node_const_pointer |
get_child_node(a_const_iterator, a_const_iterator, a_const_pointer) const; |
inline iterator |
get_child_it(a_const_iterator, a_const_iterator, a_const_pointer); |
inline node_pointer |
get_lower_bound_child_node(a_const_iterator, a_const_iterator, |
size_type, a_const_pointer); |
inline node_pointer |
add_child(node_pointer, a_const_iterator, a_const_iterator, |
a_const_pointer); |
inline node_const_pointer |
get_join_child(node_const_pointer, a_const_pointer) const; |
inline node_pointer |
get_join_child(node_pointer, a_const_pointer); |
void |
remove_child(node_pointer); |
void |
remove_child(iterator); |
void |
replace_child(node_pointer, a_const_iterator, a_const_iterator, |
a_const_pointer); |
inline a_const_iterator |
pref_b_it() const; |
inline a_const_iterator |
pref_e_it() const; |
bool |
should_be_mine(a_const_iterator, a_const_iterator, size_type, |
a_const_pointer) const; |
leaf_pointer |
leftmost_descendant(); |
leaf_const_pointer |
leftmost_descendant() const; |
leaf_pointer |
rightmost_descendant(); |
leaf_const_pointer |
rightmost_descendant() const; |
#ifdef _GLIBCXX_DEBUG |
typedef typename base_type::node_debug_info node_debug_info; |
virtual node_debug_info |
assert_valid_imp(a_const_pointer, const char*, int) const; |
#endif |
size_type |
get_e_ind() const |
{ return m_e_ind; } |
private: |
_Inode(const _Inode&); |
size_type |
get_begin_pos() const; |
static __rebind_l s_leaf_alloc; |
static __rebind_in s_inode_alloc; |
const size_type m_e_ind; |
a_const_iterator m_pref_b_it; |
a_const_iterator m_pref_e_it; |
node_pointer m_a_p_children[arr_size]; |
}; |
#define PB_DS_CONST_IT_C_DEC \ |
_CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator> |
#define PB_DS_CONST_ODIR_IT_C_DEC \ |
_CIter<Node, Leaf, Head, Inode, !Is_Forward_Iterator> |
#define PB_DS_IT_C_DEC \ |
_Iter<Node, Leaf, Head, Inode, Is_Forward_Iterator> |
#define PB_DS_ODIR_IT_C_DEC \ |
_Iter<Node, Leaf, Head, Inode, !Is_Forward_Iterator> |
/// Const iterator. |
template<typename Node, typename Leaf, typename Head, typename Inode, |
bool Is_Forward_Iterator> |
class _CIter |
{ |
public: |
// These types are all the same for the first four template arguments. |
typedef typename Node::allocator_type allocator_type; |
typedef typename Node::type_traits type_traits; |
typedef std::bidirectional_iterator_tag iterator_category; |
typedef typename allocator_type::difference_type difference_type; |
typedef typename type_traits::value_type value_type; |
typedef typename type_traits::pointer pointer; |
typedef typename type_traits::reference reference; |
typedef typename type_traits::const_pointer const_pointer; |
typedef typename type_traits::const_reference const_reference; |
typedef allocator_type _Alloc; |
typedef typename _Alloc::template rebind<Node> __rebind_n; |
typedef typename __rebind_n::other::pointer node_pointer; |
typedef typename _Alloc::template rebind<Leaf> __rebind_l; |
typedef typename __rebind_l::other::pointer leaf_pointer; |
typedef typename __rebind_l::other::const_pointer leaf_const_pointer; |
typedef typename _Alloc::template rebind<Head> __rebind_h; |
typedef typename __rebind_h::other::pointer head_pointer; |
typedef typename _Alloc::template rebind<Inode> __rebind_in; |
typedef typename __rebind_in::other::pointer inode_pointer; |
typedef typename Inode::iterator inode_iterator; |
node_pointer m_p_nd; |
_CIter(node_pointer p_nd = 0) : m_p_nd(p_nd) |
{ } |
_CIter(const PB_DS_CONST_ODIR_IT_C_DEC& other) |
: m_p_nd(other.m_p_nd) |
{ } |
_CIter& |
operator=(const _CIter& other) |
{ |
m_p_nd = other.m_p_nd; |
return *this; |
} |
_CIter& |
operator=(const PB_DS_CONST_ODIR_IT_C_DEC& other) |
{ |
m_p_nd = other.m_p_nd; |
return *this; |
} |
const_pointer |
operator->() const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node); |
return &static_cast<leaf_pointer>(m_p_nd)->value(); |
} |
const_reference |
operator*() const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == leaf_node); |
return static_cast<leaf_pointer>(m_p_nd)->value(); |
} |
bool |
operator==(const _CIter& other) const |
{ return m_p_nd == other.m_p_nd; } |
bool |
operator==(const PB_DS_CONST_ODIR_IT_C_DEC& other) const |
{ return m_p_nd == other.m_p_nd; } |
bool |
operator!=(const _CIter& other) const |
{ return m_p_nd != other.m_p_nd; } |
bool |
operator!=(const PB_DS_CONST_ODIR_IT_C_DEC& other) const |
{ return m_p_nd != other.m_p_nd; } |
_CIter& |
operator++() |
{ |
inc(integral_constant<int, Is_Forward_Iterator>()); |
return *this; |
} |
_CIter |
operator++(int) |
{ |
_CIter ret_it(m_p_nd); |
operator++(); |
return ret_it; |
} |
_CIter& |
operator--() |
{ |
dec(integral_constant<int, Is_Forward_Iterator>()); |
return *this; |
} |
_CIter |
operator--(int) |
{ |
_CIter ret_it(m_p_nd); |
operator--(); |
return ret_it; |
} |
protected: |
void |
inc(false_type) |
{ dec(true_type()); } |
void |
inc(true_type) |
{ |
if (m_p_nd->m_type == head_node) |
{ |
m_p_nd = static_cast<head_pointer>(m_p_nd)->m_p_min; |
return; |
} |
node_pointer p_y = m_p_nd->m_p_parent; |
while (p_y->m_type != head_node && get_larger_sibling(m_p_nd) == 0) |
{ |
m_p_nd = p_y; |
p_y = p_y->m_p_parent; |
} |
if (p_y->m_type == head_node) |
{ |
m_p_nd = p_y; |
return; |
} |
m_p_nd = leftmost_descendant(get_larger_sibling(m_p_nd)); |
} |
void |
dec(false_type) |
{ inc(true_type()); } |
void |
dec(true_type) |
{ |
if (m_p_nd->m_type == head_node) |
{ |
m_p_nd = static_cast<head_pointer>(m_p_nd)->m_p_max; |
return; |
} |
node_pointer p_y = m_p_nd->m_p_parent; |
while (p_y->m_type != head_node && get_smaller_sibling(m_p_nd) == 0) |
{ |
m_p_nd = p_y; |
p_y = p_y->m_p_parent; |
} |
if (p_y->m_type == head_node) |
{ |
m_p_nd = p_y; |
return; |
} |
m_p_nd = rightmost_descendant(get_smaller_sibling(m_p_nd)); |
} |
static node_pointer |
get_larger_sibling(node_pointer p_nd) |
{ |
inode_pointer p_parent = static_cast<inode_pointer>(p_nd->m_p_parent); |
inode_iterator it = p_parent->begin(); |
while (*it != p_nd) |
++it; |
inode_iterator next_it = it; |
++next_it; |
return (next_it == p_parent->end())? 0 : *next_it; |
} |
static node_pointer |
get_smaller_sibling(node_pointer p_nd) |
{ |
inode_pointer p_parent = static_cast<inode_pointer>(p_nd->m_p_parent); |
inode_iterator it = p_parent->begin(); |
if (*it == p_nd) |
return 0; |
inode_iterator prev_it; |
do |
{ |
prev_it = it; |
++it; |
if (*it == p_nd) |
return *prev_it; |
} |
while (true); |
_GLIBCXX_DEBUG_ASSERT(false); |
return 0; |
} |
static leaf_pointer |
leftmost_descendant(node_pointer p_nd) |
{ |
if (p_nd->m_type == leaf_node) |
return static_cast<leaf_pointer>(p_nd); |
return static_cast<inode_pointer>(p_nd)->leftmost_descendant(); |
} |
static leaf_pointer |
rightmost_descendant(node_pointer p_nd) |
{ |
if (p_nd->m_type == leaf_node) |
return static_cast<leaf_pointer>(p_nd); |
return static_cast<inode_pointer>(p_nd)->rightmost_descendant(); |
} |
}; |
/// Iterator. |
template<typename Node, typename Leaf, typename Head, typename Inode, |
bool Is_Forward_Iterator> |
class _Iter |
: public _CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator> |
{ |
public: |
typedef _CIter<Node, Leaf, Head, Inode, Is_Forward_Iterator> |
base_type; |
typedef typename base_type::allocator_type allocator_type; |
typedef typename base_type::type_traits type_traits; |
typedef typename type_traits::value_type value_type; |
typedef typename type_traits::pointer pointer; |
typedef typename type_traits::reference reference; |
typedef typename base_type::node_pointer node_pointer; |
typedef typename base_type::leaf_pointer leaf_pointer; |
typedef typename base_type::leaf_const_pointer leaf_const_pointer; |
typedef typename base_type::head_pointer head_pointer; |
typedef typename base_type::inode_pointer inode_pointer; |
_Iter(node_pointer p_nd = 0) |
: base_type(p_nd) { } |
_Iter(const PB_DS_ODIR_IT_C_DEC& other) |
: base_type(other.m_p_nd) { } |
_Iter& |
operator=(const _Iter& other) |
{ |
base_type::m_p_nd = other.m_p_nd; |
return *this; |
} |
_Iter& |
operator=(const PB_DS_ODIR_IT_C_DEC& other) |
{ |
base_type::m_p_nd = other.m_p_nd; |
return *this; |
} |
pointer |
operator->() const |
{ |
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node); |
return &static_cast<leaf_pointer>(base_type::m_p_nd)->value(); |
} |
reference |
operator*() const |
{ |
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == leaf_node); |
return static_cast<leaf_pointer>(base_type::m_p_nd)->value(); |
} |
_Iter& |
operator++() |
{ |
base_type::operator++(); |
return *this; |
} |
_Iter |
operator++(int) |
{ |
_Iter ret(base_type::m_p_nd); |
operator++(); |
return ret; |
} |
_Iter& |
operator--() |
{ |
base_type::operator--(); |
return *this; |
} |
_Iter |
operator--(int) |
{ |
_Iter ret(base_type::m_p_nd); |
operator--(); |
return ret; |
} |
}; |
#undef PB_DS_CONST_ODIR_IT_C_DEC |
#undef PB_DS_ODIR_IT_C_DEC |
#define PB_DS_PAT_TRIE_NODE_CONST_ITERATOR_C_DEC \ |
_Node_citer<Node, Leaf, Head, Inode, _CIterator, Iterator, _ATraits, _Alloc> |
#define PB_DS_PAT_TRIE_NODE_ITERATOR_C_DEC \ |
_Node_iter<Node, Leaf, Head, Inode, _CIterator, Iterator, _ATraits, _Alloc> |
/// Node const iterator. |
template<typename Node, |
typename Leaf, |
typename Head, |
typename Inode, |
typename _CIterator, |
typename Iterator, |
typename _Alloc> |
class _Node_citer |
{ |
protected: |
typedef typename _Alloc::template rebind<Node> __rebind_n; |
typedef typename __rebind_n::other::pointer node_pointer; |
typedef typename _Alloc::template rebind<Leaf> __rebind_l; |
typedef typename __rebind_l::other::pointer leaf_pointer; |
typedef typename __rebind_l::other::const_pointer leaf_const_pointer; |
typedef typename _Alloc::template rebind<Inode> __rebind_in; |
typedef typename __rebind_in::other::pointer inode_pointer; |
typedef typename __rebind_in::other::const_pointer inode_const_pointer; |
typedef typename Node::a_const_pointer a_const_pointer; |
typedef typename Node::a_const_iterator a_const_iterator; |
private: |
a_const_iterator |
pref_begin() const |
{ |
if (m_p_nd->m_type == leaf_node) |
{ |
leaf_const_pointer lcp = static_cast<leaf_const_pointer>(m_p_nd); |
return m_p_traits->begin(m_p_traits->extract_key(lcp->value())); |
} |
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node); |
return static_cast<inode_const_pointer>(m_p_nd)->pref_b_it(); |
} |
a_const_iterator |
pref_end() const |
{ |
if (m_p_nd->m_type == leaf_node) |
{ |
leaf_const_pointer lcp = static_cast<leaf_const_pointer>(m_p_nd); |
return m_p_traits->end(m_p_traits->extract_key(lcp->value())); |
} |
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node); |
return static_cast<inode_const_pointer>(m_p_nd)->pref_e_it(); |
} |
public: |
typedef trivial_iterator_tag iterator_category; |
typedef trivial_iterator_difference_type difference_type; |
typedef typename _Alloc::size_type size_type; |
typedef _CIterator value_type; |
typedef value_type reference; |
typedef value_type const_reference; |
/// Metadata type. |
typedef typename Node::metadata_type metadata_type; |
/// Const metadata reference type. |
typedef typename _Alloc::template rebind<metadata_type> __rebind_m; |
typedef typename __rebind_m::other __rebind_ma; |
typedef typename __rebind_ma::const_reference metadata_const_reference; |
inline |
_Node_citer(node_pointer p_nd = 0, a_const_pointer p_traits = 0) |
: m_p_nd(const_cast<node_pointer>(p_nd)), m_p_traits(p_traits) |
{ } |
/// Subtree valid prefix. |
std::pair<a_const_iterator, a_const_iterator> |
valid_prefix() const |
{ return std::make_pair(pref_begin(), pref_end()); } |
/// Const access; returns the __const iterator* associated with |
/// the current leaf. |
const_reference |
operator*() const |
{ |
_GLIBCXX_DEBUG_ASSERT(num_children() == 0); |
return _CIterator(m_p_nd); |
} |
/// Metadata access. |
metadata_const_reference |
get_metadata() const |
{ return m_p_nd->get_metadata(); } |
/// Returns the number of children in the corresponding node. |
size_type |
num_children() const |
{ |
if (m_p_nd->m_type == leaf_node) |
return 0; |
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node); |
inode_pointer inp = static_cast<inode_pointer>(m_p_nd); |
return std::distance(inp->begin(), inp->end()); |
} |
/// Returns a __const node __iterator to the corresponding node's |
/// i-th child. |
_Node_citer |
get_child(size_type i) const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_nd->m_type == i_node); |
inode_pointer inp = static_cast<inode_pointer>(m_p_nd); |
typename Inode::iterator it = inp->begin(); |
std::advance(it, i); |
return _Node_citer(*it, m_p_traits); |
} |
/// Compares content to a different iterator object. |
bool |
operator==(const _Node_citer& other) const |
{ return m_p_nd == other.m_p_nd; } |
/// Compares content (negatively) to a different iterator object. |
bool |
operator!=(const _Node_citer& other) const |
{ return m_p_nd != other.m_p_nd; } |
node_pointer m_p_nd; |
a_const_pointer m_p_traits; |
}; |
/// Node iterator. |
template<typename Node, |
typename Leaf, |
typename Head, |
typename Inode, |
typename _CIterator, |
typename Iterator, |
typename _Alloc> |
class _Node_iter |
: public _Node_citer<Node, Leaf, Head, Inode, _CIterator, Iterator, _Alloc> |
{ |
private: |
typedef _Node_citer<Node, Leaf, Head, Inode, |
_CIterator, Iterator, _Alloc> base_type; |
typedef typename _Alloc::template rebind<Node> __rebind_n; |
typedef typename __rebind_n::other::pointer node_pointer; |
typedef typename base_type::inode_pointer inode_pointer; |
typedef typename base_type::a_const_pointer a_const_pointer; |
typedef Iterator iterator; |
public: |
typedef typename base_type::size_type size_type; |
typedef Iterator value_type; |
typedef value_type reference; |
typedef value_type const_reference; |
_Node_iter(node_pointer p_nd = 0, a_const_pointer p_traits = 0) |
: base_type(p_nd, p_traits) |
{ } |
/// Access; returns the iterator* associated with the current leaf. |
reference |
operator*() const |
{ |
_GLIBCXX_DEBUG_ASSERT(base_type::num_children() == 0); |
return iterator(base_type::m_p_nd); |
} |
/// Returns a node __iterator to the corresponding node's i-th child. |
_Node_iter |
get_child(size_type i) const |
{ |
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_nd->m_type == i_node); |
typename Inode::iterator it = |
static_cast<inode_pointer>(base_type::m_p_nd)->begin(); |
std::advance(it, i); |
return _Node_iter(*it, base_type::m_p_traits); |
} |
}; |
}; |
#define PB_DS_CLASS_T_DEC \ |
template<typename _ATraits, typename Metadata> |
#define PB_DS_CLASS_C_DEC \ |
pat_trie_base::_Inode<_ATraits, Metadata> |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::__rebind_l |
PB_DS_CLASS_C_DEC::s_leaf_alloc; |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::__rebind_in |
PB_DS_CLASS_C_DEC::s_inode_alloc; |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
get_pref_pos(a_const_iterator b_it, a_const_iterator e_it, |
a_const_pointer p_traits) const |
{ |
if (static_cast<std::size_t>(std::distance(b_it, e_it)) <= m_e_ind) |
return 0; |
std::advance(b_it, m_e_ind); |
return 1 + p_traits->e_pos(*b_it); |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
_Inode(size_type len, const a_const_iterator it) |
: base_type(i_node), m_e_ind(len), m_pref_b_it(it), m_pref_e_it(it) |
{ |
std::advance(m_pref_e_it, m_e_ind); |
std::fill(m_a_p_children, m_a_p_children + arr_size, |
static_cast<node_pointer>(0)); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
update_prefixes(a_const_pointer p_traits) |
{ |
node_pointer p_first = *begin(); |
if (p_first->m_type == leaf_node) |
{ |
leaf_const_pointer p = static_cast<leaf_const_pointer>(p_first); |
m_pref_b_it = p_traits->begin(access_traits::extract_key(p->value())); |
} |
else |
{ |
inode_pointer p = static_cast<inode_pointer>(p_first); |
_GLIBCXX_DEBUG_ASSERT(p_first->m_type == i_node); |
m_pref_b_it = p->pref_b_it(); |
} |
m_pref_e_it = m_pref_b_it; |
std::advance(m_pref_e_it, m_e_ind); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
begin() const |
{ |
typedef node_pointer_pointer pointer_type; |
pointer_type p = const_cast<pointer_type>(m_a_p_children); |
return const_iterator(p + get_begin_pos(), p + arr_size); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
begin() |
{ |
return iterator(m_a_p_children + get_begin_pos(), |
m_a_p_children + arr_size); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
end() const |
{ |
typedef node_pointer_pointer pointer_type; |
pointer_type p = const_cast<pointer_type>(m_a_p_children) + arr_size; |
return const_iterator(p, p); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
end() |
{ return iterator(m_a_p_children + arr_size, m_a_p_children + arr_size); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
get_child_node(a_const_iterator b_it, a_const_iterator e_it, |
a_const_pointer p_traits) |
{ |
const size_type i = get_pref_pos(b_it, e_it, p_traits); |
_GLIBCXX_DEBUG_ASSERT(i < arr_size); |
return m_a_p_children[i]; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
get_child_it(a_const_iterator b_it, a_const_iterator e_it, |
a_const_pointer p_traits) |
{ |
const size_type i = get_pref_pos(b_it, e_it, p_traits); |
_GLIBCXX_DEBUG_ASSERT(i < arr_size); |
_GLIBCXX_DEBUG_ASSERT(m_a_p_children[i] != 0); |
return iterator(m_a_p_children + i, m_a_p_children + i); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_const_pointer |
PB_DS_CLASS_C_DEC:: |
get_child_node(a_const_iterator b_it, a_const_iterator e_it, |
a_const_pointer p_traits) const |
{ return const_cast<node_pointer>(get_child_node(b_it, e_it, p_traits)); } |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
get_lower_bound_child_node(a_const_iterator b_it, a_const_iterator e_it, |
size_type checked_ind, |
a_const_pointer p_traits) |
{ |
if (!should_be_mine(b_it, e_it, checked_ind, p_traits)) |
{ |
if (p_traits->cmp_prefixes(b_it, e_it, m_pref_b_it, |
m_pref_e_it, true)) |
return leftmost_descendant(); |
return rightmost_descendant(); |
} |
size_type i = get_pref_pos(b_it, e_it, p_traits); |
_GLIBCXX_DEBUG_ASSERT(i < arr_size); |
if (m_a_p_children[i] != 0) |
return m_a_p_children[i]; |
while (++i < arr_size) |
if (m_a_p_children[i] != 0) |
{ |
const node_type& __nt = m_a_p_children[i]->m_type; |
node_pointer ret = m_a_p_children[i]; |
if (__nt == leaf_node) |
return ret; |
_GLIBCXX_DEBUG_ASSERT(__nt == i_node); |
inode_pointer inp = static_cast<inode_pointer>(ret); |
return inp->leftmost_descendant(); |
} |
return rightmost_descendant(); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
add_child(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it, |
a_const_pointer p_traits) |
{ |
const size_type i = get_pref_pos(b_it, e_it, p_traits); |
_GLIBCXX_DEBUG_ASSERT(i < arr_size); |
if (m_a_p_children[i] == 0) |
{ |
m_a_p_children[i] = p_nd; |
p_nd->m_p_parent = this; |
return p_nd; |
} |
return m_a_p_children[i]; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_const_pointer |
PB_DS_CLASS_C_DEC:: |
get_join_child(node_const_pointer p_nd, |
a_const_pointer p_tr) const |
{ |
node_pointer p = const_cast<node_pointer>(p_nd); |
return const_cast<inode_pointer>(this)->get_join_child(p, p_tr); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
get_join_child(node_pointer p_nd, a_const_pointer p_traits) |
{ |
size_type i; |
a_const_iterator b_it; |
a_const_iterator e_it; |
if (p_nd->m_type == leaf_node) |
{ |
leaf_const_pointer p = static_cast<leaf_const_pointer>(p_nd); |
typedef typename type_traits::key_const_reference kcr; |
kcr r_key = access_traits::extract_key(p->value()); |
b_it = p_traits->begin(r_key); |
e_it = p_traits->end(r_key); |
} |
else |
{ |
b_it = static_cast<inode_pointer>(p_nd)->pref_b_it(); |
e_it = static_cast<inode_pointer>(p_nd)->pref_e_it(); |
} |
i = get_pref_pos(b_it, e_it, p_traits); |
_GLIBCXX_DEBUG_ASSERT(i < arr_size); |
return m_a_p_children[i]; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
remove_child(node_pointer p_nd) |
{ |
size_type i = 0; |
for (; i < arr_size; ++i) |
if (m_a_p_children[i] == p_nd) |
{ |
m_a_p_children[i] = 0; |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(i != arr_size); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
remove_child(iterator it) |
{ *it.m_p_p_cur = 0; } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
replace_child(node_pointer p_nd, a_const_iterator b_it, |
a_const_iterator e_it, |
a_const_pointer p_traits) |
{ |
const size_type i = get_pref_pos(b_it, e_it, p_traits); |
_GLIBCXX_DEBUG_ASSERT(i < arr_size); |
m_a_p_children[i] = p_nd; |
p_nd->m_p_parent = this; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::a_const_iterator |
PB_DS_CLASS_C_DEC:: |
pref_b_it() const |
{ return m_pref_b_it; } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::a_const_iterator |
PB_DS_CLASS_C_DEC:: |
pref_e_it() const |
{ return m_pref_e_it; } |
PB_DS_CLASS_T_DEC |
bool |
PB_DS_CLASS_C_DEC:: |
should_be_mine(a_const_iterator b_it, a_const_iterator e_it, |
size_type checked_ind, |
a_const_pointer p_traits) const |
{ |
if (m_e_ind == 0) |
return true; |
const size_type num_es = std::distance(b_it, e_it); |
if (num_es < m_e_ind) |
return false; |
a_const_iterator key_b_it = b_it; |
std::advance(key_b_it, checked_ind); |
a_const_iterator key_e_it = b_it; |
std::advance(key_e_it, m_e_ind); |
a_const_iterator value_b_it = m_pref_b_it; |
std::advance(value_b_it, checked_ind); |
a_const_iterator value_e_it = m_pref_b_it; |
std::advance(value_e_it, m_e_ind); |
return p_traits->equal_prefixes(key_b_it, key_e_it, value_b_it, |
value_e_it); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::leaf_pointer |
PB_DS_CLASS_C_DEC:: |
leftmost_descendant() |
{ |
node_pointer p_pot = *begin(); |
if (p_pot->m_type == leaf_node) |
return (static_cast<leaf_pointer>(p_pot)); |
_GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node); |
return static_cast<inode_pointer>(p_pot)->leftmost_descendant(); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::leaf_const_pointer |
PB_DS_CLASS_C_DEC:: |
leftmost_descendant() const |
{ return const_cast<inode_pointer>(this)->leftmost_descendant(); } |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::leaf_pointer |
PB_DS_CLASS_C_DEC:: |
rightmost_descendant() |
{ |
const size_type num_children = std::distance(begin(), end()); |
_GLIBCXX_DEBUG_ASSERT(num_children >= 2); |
iterator it = begin(); |
std::advance(it, num_children - 1); |
node_pointer p_pot =* it; |
if (p_pot->m_type == leaf_node) |
return static_cast<leaf_pointer>(p_pot); |
_GLIBCXX_DEBUG_ASSERT(p_pot->m_type == i_node); |
return static_cast<inode_pointer>(p_pot)->rightmost_descendant(); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::leaf_const_pointer |
PB_DS_CLASS_C_DEC:: |
rightmost_descendant() const |
{ return const_cast<inode_pointer>(this)->rightmost_descendant(); } |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
get_begin_pos() const |
{ |
size_type i = 0; |
for (; i < arr_size && m_a_p_children[i] == 0; ++i) |
; |
return i; |
} |
#ifdef _GLIBCXX_DEBUG |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_debug_info |
PB_DS_CLASS_C_DEC:: |
assert_valid_imp(a_const_pointer p_traits, |
const char* __file, int __line) const |
{ |
PB_DS_DEBUG_VERIFY(base_type::m_type == i_node); |
PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(pref_b_it(), pref_e_it())) == m_e_ind); |
PB_DS_DEBUG_VERIFY(std::distance(begin(), end()) >= 2); |
for (typename _Inode::const_iterator it = begin(); it != end(); ++it) |
{ |
node_const_pointer p_nd = *it; |
PB_DS_DEBUG_VERIFY(p_nd->m_p_parent == this); |
node_debug_info child_ret = p_nd->assert_valid_imp(p_traits, |
__file, __line); |
PB_DS_DEBUG_VERIFY(static_cast<size_type>(std::distance(child_ret.first, child_ret.second)) >= m_e_ind); |
PB_DS_DEBUG_VERIFY(should_be_mine(child_ret.first, child_ret.second, 0, p_traits)); |
PB_DS_DEBUG_VERIFY(get_pref_pos(child_ret.first, child_ret.second, p_traits) == static_cast<size_type>(it.m_p_p_cur - m_a_p_children)); |
} |
return std::make_pair(pref_b_it(), pref_e_it()); |
} |
#endif |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp |
---|
0,0 → 1,63 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/policy_access_fn_imps.hpp |
* Contains an implementation class for pat_trie. |
*/ |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::access_traits& |
PB_DS_CLASS_C_DEC:: |
get_access_traits() |
{ return *this; } |
PB_DS_CLASS_T_DEC |
const typename PB_DS_CLASS_C_DEC::access_traits& |
PB_DS_CLASS_C_DEC:: |
get_access_traits() const |
{ return *this; } |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_update& |
PB_DS_CLASS_C_DEC:: |
get_node_update() |
{ return *this; } |
PB_DS_CLASS_T_DEC |
const typename PB_DS_CLASS_C_DEC::node_update& |
PB_DS_CLASS_C_DEC:: |
get_node_update() const |
{ return *this; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp |
---|
0,0 → 1,103 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/r_erase_fn_imps.hpp |
* Contains an implementation class for pat_trie. |
*/ |
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() |
{ |
_GLIBCXX_DEBUG_ONLY(assert_valid(true, true);) |
clear_imp(m_p_head->m_p_parent); |
m_size = 0; |
initialize(); |
_GLIBCXX_DEBUG_ONLY(debug_base::clear();) |
_GLIBCXX_DEBUG_ONLY(assert_valid(true, true);) |
} |
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); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp |
---|
0,0 → 1,150 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/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; |
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) |
_GLIBCXX_DEBUG_ONLY(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; |
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(p_x);) |
_GLIBCXX_DEBUG_ONLY(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*/, __gnu_pbds::null_node_update* /*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) |
{ |
p_update->operator()(& PB_DS_V2F(p_nd->m_value),(p_nd->m_p_left == 0) ? |
0 : |
& PB_DS_V2F(p_nd->m_p_left->m_value),(p_nd->m_p_right == 0) ? |
0 : |
& PB_DS_V2F(p_nd->m_p_right->m_value)); |
} |
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*/, __gnu_pbds::null_node_update* /*p_update*/) |
{ } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp |
---|
0,0 → 1,250 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/split_fn_imps.hpp |
* Contains an implementation class for pat_trie. |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
branch_bag bag; |
leaf_pointer p_split_lf = split_prep(r_key, other, bag); |
if (p_split_lf == 0) |
{ |
_GLIBCXX_DEBUG_ASSERT(bag.empty()); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(!bag.empty()); |
other.clear(); |
m_p_head->m_p_parent = rec_split(m_p_head->m_p_parent, pref_begin(p_split_lf), |
pref_end(p_split_lf), other, bag); |
m_p_head->m_p_parent->m_p_parent = m_p_head; |
head_pointer __ohead = other.m_p_head; |
__ohead->m_p_max = m_p_head->m_p_max; |
m_p_head->m_p_max = rightmost_descendant(m_p_head->m_p_parent); |
__ohead->m_p_min = other.leftmost_descendant(__ohead->m_p_parent); |
other.m_size = std::distance(other.PB_DS_CLASS_C_DEC::begin(), |
other.PB_DS_CLASS_C_DEC::end()); |
m_size -= other.m_size; |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::leaf_pointer |
PB_DS_CLASS_C_DEC:: |
split_prep(key_const_reference r_key, PB_DS_CLASS_C_DEC& other, |
branch_bag& r_bag) |
{ |
_GLIBCXX_DEBUG_ASSERT(r_bag.empty()); |
if (m_size == 0) |
{ |
other.clear(); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return 0; |
} |
if (synth_access_traits::cmp_keys(r_key, |
PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_min)->value()))) |
{ |
other.clear(); |
value_swap(other); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return 0; |
} |
if (!synth_access_traits::cmp_keys(r_key, |
PB_DS_V2F(static_cast<leaf_const_pointer>(m_p_head->m_p_max)->value()))) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return 0; |
} |
iterator it = lower_bound(r_key); |
if (!synth_access_traits::equal_keys(PB_DS_V2F(*it), r_key)) |
--it; |
node_pointer p_nd = it.m_p_nd; |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == leaf_node); |
leaf_pointer p_ret_l = static_cast<leaf_pointer>(p_nd); |
while (p_nd->m_type != head_node) |
{ |
r_bag.add_branch(); |
p_nd = p_nd->m_p_parent; |
} |
_GLIBCXX_DEBUG_ONLY(debug_base::split(r_key,(synth_access_traits&)(*this), other);) |
return p_ret_l; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
rec_split(node_pointer p_nd, a_const_iterator b_it, a_const_iterator e_it, |
PB_DS_CLASS_C_DEC& other, branch_bag& r_bag) |
{ |
if (p_nd->m_type == leaf_node) |
{ |
_GLIBCXX_DEBUG_ASSERT(other.m_p_head->m_p_parent == 0); |
return p_nd; |
} |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_type == i_node); |
inode_pointer p_ind = static_cast<inode_pointer>(p_nd); |
node_pointer pfirst = p_ind->get_child_node(b_it, e_it, this); |
node_pointer p_child_ret = rec_split(pfirst, b_it, e_it, other, r_bag); |
PB_DS_ASSERT_NODE_VALID(p_child_ret) |
p_ind->replace_child(p_child_ret, b_it, e_it, this); |
apply_update(p_ind, (node_update*)this); |
inode_iterator child_it = p_ind->get_child_it(b_it, e_it, this); |
const size_type lhs_dist = std::distance(p_ind->begin(), child_it); |
const size_type lhs_num_children = lhs_dist + 1; |
_GLIBCXX_DEBUG_ASSERT(lhs_num_children > 0); |
const size_type rhs_dist = std::distance(p_ind->begin(), p_ind->end()); |
size_type rhs_num_children = rhs_dist - lhs_num_children; |
if (rhs_num_children == 0) |
{ |
apply_update(p_ind, (node_update*)this); |
return p_ind; |
} |
other.split_insert_branch(p_ind->get_e_ind(), b_it, child_it, |
rhs_num_children, r_bag); |
child_it = p_ind->get_child_it(b_it, e_it, this); |
while (rhs_num_children != 0) |
{ |
++child_it; |
p_ind->remove_child(child_it); |
--rhs_num_children; |
} |
apply_update(p_ind, (node_update*)this); |
const size_type int_dist = std::distance(p_ind->begin(), p_ind->end()); |
_GLIBCXX_DEBUG_ASSERT(int_dist >= 1); |
if (int_dist > 1) |
{ |
p_ind->update_prefixes(this); |
PB_DS_ASSERT_NODE_VALID(p_ind) |
apply_update(p_ind, (node_update*)this); |
return p_ind; |
} |
node_pointer p_ret = *p_ind->begin(); |
p_ind->~inode(); |
s_inode_allocator.deallocate(p_ind, 1); |
apply_update(p_ret, (node_update*)this); |
return p_ret; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
split_insert_branch(size_type e_ind, a_const_iterator b_it, |
inode_iterator child_b_it, |
size_type num_children, branch_bag& r_bag) |
{ |
#ifdef _GLIBCXX_DEBUG |
if (m_p_head->m_p_parent != 0) |
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) |
#endif |
const size_type start = m_p_head->m_p_parent == 0 ? 0 : 1; |
const size_type total_num_children = start + num_children; |
if (total_num_children == 0) |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0); |
return; |
} |
if (total_num_children == 1) |
{ |
if (m_p_head->m_p_parent != 0) |
{ |
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(m_p_head->m_p_parent == 0); |
++child_b_it; |
m_p_head->m_p_parent = *child_b_it; |
m_p_head->m_p_parent->m_p_parent = m_p_head; |
apply_update(m_p_head->m_p_parent, (node_update*)this); |
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) |
return; |
} |
_GLIBCXX_DEBUG_ASSERT(total_num_children > 1); |
inode_pointer p_new_root = r_bag.get_branch(); |
new (p_new_root) inode(e_ind, b_it); |
size_type num_inserted = 0; |
while (num_inserted++ < num_children) |
{ |
++child_b_it; |
PB_DS_ASSERT_NODE_VALID((*child_b_it)) |
p_new_root->add_child(*child_b_it, pref_begin(*child_b_it), |
pref_end(*child_b_it), this); |
} |
if (m_p_head->m_p_parent != 0) |
p_new_root->add_child(m_p_head->m_p_parent, |
pref_begin(m_p_head->m_p_parent), |
pref_end(m_p_head->m_p_parent), this); |
m_p_head->m_p_parent = p_new_root; |
p_new_root->m_p_parent = m_p_head; |
apply_update(m_p_head->m_p_parent, (node_update*)this); |
PB_DS_ASSERT_NODE_VALID(m_p_head->m_p_parent) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp |
---|
0,0 → 1,218 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/synth_access_traits.hpp |
* Contains an implementation class for a patricia tree. |
*/ |
#ifndef PB_DS_SYNTH_E_ACCESS_TRAITS_HPP |
#define PB_DS_SYNTH_E_ACCESS_TRAITS_HPP |
#include <ext/pb_ds/detail/type_utils.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#define PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC \ |
template<typename Type_Traits, bool Set, typename _ATraits> |
#define PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC \ |
synth_access_traits<Type_Traits, Set, _ATraits> |
/// Synthetic element access traits. |
template<typename Type_Traits, bool Set, typename _ATraits> |
struct synth_access_traits : public _ATraits |
{ |
typedef _ATraits base_type; |
typedef typename base_type::const_iterator const_iterator; |
typedef Type_Traits type_traits; |
typedef typename type_traits::const_reference const_reference; |
typedef typename type_traits::key_const_reference key_const_reference; |
synth_access_traits(); |
synth_access_traits(const base_type&); |
inline bool |
equal_prefixes(const_iterator, const_iterator, const_iterator, |
const_iterator, bool compare_after = true) const; |
bool |
equal_keys(key_const_reference, key_const_reference) const; |
bool |
cmp_prefixes(const_iterator, const_iterator, const_iterator, |
const_iterator, bool compare_after = false) const; |
bool |
cmp_keys(key_const_reference, key_const_reference) const; |
inline static key_const_reference |
extract_key(const_reference); |
#ifdef _GLIBCXX_DEBUG |
bool |
operator()(key_const_reference, key_const_reference); |
#endif |
private: |
inline static key_const_reference |
extract_key(const_reference, true_type); |
inline static key_const_reference |
extract_key(const_reference, false_type); |
static integral_constant<int, Set> s_set_ind; |
}; |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
integral_constant<int,Set> |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::s_set_ind; |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
synth_access_traits() |
{ } |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
synth_access_traits(const _ATraits& r_traits) |
: _ATraits(r_traits) |
{ } |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
inline bool |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
equal_prefixes(const_iterator b_l, const_iterator e_l, const_iterator b_r, |
const_iterator e_r, bool compare_after /*= false */) const |
{ |
while (b_l != e_l) |
{ |
if (b_r == e_r) |
return false; |
if (base_type::e_pos(*b_l) != base_type::e_pos(*b_r)) |
return false; |
++b_l; |
++b_r; |
} |
return (!compare_after || b_r == e_r); |
} |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
bool |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
equal_keys(key_const_reference r_lhs_key, |
key_const_reference r_rhs_key) const |
{ |
return equal_prefixes(base_type::begin(r_lhs_key), |
base_type::end(r_lhs_key), |
base_type::begin(r_rhs_key), |
base_type::end(r_rhs_key), |
true); |
} |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
bool |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
cmp_prefixes(const_iterator b_l, const_iterator e_l, const_iterator b_r, |
const_iterator e_r, bool compare_after /* = false*/) const |
{ |
while (b_l != e_l) |
{ |
if (b_r == e_r) |
return false; |
const typename base_type::size_type l_pos = base_type::e_pos(*b_l); |
const typename base_type::size_type r_pos = base_type::e_pos(*b_r); |
if (l_pos != r_pos) |
return l_pos < r_pos; |
++b_l; |
++b_r; |
} |
if (!compare_after) |
return false; |
return b_r != e_r; |
} |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
bool |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
cmp_keys(key_const_reference r_lhs_key, |
key_const_reference r_rhs_key) const |
{ |
return cmp_prefixes(base_type::begin(r_lhs_key), |
base_type::end(r_lhs_key), |
base_type::begin(r_rhs_key), |
base_type::end(r_rhs_key), |
true); |
} |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
extract_key(const_reference r_val) |
{ return extract_key(r_val, s_set_ind); } |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
extract_key(const_reference r_val, true_type) |
{ return r_val; } |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::key_const_reference |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
extract_key(const_reference r_val, false_type) |
{ return r_val.first; } |
#ifdef _GLIBCXX_DEBUG |
PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
bool |
PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC:: |
operator()(key_const_reference r_lhs, key_const_reference r_rhs) |
{ return cmp_keys(r_lhs, r_rhs); } |
#endif |
#undef PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC |
#undef PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp |
---|
0,0 → 1,111 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/trace_fn_imps.hpp |
* Contains an implementation class for pat_trie_. |
*/ |
#ifdef PB_DS_PAT_TRIE_TRACE_ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace() const |
{ |
std::cerr << std::endl; |
if (m_p_head->m_p_parent == 0) |
return; |
trace_node(m_p_head->m_p_parent, 0); |
std::cerr << std::endl; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace_node(node_const_pointer p_nd, size_type level) |
{ |
for (size_type i = 0; i < level; ++i) |
std::cerr << ' '; |
std::cerr << p_nd << " "; |
std::cerr << ((p_nd->m_type == pat_trie_leaf_node_type) ? "l " : "i "); |
trace_node_metadata(p_nd, type_to_type<typename node::metadata_type>()); |
typename access_traits::const_iterator el_it = pref_begin(p_nd); |
while (el_it != pref_end(p_nd)) |
{ |
std::cerr <<* el_it; |
++el_it; |
} |
if (p_nd->m_type == pat_trie_leaf_node_type) |
{ |
std::cerr << std::endl; |
return; |
} |
inode_const_pointer p_internal = static_cast<inode_const_pointer>(p_nd); |
std::cerr << " " << |
static_cast<unsigned long>(p_internal->get_e_ind()) << std::endl; |
const size_type num_children = std::distance(p_internal->begin(), |
p_internal->end()); |
for (size_type child_i = 0; child_i < num_children; ++child_i) |
{ |
typename inode::const_iterator child_it = p_internal->begin(); |
std::advance(child_it, num_children - child_i - 1); |
trace_node(*child_it, level + 1); |
} |
} |
PB_DS_CLASS_T_DEC |
template<typename Metadata_> |
void |
PB_DS_CLASS_C_DEC:: |
trace_node_metadata(node_const_pointer p_nd, type_to_type<Metadata_>) |
{ |
std::cerr << "(" << static_cast<unsigned long>(p_nd->get_metadata()) << ") "; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace_node_metadata(node_const_pointer, type_to_type<null_type>) |
{ } |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/traits.hpp |
---|
0,0 → 1,148 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/traits.hpp |
* Contains an implementation class for pat_trie_. |
*/ |
#ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP |
#define PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP |
#include <ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp> |
#include <ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Specialization. |
/// @ingroup traits |
template<typename Key, |
typename Mapped, |
typename _ATraits, |
template<typename Node_CItr, |
typename Node_Itr, |
typename Cmp_Fn_, |
typename _Alloc_> |
class Node_Update, |
typename _Alloc> |
struct trie_traits<Key, Mapped, _ATraits, Node_Update, pat_trie_tag, _Alloc> |
{ |
private: |
typedef pat_trie_base base_type; |
typedef types_traits<Key, Mapped, _Alloc, false> type_traits; |
public: |
typedef typename trie_node_metadata_dispatch<Key, Mapped, _ATraits, Node_Update, _Alloc>::type metadata_type; |
typedef base_type::_Metadata<metadata_type, _Alloc> metadata; |
typedef _ATraits access_traits; |
/// Type for synthesized traits. |
typedef __gnu_pbds::detail::synth_access_traits<type_traits, false, access_traits> synth_access_traits; |
typedef base_type::_Node_base<synth_access_traits, metadata> node; |
typedef base_type::_Head<synth_access_traits, metadata> head; |
typedef base_type::_Leaf<synth_access_traits, metadata> leaf; |
typedef base_type::_Inode<synth_access_traits, metadata> inode; |
typedef base_type::_Iter<node, leaf, head, inode, true> iterator; |
typedef base_type::_CIter<node, leaf, head, inode, true> const_iterator; |
typedef base_type::_Iter<node, leaf, head, inode, false> reverse_iterator; |
typedef base_type::_CIter<node, leaf, head, inode, false> const_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 base_type::_Node_citer<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_const_iterator; |
typedef base_type::_Node_iter<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_iterator; |
/// Type for node update. |
typedef Node_Update<node_const_iterator, node_iterator, _ATraits, _Alloc> node_update; |
typedef null_node_update<node_const_iterator, node_iterator, _ATraits, _Alloc>* null_node_update_pointer; |
}; |
/// Specialization. |
/// @ingroup traits |
template<typename Key, |
typename _ATraits, |
template<typename Node_CItr, |
typename Node_Itr, |
typename Cmp_Fn_, |
typename _Alloc_> |
class Node_Update, |
typename _Alloc> |
struct trie_traits<Key, null_type, _ATraits, Node_Update, pat_trie_tag, _Alloc> |
{ |
private: |
typedef pat_trie_base base_type; |
typedef types_traits<Key, null_type, _Alloc, false> type_traits; |
public: |
typedef typename trie_node_metadata_dispatch<Key, null_type, _ATraits, Node_Update, _Alloc>::type metadata_type; |
typedef base_type::_Metadata<metadata_type, _Alloc> metadata; |
typedef _ATraits access_traits; |
/// Type for synthesized traits. |
typedef __gnu_pbds::detail::synth_access_traits<type_traits, true, access_traits> synth_access_traits; |
typedef base_type::_Node_base<synth_access_traits, metadata> node; |
typedef base_type::_Head<synth_access_traits, metadata> head; |
typedef base_type::_Leaf<synth_access_traits, metadata> leaf; |
typedef base_type::_Inode<synth_access_traits, metadata> inode; |
typedef base_type::_CIter<node, leaf, head, inode, true> const_iterator; |
typedef const_iterator iterator; |
typedef base_type::_CIter<node, leaf, head, inode, false> 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 base_type::_Node_citer<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_const_iterator; |
typedef node_const_iterator node_iterator; |
/// Type for node update. |
typedef Node_Update<node_const_iterator, node_iterator, _ATraits, _Alloc> node_update; |
typedef null_node_update<node_const_iterator, node_const_iterator, _ATraits, _Alloc>* null_node_update_pointer; |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp |
---|
0,0 → 1,55 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 pat_trie_/update_fn_imps.hpp |
* Contains an implementation class for pat_trie_. |
*/ |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
apply_update(node_pointer, null_node_update_pointer) |
{ } |
PB_DS_CLASS_T_DEC |
template<typename Node_Update_> |
inline void |
PB_DS_CLASS_C_DEC:: |
apply_update(node_pointer p_nd, Node_Update_*) |
{ |
Node_Update_::operator()(node_iterator(p_nd, this), |
node_const_iterator(0, this)); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/priority_queue_base_dispatch.hpp |
---|
0,0 → 1,114 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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/priority_queue_base_dispatch.hpp |
* Contains an pqiative container dispatching base. |
*/ |
#ifndef PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP |
#define PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP |
#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/pairing_heap_/pairing_heap_.hpp> |
#include <ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp> |
#include <ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp> |
#include <ext/pb_ds/detail/binary_heap_/binary_heap_.hpp> |
#include <ext/pb_ds/detail/thin_heap_/thin_heap_.hpp> |
#undef PB_DS_DEBUG_VERIFY |
#undef PB_DS_ASSERT_VALID |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Specialization for pairing_heap. |
template<typename _VTp, typename Cmp_Fn, typename _Alloc> |
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, pairing_heap_tag, |
null_type> |
{ |
/// Dispatched type. |
typedef pairing_heap<_VTp, Cmp_Fn, _Alloc> type; |
}; |
/// Specialization for binomial_heap. |
template<typename _VTp, typename Cmp_Fn, typename _Alloc> |
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, binomial_heap_tag, |
null_type> |
{ |
/// Dispatched type. |
typedef binomial_heap<_VTp, Cmp_Fn, _Alloc> type; |
}; |
/// Specialization for rc_binary_heap. |
template<typename _VTp, typename Cmp_Fn, typename _Alloc> |
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, rc_binomial_heap_tag, |
null_type> |
{ |
/// Dispatched type. |
typedef rc_binomial_heap<_VTp, Cmp_Fn, _Alloc> type; |
}; |
/// Specialization for binary_heap. |
template<typename _VTp, typename Cmp_Fn, typename _Alloc> |
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, binary_heap_tag, |
null_type> |
{ |
/// Dispatched type. |
typedef binary_heap<_VTp, Cmp_Fn, _Alloc> type; |
}; |
/// Specialization for thin_heap. |
template<typename _VTp, typename Cmp_Fn, typename _Alloc> |
struct container_base_dispatch<_VTp, Cmp_Fn, _Alloc, thin_heap_tag, |
null_type> |
{ |
/// Dispatched type. |
typedef thin_heap<_VTp, Cmp_Fn, _Alloc> type; |
}; |
//@} group pbds |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifndef PB_DS_PRIORITY_QUEUE_BASE_DS_DISPATCHER_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,100 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/constructors_destructor_fn_imps.hpp |
* Contains an implementation for rb_tree_. |
*/ |
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_RB_TREE_NAME() |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_RB_TREE_NAME(const Cmp_Fn& r_cmp_fn) : |
base_type(r_cmp_fn) |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_RB_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : |
base_type(r_cmp_fn, r_node_update) |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_RB_TREE_NAME(const PB_DS_CLASS_C_DEC& other) : |
base_type(other) |
{ |
initialize(); |
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)) |
base_type::swap(other); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
initialize() |
{ base_type::m_p_head->m_red = true; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp |
---|
0,0 → 1,81 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/debug_fn_imps.hpp |
* Contains an implementation for rb_tree_. |
*/ |
#ifdef _GLIBCXX_DEBUG |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
assert_node_consistent(const node_pointer p_nd, const char* __file, |
int __line) const |
{ |
if (p_nd == 0) |
return 1; |
const size_type l_height = |
assert_node_consistent(p_nd->m_p_left, __file, __line); |
const size_type r_height = |
assert_node_consistent(p_nd->m_p_right, __file, __line); |
if (p_nd->m_red) |
{ |
PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_left)); |
PB_DS_DEBUG_VERIFY(is_effectively_black(p_nd->m_p_right)); |
} |
PB_DS_DEBUG_VERIFY(l_height == r_height); |
return (p_nd->m_red ? 0 : 1) + l_height; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_valid(const char* __file, int __line) const |
{ |
base_type::assert_valid(__file, __line); |
const node_pointer p_head = base_type::m_p_head; |
PB_DS_DEBUG_VERIFY(p_head->m_red); |
if (p_head->m_p_parent != 0) |
{ |
PB_DS_DEBUG_VERIFY(!p_head->m_p_parent->m_red); |
assert_node_consistent(p_head->m_p_parent, __file, __line); |
} |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp |
---|
0,0 → 1,289 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/erase_fn_imps.hpp |
* Contains an implementation for rb_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
erase(key_const_reference r_key) |
{ |
point_iterator it = this->find(r_key); |
if (it == base_type::end()) |
return false; |
erase(it); |
return true; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
erase(iterator it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (it == base_type::end()) |
return it; |
iterator ret_it = it; |
++ret_it; |
erase_node(it.m_p_nd); |
PB_DS_ASSERT_VALID((*this)) |
return ret_it; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::reverse_iterator |
PB_DS_CLASS_C_DEC:: |
erase(reverse_iterator it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (it.m_p_nd == base_type::m_p_head) |
return it; |
reverse_iterator ret_it = it; |
++ret_it; |
erase_node(it.m_p_nd); |
PB_DS_ASSERT_VALID((*this)) |
return ret_it; |
} |
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) |
{ |
PB_DS_ASSERT_VALID((*this)) |
size_type num_ersd = 0; |
iterator it = base_type::begin(); |
while (it != base_type::end()) |
{ |
if (pred(*it)) |
{ |
++num_ersd; |
it = erase(it); |
} |
else |
++it; |
} |
PB_DS_ASSERT_VALID((*this)) |
return num_ersd; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
erase_node(node_pointer p_nd) |
{ |
remove_node(p_nd); |
base_type::actual_erase_node(p_nd); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
remove_node(node_pointer p_z) |
{ |
this->update_min_max_for_erased_node(p_z); |
node_pointer p_y = p_z; |
node_pointer p_x = 0; |
node_pointer p_new_x_parent = 0; |
if (p_y->m_p_left == 0) |
p_x = p_y->m_p_right; |
else if (p_y->m_p_right == 0) |
p_x = p_y->m_p_left; |
else |
{ |
p_y = p_y->m_p_right; |
while (p_y->m_p_left != 0) |
p_y = p_y->m_p_left; |
p_x = p_y->m_p_right; |
} |
if (p_y == p_z) |
{ |
p_new_x_parent = p_y->m_p_parent; |
if (p_x != 0) |
p_x->m_p_parent = p_y->m_p_parent; |
if (base_type::m_p_head->m_p_parent == p_z) |
base_type::m_p_head->m_p_parent = p_x; |
else if (p_z->m_p_parent->m_p_left == p_z) |
{ |
p_y->m_p_left = p_z->m_p_parent; |
p_z->m_p_parent->m_p_left = p_x; |
} |
else |
{ |
p_y->m_p_left = 0; |
p_z->m_p_parent->m_p_right = p_x; |
} |
} |
else |
{ |
p_z->m_p_left->m_p_parent = p_y; |
p_y->m_p_left = p_z->m_p_left; |
if (p_y != p_z->m_p_right) |
{ |
p_new_x_parent = p_y->m_p_parent; |
if (p_x != 0) |
p_x->m_p_parent = p_y->m_p_parent; |
p_y->m_p_parent->m_p_left = p_x; |
p_y->m_p_right = p_z->m_p_right; |
p_z->m_p_right->m_p_parent = p_y; |
} |
else |
p_new_x_parent = p_y; |
if (base_type::m_p_head->m_p_parent == p_z) |
base_type::m_p_head->m_p_parent = p_y; |
else if (p_z->m_p_parent->m_p_left == p_z) |
p_z->m_p_parent->m_p_left = p_y; |
else |
p_z->m_p_parent->m_p_right = p_y; |
p_y->m_p_parent = p_z->m_p_parent; |
std::swap(p_y->m_red, p_z->m_red); |
p_y = p_z; |
} |
this->update_to_top(p_new_x_parent, (node_update* )this); |
if (p_y->m_red) |
return; |
remove_fixup(p_x, p_new_x_parent); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
remove_fixup(node_pointer p_x, node_pointer p_new_x_parent) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_x == 0 || p_x->m_p_parent == p_new_x_parent); |
while (p_x != base_type::m_p_head->m_p_parent && is_effectively_black(p_x)) |
if (p_x == p_new_x_parent->m_p_left) |
{ |
node_pointer p_w = p_new_x_parent->m_p_right; |
if (p_w->m_red) |
{ |
p_w->m_red = false; |
p_new_x_parent->m_red = true; |
base_type::rotate_left(p_new_x_parent); |
p_w = p_new_x_parent->m_p_right; |
} |
if (is_effectively_black(p_w->m_p_left) |
&& is_effectively_black(p_w->m_p_right)) |
{ |
p_w->m_red = true; |
p_x = p_new_x_parent; |
p_new_x_parent = p_new_x_parent->m_p_parent; |
} |
else |
{ |
if (is_effectively_black(p_w->m_p_right)) |
{ |
if (p_w->m_p_left != 0) |
p_w->m_p_left->m_red = false; |
p_w->m_red = true; |
base_type::rotate_right(p_w); |
p_w = p_new_x_parent->m_p_right; |
} |
p_w->m_red = p_new_x_parent->m_red; |
p_new_x_parent->m_red = false; |
if (p_w->m_p_right != 0) |
p_w->m_p_right->m_red = false; |
base_type::rotate_left(p_new_x_parent); |
this->update_to_top(p_new_x_parent, (node_update* )this); |
break; |
} |
} |
else |
{ |
node_pointer p_w = p_new_x_parent->m_p_left; |
if (p_w->m_red == true) |
{ |
p_w->m_red = false; |
p_new_x_parent->m_red = true; |
base_type::rotate_right(p_new_x_parent); |
p_w = p_new_x_parent->m_p_left; |
} |
if (is_effectively_black(p_w->m_p_right) |
&& is_effectively_black(p_w->m_p_left)) |
{ |
p_w->m_red = true; |
p_x = p_new_x_parent; |
p_new_x_parent = p_new_x_parent->m_p_parent; |
} |
else |
{ |
if (is_effectively_black(p_w->m_p_left)) |
{ |
if (p_w->m_p_right != 0) |
p_w->m_p_right->m_red = false; |
p_w->m_red = true; |
base_type::rotate_left(p_w); |
p_w = p_new_x_parent->m_p_left; |
} |
p_w->m_red = p_new_x_parent->m_red; |
p_new_x_parent->m_red = false; |
if (p_w->m_p_left != 0) |
p_w->m_p_left->m_red = false; |
base_type::rotate_right(p_new_x_parent); |
this->update_to_top(p_new_x_parent, (node_update* )this); |
break; |
} |
} |
if (p_x != 0) |
p_x->m_red = false; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp |
---|
0,0 → 1,39 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/find_fn_imps.hpp |
* Contains an implementation for rb_tree_. |
*/ |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp |
---|
0,0 → 1,46 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/info_fn_imps.hpp |
* Contains an implementation for rb_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
is_effectively_black(const node_pointer p_nd) |
{ return (p_nd == 0 || !p_nd->m_red); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp |
---|
0,0 → 1,115 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/insert_fn_imps.hpp |
* Contains an implementation for rb_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> |
PB_DS_CLASS_C_DEC:: |
insert(const_reference r_value) |
{ |
PB_DS_ASSERT_VALID((*this)) |
std::pair<point_iterator, bool> ins_pair = base_type::insert_leaf(r_value); |
if (ins_pair.second == true) |
{ |
ins_pair.first.m_p_nd->m_red = true; |
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) |
insert_fixup(ins_pair.first.m_p_nd); |
} |
PB_DS_ASSERT_VALID((*this)) |
return ins_pair; |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
insert_fixup(node_pointer p_nd) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_red == true); |
while (p_nd != base_type::m_p_head->m_p_parent && p_nd->m_p_parent->m_red) |
{ |
if (p_nd->m_p_parent == p_nd->m_p_parent->m_p_parent->m_p_left) |
{ |
node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_right; |
if (p_y != 0 && p_y->m_red) |
{ |
p_nd->m_p_parent->m_red = false; |
p_y->m_red = false; |
p_nd->m_p_parent->m_p_parent->m_red = true; |
p_nd = p_nd->m_p_parent->m_p_parent; |
} |
else |
{ |
if (p_nd == p_nd->m_p_parent->m_p_right) |
{ |
p_nd = p_nd->m_p_parent; |
base_type::rotate_left(p_nd); |
} |
p_nd->m_p_parent->m_red = false; |
p_nd->m_p_parent->m_p_parent->m_red = true; |
base_type::rotate_right(p_nd->m_p_parent->m_p_parent); |
} |
} |
else |
{ |
node_pointer p_y = p_nd->m_p_parent->m_p_parent->m_p_left; |
if (p_y != 0 && p_y->m_red) |
{ |
p_nd->m_p_parent->m_red = false; |
p_y->m_red = false; |
p_nd->m_p_parent->m_p_parent->m_red = true; |
p_nd = p_nd->m_p_parent->m_p_parent; |
} |
else |
{ |
if (p_nd == p_nd->m_p_parent->m_p_left) |
{ |
p_nd = p_nd->m_p_parent; |
base_type::rotate_right(p_nd); |
} |
p_nd->m_p_parent->m_red = false; |
p_nd->m_p_parent->m_p_parent->m_red = true; |
base_type::rotate_left(p_nd->m_p_parent->m_p_parent); |
} |
} |
} |
base_type::update_to_top(p_nd, (node_update* )this); |
base_type::m_p_head->m_p_parent->m_red = false; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/node.hpp |
---|
0,0 → 1,139 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/node.hpp |
* Contains an implementation for rb_tree_. |
*/ |
#ifndef PB_DS_RB_TREE_NODE_HPP |
#define PB_DS_RB_TREE_NODE_HPP |
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Node for Red-Black trees. |
template<typename Value_Type, class Metadata, typename _Alloc> |
struct rb_tree_node_ |
{ |
public: |
typedef Value_Type value_type; |
typedef Metadata metadata_type; |
typedef |
typename _Alloc::template rebind< |
rb_tree_node_< |
Value_Type, |
Metadata, |
_Alloc> >::other::pointer |
node_pointer; |
typedef |
typename _Alloc::template rebind< |
metadata_type>::other::reference |
metadata_reference; |
typedef |
typename _Alloc::template rebind< |
metadata_type>::other::const_reference |
metadata_const_reference; |
bool |
special() const |
{ return m_red; } |
metadata_const_reference |
get_metadata() const |
{ return m_metadata; } |
metadata_reference |
get_metadata() |
{ return m_metadata; } |
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ |
void |
trace() const |
{ |
std::cout << PB_DS_V2F(m_value) <<(m_red? " <r> " : " <b> ") |
<< "(" << m_metadata << ")"; |
} |
#endif |
node_pointer m_p_left; |
node_pointer m_p_right; |
node_pointer m_p_parent; |
value_type m_value; |
bool m_red; |
metadata_type m_metadata; |
}; |
template<typename Value_Type, typename _Alloc> |
struct rb_tree_node_<Value_Type, null_type, _Alloc> |
{ |
public: |
typedef Value_Type value_type; |
typedef null_type metadata_type; |
typedef |
typename _Alloc::template rebind< |
rb_tree_node_< |
Value_Type, |
null_type, |
_Alloc> >::other::pointer |
node_pointer; |
bool |
special() const |
{ return m_red; } |
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ |
void |
trace() const |
{ std::cout << PB_DS_V2F(m_value) <<(m_red? " <r> " : " <b> "); } |
#endif |
node_pointer m_p_left; |
node_pointer m_p_right; |
node_pointer m_p_parent; |
value_type m_value; |
bool m_red; |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp |
---|
0,0 → 1,248 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/rb_tree_.hpp |
* Contains an implementation for Red Black trees. |
*/ |
#include <ext/pb_ds/detail/standard_policies.hpp> |
#include <utility> |
#include <vector> |
#include <assert.h> |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#define PB_DS_CLASS_T_DEC \ |
template<typename Key, typename Mapped, typename Cmp_Fn, \ |
typename Node_And_It_Traits, typename _Alloc> |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
# define PB_DS_RB_TREE_NAME rb_tree_map |
# define PB_DS_RB_TREE_BASE_NAME bin_search_tree_map |
#endif |
#ifdef PB_DS_DATA_FALSE_INDICATOR |
# define PB_DS_RB_TREE_NAME rb_tree_set |
# define PB_DS_RB_TREE_BASE_NAME bin_search_tree_set |
#endif |
#define PB_DS_CLASS_C_DEC \ |
PB_DS_RB_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc> |
#define PB_DS_RB_TREE_BASE \ |
PB_DS_RB_TREE_BASE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc> |
/** |
* @brief Red-Black tree. |
* @ingroup branch-detail |
* |
* 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_RB_TREE_NAME : public PB_DS_RB_TREE_BASE |
{ |
private: |
typedef PB_DS_RB_TREE_BASE base_type; |
typedef typename base_type::node_pointer node_pointer; |
public: |
typedef rb_tree_tag container_category; |
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 base_type::key_type key_type; |
typedef typename base_type::key_pointer key_pointer; |
typedef typename base_type::key_const_pointer key_const_pointer; |
typedef typename base_type::key_reference key_reference; |
typedef typename base_type::key_const_reference key_const_reference; |
typedef typename base_type::mapped_type mapped_type; |
typedef typename base_type::mapped_pointer mapped_pointer; |
typedef typename base_type::mapped_const_pointer mapped_const_pointer; |
typedef typename base_type::mapped_reference mapped_reference; |
typedef typename base_type::mapped_const_reference mapped_const_reference; |
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::reference reference; |
typedef typename base_type::const_reference const_reference; |
typedef typename base_type::point_iterator point_iterator; |
typedef typename base_type::const_iterator point_const_iterator; |
typedef typename base_type::iterator iterator; |
typedef typename base_type::const_iterator const_iterator; |
typedef typename base_type::reverse_iterator reverse_iterator; |
typedef typename base_type::const_reverse_iterator const_reverse_iterator; |
typedef typename base_type::node_update node_update; |
PB_DS_RB_TREE_NAME(); |
PB_DS_RB_TREE_NAME(const Cmp_Fn&); |
PB_DS_RB_TREE_NAME(const Cmp_Fn&, const node_update&); |
PB_DS_RB_TREE_NAME(const PB_DS_CLASS_C_DEC&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
template<typename It> |
void |
copy_from_range(It, It); |
inline std::pair<point_iterator, bool> |
insert(const_reference); |
inline mapped_reference |
operator[](key_const_reference r_key) |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
std::pair<point_iterator, bool> ins_pair = |
base_type::insert_leaf(value_type(r_key, mapped_type())); |
if (ins_pair.second == true) |
{ |
ins_pair.first.m_p_nd->m_red = true; |
_GLIBCXX_DEBUG_ONLY(this->structure_only_assert_valid(__FILE__, __LINE__);) |
insert_fixup(ins_pair.first.m_p_nd); |
} |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
return ins_pair.first.m_p_nd->m_value.second; |
#else |
insert(r_key); |
return base_type::s_null_type; |
#endif |
} |
inline bool |
erase(key_const_reference); |
inline iterator |
erase(iterator); |
inline reverse_iterator |
erase(reverse_iterator); |
template<typename Pred> |
inline size_type |
erase_if(Pred); |
void |
join(PB_DS_CLASS_C_DEC&); |
void |
split(key_const_reference, PB_DS_CLASS_C_DEC&); |
private: |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char*, int) const; |
size_type |
assert_node_consistent(const node_pointer, const char*, int) const; |
#endif |
inline static bool |
is_effectively_black(const node_pointer); |
void |
initialize(); |
void |
insert_fixup(node_pointer); |
void |
erase_node(node_pointer); |
void |
remove_node(node_pointer); |
void |
remove_fixup(node_pointer, node_pointer); |
void |
split_imp(node_pointer, PB_DS_CLASS_C_DEC&); |
inline node_pointer |
split_min(); |
std::pair<node_pointer, node_pointer> |
split_min_imp(); |
void |
join_imp(node_pointer, node_pointer); |
std::pair<node_pointer, node_pointer> |
find_join_pos_right(node_pointer, size_type, size_type); |
std::pair<node_pointer, node_pointer> |
find_join_pos_left(node_pointer, size_type, size_type); |
inline size_type |
black_height(node_pointer); |
void |
split_at_node(node_pointer, PB_DS_CLASS_C_DEC&); |
}; |
#define PB_DS_STRUCT_ONLY_ASSERT_VALID(X) \ |
_GLIBCXX_DEBUG_ONLY(X.structure_only_assert_valid(__FILE__, __LINE__);) |
#include <ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp> |
#include <ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp> |
#include <ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp> |
#undef PB_DS_STRUCT_ONLY_ASSERT_VALID |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_RB_TREE_NAME |
#undef PB_DS_RB_TREE_BASE_NAME |
#undef PB_DS_RB_TREE_BASE |
} // namespace detail |
} // namespace __gnu_pbds |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp |
---|
0,0 → 1,306 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/split_join_fn_imps.hpp |
* Contains an implementation for rb_tree_. |
*/ |
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) |
if (base_type::join_prep(other) == false) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
const node_pointer p_x = other.split_min(); |
join_imp(p_x, other.m_p_head->m_p_parent); |
base_type::join_finish(other); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
join_imp(node_pointer p_x, node_pointer p_r) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_x != 0); |
if (p_r != 0) |
p_r->m_red = false; |
const size_type h = black_height(base_type::m_p_head->m_p_parent); |
const size_type other_h = black_height(p_r); |
node_pointer p_x_l; |
node_pointer p_x_r; |
std::pair<node_pointer, node_pointer> join_pos; |
const bool right_join = h >= other_h; |
if (right_join) |
{ |
join_pos = find_join_pos_right(base_type::m_p_head->m_p_parent, |
h, other_h); |
p_x_l = join_pos.first; |
p_x_r = p_r; |
} |
else |
{ |
p_x_l = base_type::m_p_head->m_p_parent; |
base_type::m_p_head->m_p_parent = p_r; |
if (p_r != 0) |
p_r->m_p_parent = base_type::m_p_head; |
join_pos = find_join_pos_left(base_type::m_p_head->m_p_parent, |
h, other_h); |
p_x_r = join_pos.first; |
} |
node_pointer p_parent = join_pos.second; |
if (p_parent == base_type::m_p_head) |
{ |
base_type::m_p_head->m_p_parent = p_x; |
p_x->m_p_parent = base_type::m_p_head; |
} |
else |
{ |
p_x->m_p_parent = p_parent; |
if (right_join) |
p_x->m_p_parent->m_p_right = p_x; |
else |
p_x->m_p_parent->m_p_left = p_x; |
} |
p_x->m_p_left = p_x_l; |
if (p_x_l != 0) |
p_x_l->m_p_parent = p_x; |
p_x->m_p_right = p_x_r; |
if (p_x_r != 0) |
p_x_r->m_p_parent = p_x; |
p_x->m_red = true; |
base_type::initialize_min_max(); |
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) |
base_type::update_to_top(p_x, (node_update* )this); |
insert_fixup(p_x); |
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
split_min() |
{ |
node_pointer p_min = base_type::m_p_head->m_p_left; |
#ifdef _GLIBCXX_DEBUG |
const node_pointer p_head = base_type::m_p_head; |
_GLIBCXX_DEBUG_ASSERT(p_min != p_head); |
#endif |
remove_node(p_min); |
return p_min; |
} |
PB_DS_CLASS_T_DEC |
std::pair< |
typename PB_DS_CLASS_C_DEC::node_pointer, |
typename PB_DS_CLASS_C_DEC::node_pointer> |
PB_DS_CLASS_C_DEC:: |
find_join_pos_right(node_pointer p_l, size_type h_l, size_type h_r) |
{ |
_GLIBCXX_DEBUG_ASSERT(h_l >= h_r); |
if (base_type::m_p_head->m_p_parent == 0) |
return (std::make_pair((node_pointer)0, base_type::m_p_head)); |
node_pointer p_l_parent = base_type::m_p_head; |
while (h_l > h_r) |
{ |
if (p_l->m_red == false) |
{ |
_GLIBCXX_DEBUG_ASSERT(h_l > 0); |
--h_l; |
} |
p_l_parent = p_l; |
p_l = p_l->m_p_right; |
} |
if (!is_effectively_black(p_l)) |
{ |
p_l_parent = p_l; |
p_l = p_l->m_p_right; |
} |
_GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_l)); |
_GLIBCXX_DEBUG_ASSERT(black_height(p_l) == h_r); |
_GLIBCXX_DEBUG_ASSERT(p_l == 0 || p_l->m_p_parent == p_l_parent); |
return std::make_pair(p_l, p_l_parent); |
} |
PB_DS_CLASS_T_DEC |
std::pair< |
typename PB_DS_CLASS_C_DEC::node_pointer, |
typename PB_DS_CLASS_C_DEC::node_pointer> |
PB_DS_CLASS_C_DEC:: |
find_join_pos_left(node_pointer p_r, size_type h_l, size_type h_r) |
{ |
_GLIBCXX_DEBUG_ASSERT(h_r > h_l); |
if (base_type::m_p_head->m_p_parent == 0) |
return (std::make_pair((node_pointer)0, |
base_type::m_p_head)); |
node_pointer p_r_parent = base_type::m_p_head; |
while (h_r > h_l) |
{ |
if (p_r->m_red == false) |
{ |
_GLIBCXX_DEBUG_ASSERT(h_r > 0); |
--h_r; |
} |
p_r_parent = p_r; |
p_r = p_r->m_p_left; |
} |
if (!is_effectively_black(p_r)) |
{ |
p_r_parent = p_r; |
p_r = p_r->m_p_left; |
} |
_GLIBCXX_DEBUG_ASSERT(is_effectively_black(p_r)); |
_GLIBCXX_DEBUG_ASSERT(black_height(p_r) == h_l); |
_GLIBCXX_DEBUG_ASSERT(p_r == 0 || p_r->m_p_parent == p_r_parent); |
return std::make_pair(p_r, p_r_parent); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
black_height(node_pointer p_nd) |
{ |
size_type h = 1; |
while (p_nd != 0) |
{ |
if (p_nd->m_red == false) |
++h; |
p_nd = p_nd->m_p_left; |
} |
return h; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
if (base_type::split_prep(r_key, other) == false) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) |
PB_DS_STRUCT_ONLY_ASSERT_VALID(other) |
node_pointer p_nd = this->upper_bound(r_key).m_p_nd; |
do |
{ |
node_pointer p_next_nd = p_nd->m_p_parent; |
if (Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) |
split_at_node(p_nd, other); |
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) |
PB_DS_STRUCT_ONLY_ASSERT_VALID(other) |
p_nd = p_next_nd; |
} |
while (p_nd != base_type::m_p_head); |
base_type::split_finish(other); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
split_at_node(node_pointer p_nd, PB_DS_CLASS_C_DEC& other) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
node_pointer p_l = p_nd->m_p_left; |
node_pointer p_r = p_nd->m_p_right; |
node_pointer p_parent = p_nd->m_p_parent; |
if (p_parent == base_type::m_p_head) |
{ |
base_type::m_p_head->m_p_parent = p_l; |
if (p_l != 0) |
{ |
p_l->m_p_parent = base_type::m_p_head; |
p_l->m_red = false; |
} |
} |
else |
{ |
if (p_parent->m_p_left == p_nd) |
p_parent->m_p_left = p_l; |
else |
p_parent->m_p_right = p_l; |
if (p_l != 0) |
p_l->m_p_parent = p_parent; |
this->update_to_top(p_parent, (node_update* )this); |
if (!p_nd->m_red) |
remove_fixup(p_l, p_parent); |
} |
base_type::initialize_min_max(); |
other.join_imp(p_nd, p_r); |
PB_DS_STRUCT_ONLY_ASSERT_VALID((*this)) |
PB_DS_STRUCT_ONLY_ASSERT_VALID(other) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rb_tree_map_/traits.hpp |
---|
0,0 → 1,102 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rb_tree_map_/traits.hpp |
* Contains an implementation for rb_tree_. |
*/ |
#ifndef PB_DS_RB_TREE_NODE_AND_IT_TRAITS_HPP |
#define PB_DS_RB_TREE_NODE_AND_IT_TRAITS_HPP |
#include <ext/pb_ds/detail/rb_tree_map_/node.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Specialization. |
/// @ingroup traits |
template<typename Key, |
typename Mapped, |
typename Cmp_Fn, |
template<typename Node_CItr, |
typename Node_Itr, |
typename Cmp_Fn_, |
typename _Alloc_> |
class Node_Update, |
typename _Alloc> |
struct tree_traits<Key, Mapped, Cmp_Fn, Node_Update, rb_tree_tag,_Alloc> |
: public bin_search_tree_traits< |
Key, |
Mapped, |
Cmp_Fn, |
Node_Update, |
rb_tree_node_< |
typename types_traits<Key, Mapped, _Alloc, false>::value_type, |
typename tree_node_metadata_dispatch<Key, Mapped, Cmp_Fn, Node_Update, |
_Alloc>::type, |
_Alloc>, |
_Alloc> |
{ }; |
/// Specialization. |
/// @ingroup traits |
template<typename Key, |
typename Cmp_Fn, |
template<typename Node_CItr, |
typename Node_Itr, |
typename Cmp_Fn_, |
typename _Alloc_> |
class Node_Update, |
typename _Alloc> |
struct tree_traits<Key, null_type, Cmp_Fn, Node_Update, rb_tree_tag,_Alloc> |
: public bin_search_tree_traits< |
Key, |
null_type, |
Cmp_Fn, |
Node_Update, |
rb_tree_node_< |
typename types_traits<Key, null_type, _Alloc, false>::value_type, |
typename tree_node_metadata_dispatch<Key, null_type, Cmp_Fn, Node_Update, |
_Alloc>::type, |
_Alloc>, |
_Alloc> |
{ }; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,84 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rc_binomial_heap_/constructors_destructor_fn_imps.hpp |
* Contains an implementation for rc_binomial_heap_. |
*/ |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
rc_binomial_heap() |
{ |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
rc_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:: |
rc_binomial_heap(const PB_DS_CLASS_C_DEC& other) |
: base_type(other) |
{ |
make_binomial_heap(); |
base_type::find_max(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
~rc_binomial_heap() |
{ } |
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) |
base_type::swap(other); |
m_rc.swap(other.m_rc); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp |
---|
0,0 → 1,121 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rc_binomial_heap_/debug_fn_imps.hpp |
* Contains an implementation for rc_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(false, __file, __line); |
if (!base_type::empty()) |
{ |
PB_DS_DEBUG_VERIFY(base_type::m_p_max != 0); |
base_type::assert_max(__file, __line); |
} |
m_rc.assert_valid(__file, __line); |
if (m_rc.empty()) |
{ |
base_type::assert_valid(true, __file, __line); |
PB_DS_DEBUG_VERIFY(next_2_pointer(base_type::m_p_root) == 0); |
return; |
} |
node_const_pointer p_nd = next_2_pointer(base_type::m_p_root); |
typename rc_t::const_iterator it = m_rc.end(); |
--it; |
while (p_nd != 0) |
{ |
PB_DS_DEBUG_VERIFY(*it == p_nd); |
node_const_pointer p_next = p_nd->m_p_next_sibling; |
PB_DS_DEBUG_VERIFY(p_next != 0); |
PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_next->m_metadata); |
PB_DS_DEBUG_VERIFY(p_next->m_p_next_sibling == 0 || |
p_next->m_metadata < p_next->m_p_next_sibling->m_metadata); |
--it; |
p_nd = next_2_pointer(next_after_0_pointer(p_nd)); |
} |
PB_DS_DEBUG_VERIFY(it + 1 == m_rc.begin()); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_const_pointer |
PB_DS_CLASS_C_DEC:: |
next_2_pointer(node_const_pointer p_nd) |
{ |
if (p_nd == 0) |
return 0; |
node_pointer p_next = p_nd->m_p_next_sibling; |
if (p_next == 0) |
return 0; |
if (p_nd->m_metadata == p_next->m_metadata) |
return p_nd; |
return next_2_pointer(p_next); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_const_pointer |
PB_DS_CLASS_C_DEC:: |
next_after_0_pointer(node_const_pointer p_nd) |
{ |
if (p_nd == 0) |
return 0; |
node_pointer p_next = p_nd->m_p_next_sibling; |
if (p_next == 0) |
return 0; |
if (p_nd->m_metadata < p_next->m_metadata) |
return p_next; |
return next_after_0_pointer(p_next); |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp |
---|
0,0 → 1,107 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rc_binomial_heap_/erase_fn_imps.hpp |
* Contains an implementation for rc_binomial_heap_. |
*/ |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
pop() |
{ |
make_binomial_heap(); |
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); |
base_type::pop(); |
base_type::find_max(); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
clear() |
{ |
base_type::clear(); |
m_rc.clear(); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
make_binomial_heap() |
{ |
node_pointer p_nd = base_type::m_p_root; |
while (p_nd != 0) |
{ |
node_pointer p_next = p_nd->m_p_next_sibling; |
if (p_next == 0) |
p_nd = p_next; |
else if (p_nd->m_metadata == p_next->m_metadata) |
p_nd = link_with_next_sibling(p_nd); |
else if (p_nd->m_metadata < p_next->m_metadata) |
p_nd = p_next; |
#ifdef _GLIBCXX_DEBUG |
else |
_GLIBCXX_DEBUG_ASSERT(0); |
#endif |
} |
m_rc.clear(); |
} |
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) |
{ |
make_binomial_heap(); |
const size_type ersd = base_type::erase_if(pred); |
base_type::find_max(); |
PB_DS_ASSERT_VALID((*this)) |
return ersd; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
erase(point_iterator it) |
{ |
make_binomial_heap(); |
base_type::erase(it); |
base_type::find_max(); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp |
---|
0,0 → 1,154 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rc_binomial_heap_/insert_fn_imps.hpp |
* Contains an implementation for rc_binomial_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)) |
make_0_exposed(); |
PB_DS_ASSERT_VALID((*this)) |
node_pointer p_nd = base_type::get_new_node_for_insert(r_val); |
p_nd->m_p_l_child = p_nd->m_p_prev_or_parent = 0; |
p_nd->m_metadata = 0; |
if (base_type::m_p_max == 0 || Cmp_Fn::operator()(base_type::m_p_max->m_value, r_val)) |
base_type::m_p_max = p_nd; |
p_nd->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_nd; |
base_type::m_p_root = p_nd; |
if (p_nd->m_p_next_sibling != 0&& p_nd->m_p_next_sibling->m_metadata == 0) |
m_rc.push(p_nd); |
PB_DS_ASSERT_VALID((*this)) |
return point_iterator(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((*this)) |
make_binomial_heap(); |
base_type::modify(it, r_new_val); |
base_type::find_max(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
link_with_next_sibling(node_pointer p_nd) |
{ |
node_pointer p_next = p_nd->m_p_next_sibling; |
_GLIBCXX_DEBUG_ASSERT(p_next != 0); |
_GLIBCXX_DEBUG_ASSERT(p_next->m_p_prev_or_parent == p_nd); |
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_next->m_p_prev_or_parent == 0) |
base_type::m_p_root = p_next; |
else |
p_next->m_p_prev_or_parent->m_p_next_sibling = p_next; |
if (base_type::m_p_max == p_nd) |
base_type::m_p_max = p_next; |
base_type::make_child_of(p_nd, p_next); |
++p_next->m_metadata; |
return p_next; |
} |
p_nd->m_p_next_sibling = p_next->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; |
if (base_type::m_p_max == p_next) |
base_type::m_p_max = p_nd; |
base_type::make_child_of(p_next, p_nd); |
++p_nd->m_metadata; |
return p_nd; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
make_0_exposed() |
{ |
if (m_rc.empty()) |
return; |
node_pointer p_nd = m_rc.top(); |
m_rc.pop(); |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_p_next_sibling != 0); |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata); |
node_pointer p_res = link_with_next_sibling(p_nd); |
if (p_res->m_p_next_sibling != 0&& p_res->m_metadata == p_res->m_p_next_sibling->m_metadata) |
m_rc.push(p_res); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp |
---|
0,0 → 1,240 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rc_binomial_heap_/rc.hpp |
* Contains a redundant (binary counter). |
*/ |
#ifndef PB_DS_RC_HPP |
#define PB_DS_RC_HPP |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Redundant binary counter. |
template<typename _Node, typename _Alloc> |
class rc |
{ |
private: |
typedef _Alloc allocator_type; |
typedef typename allocator_type::size_type size_type; |
typedef _Node node; |
typedef typename _Alloc::template rebind<node> __rebind_n; |
typedef typename __rebind_n::other::pointer node_pointer; |
typedef typename _Alloc::template rebind<node_pointer> __rebind_np; |
typedef typename __rebind_np::other::pointer entry_pointer; |
typedef typename __rebind_np::other::const_pointer entry_const_pointer; |
enum |
{ |
max_entries = sizeof(size_type) << 3 |
}; |
public: |
typedef node_pointer entry; |
typedef entry_const_pointer const_iterator; |
rc(); |
rc(const rc&); |
inline void |
swap(rc&); |
inline void |
push(entry); |
inline node_pointer |
top() const; |
inline void |
pop(); |
inline bool |
empty() const; |
inline size_type |
size() const; |
void |
clear(); |
const const_iterator |
begin() const; |
const const_iterator |
end() const; |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char*, int) const; |
#endif |
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ |
void |
trace() const; |
#endif |
private: |
node_pointer m_a_entries[max_entries]; |
size_type m_over_top; |
}; |
template<typename _Node, typename _Alloc> |
rc<_Node, _Alloc>:: |
rc() : m_over_top(0) |
{ PB_DS_ASSERT_VALID((*this)) } |
template<typename _Node, typename _Alloc> |
rc<_Node, _Alloc>:: |
rc(const rc<_Node, _Alloc>& other) : m_over_top(0) |
{ PB_DS_ASSERT_VALID((*this)) } |
template<typename _Node, typename _Alloc> |
inline void |
rc<_Node, _Alloc>:: |
swap(rc<_Node, _Alloc>& other) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
const size_type over_top = std::max(m_over_top, other.m_over_top); |
for (size_type i = 0; i < over_top; ++i) |
std::swap(m_a_entries[i], other.m_a_entries[i]); |
std::swap(m_over_top, other.m_over_top); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
template<typename _Node, typename _Alloc> |
inline void |
rc<_Node, _Alloc>:: |
push(entry p_nd) |
{ |
PB_DS_ASSERT_VALID((*this)) |
_GLIBCXX_DEBUG_ASSERT(m_over_top < max_entries); |
m_a_entries[m_over_top++] = p_nd; |
PB_DS_ASSERT_VALID((*this)) |
} |
template<typename _Node, typename _Alloc> |
inline void |
rc<_Node, _Alloc>:: |
pop() |
{ |
PB_DS_ASSERT_VALID((*this)) |
_GLIBCXX_DEBUG_ASSERT(!empty()); |
--m_over_top; |
PB_DS_ASSERT_VALID((*this)) |
} |
template<typename _Node, typename _Alloc> |
inline typename rc<_Node, _Alloc>::node_pointer |
rc<_Node, _Alloc>:: |
top() const |
{ |
PB_DS_ASSERT_VALID((*this)) |
_GLIBCXX_DEBUG_ASSERT(!empty()); |
return *(m_a_entries + m_over_top - 1); |
} |
template<typename _Node, typename _Alloc> |
inline bool |
rc<_Node, _Alloc>:: |
empty() const |
{ |
PB_DS_ASSERT_VALID((*this)) |
return m_over_top == 0; |
} |
template<typename _Node, typename _Alloc> |
inline typename rc<_Node, _Alloc>::size_type |
rc<_Node, _Alloc>:: |
size() const |
{ return m_over_top; } |
template<typename _Node, typename _Alloc> |
void |
rc<_Node, _Alloc>:: |
clear() |
{ |
PB_DS_ASSERT_VALID((*this)) |
m_over_top = 0; |
PB_DS_ASSERT_VALID((*this)) |
} |
template<typename _Node, typename _Alloc> |
const typename rc<_Node, _Alloc>::const_iterator |
rc<_Node, _Alloc>:: |
begin() const |
{ return& m_a_entries[0]; } |
template<typename _Node, typename _Alloc> |
const typename rc<_Node, _Alloc>::const_iterator |
rc<_Node, _Alloc>:: |
end() const |
{ return& m_a_entries[m_over_top]; } |
#ifdef _GLIBCXX_DEBUG |
template<typename _Node, typename _Alloc> |
void |
rc<_Node, _Alloc>:: |
assert_valid(const char* __file, int __line) const |
{ PB_DS_DEBUG_VERIFY(m_over_top < max_entries); } |
#endif |
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ |
template<typename _Node, typename _Alloc> |
void |
rc<_Node, _Alloc>:: |
trace() const |
{ |
std::cout << "rc" << std::endl; |
for (size_type i = 0; i < m_over_top; ++i) |
std::cerr << m_a_entries[i] << std::endl; |
std::cout << std::endl; |
} |
#endif |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp |
---|
0,0 → 1,171 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rc_binomial_heap_/rc_binomial_heap_.hpp |
* Contains an implementation for redundant-counter binomial heap. |
*/ |
#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> |
#include <ext/pb_ds/detail/rc_binomial_heap_/rc.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 \ |
rc_binomial_heap<Value_Type, Cmp_Fn, _Alloc> |
#define PB_DS_RC_C_DEC \ |
rc<typename binomial_heap_base<Value_Type, Cmp_Fn, _Alloc>::node, _Alloc> |
/** |
* Redundant-counter binomial heap. |
* |
* @ingroup heap-detail |
*/ |
template<typename Value_Type, typename Cmp_Fn, typename _Alloc> |
class rc_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; |
typedef PB_DS_RC_C_DEC rc_t; |
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; |
rc_binomial_heap(); |
rc_binomial_heap(const Cmp_Fn&); |
rc_binomial_heap(const PB_DS_CLASS_C_DEC&); |
~rc_binomial_heap(); |
void |
swap(PB_DS_CLASS_C_DEC&); |
inline point_iterator |
push(const_reference); |
void |
modify(point_iterator, const_reference); |
inline 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&); |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char*, int) const; |
#endif |
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ |
void |
trace() const; |
#endif |
private: |
inline node_pointer |
link_with_next_sibling(node_pointer); |
void |
make_0_exposed(); |
void |
make_binomial_heap(); |
#ifdef _GLIBCXX_DEBUG |
static node_const_pointer |
next_2_pointer(node_const_pointer); |
static node_const_pointer |
next_after_0_pointer(node_const_pointer); |
#endif |
rc_t m_rc; |
}; |
#include <ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp> |
#include <ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp> |
#include <ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp> |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_RC_C_DEC |
} // namespace detail |
} // namespace __gnu_pbds |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp |
---|
0,0 → 1,77 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rc_binomial_heap_/split_join_fn_imps.hpp |
* Contains an implementation for rc_binomial_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)) |
PB_DS_ASSERT_VALID(other) |
make_binomial_heap(); |
other.make_binomial_heap(); |
base_type::split(pred, other); |
base_type::find_max(); |
other.find_max(); |
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) |
make_binomial_heap(); |
other.make_binomial_heap(); |
base_type::join(other); |
base_type::find_max(); |
other.find_max(); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp |
---|
0,0 → 1,52 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 rc_binomial_heap_/trace_fn_imps.hpp |
* Contains an implementation for rc_binomial_heap_. |
*/ |
#ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace() const |
{ |
base_type::trace(); |
m_rc.trace(); |
} |
#endif // #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_ |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp |
---|
0,0 → 1,211 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_max_collision_check_resize_trigger_imp.hpp |
* Contains a resize trigger implementation. |
*/ |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
cc_hash_max_collision_check_resize_trigger(float load) : |
m_load(load), |
m_size(0), |
m_num_col(0), |
m_max_col(0), |
m_resize_needed(false) |
{ } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_find_search_start() |
{ } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_find_search_collision() |
{ } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_find_search_end() |
{ } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_insert_search_start() |
{ m_num_col = 0; } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_insert_search_collision() |
{ ++m_num_col; } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_insert_search_end() |
{ calc_resize_needed(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erase_search_start() |
{ } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erase_search_collision() |
{ } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erase_search_end() |
{ } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_inserted(size_type) |
{ } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erased(size_type) |
{ m_resize_needed = true; } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_cleared() |
{ m_resize_needed = false; } |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
is_resize_needed() const |
{ return m_resize_needed; } |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
is_grow_needed(size_type /*size*/, size_type /*num_used_e*/) const |
{ return m_num_col >= m_max_col; } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_resized(size_type new_size) |
{ |
m_size = new_size; |
#ifdef PB_DS_HT_MAP_RESIZE_TRACE_ |
std::cerr << "chmccrt::notify_resized " |
<< static_cast<unsigned long>(new_size) << std::endl; |
#endif |
calc_max_num_coll(); |
calc_resize_needed(); |
m_num_col = 0; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
calc_max_num_coll() |
{ |
// max_col <-- \sqrt{2 load \ln( 2 m \ln( m ) ) } |
const double ln_arg = 2 * m_size * std::log(double(m_size)); |
m_max_col = size_type(std::ceil(std::sqrt(2 * m_load * std::log(ln_arg)))); |
#ifdef PB_DS_HT_MAP_RESIZE_TRACE_ |
std::cerr << "chmccrt::calc_max_num_coll " |
<< static_cast<unsigned long>(m_size) << " " |
<< static_cast<unsigned long>(m_max_col) << std::endl; |
#endif |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_externally_resized(size_type new_size) |
{ notify_resized(new_size); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ |
std::swap(m_load, other.m_load); |
std::swap(m_size, other.m_size); |
std::swap(m_num_col, other.m_num_col); |
std::swap(m_max_col, other.m_max_col); |
std::swap(m_resize_needed, other.m_resize_needed); |
} |
PB_DS_CLASS_T_DEC |
inline float |
PB_DS_CLASS_C_DEC:: |
get_load() const |
{ |
PB_DS_STATIC_ASSERT(access, external_load_access); |
return m_load; |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
calc_resize_needed() |
{ m_resize_needed = m_resize_needed || m_num_col >= m_max_col; } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
set_load(float load) |
{ |
PB_DS_STATIC_ASSERT(access, external_load_access); |
m_load = load; |
calc_max_num_coll(); |
calc_resize_needed(); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp |
---|
0,0 → 1,90 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_exponential_size_policy_imp.hpp |
* Contains a resize size policy implementation. |
*/ |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
hash_exponential_size_policy(size_type start_size, size_type grow_factor) : |
m_start_size(start_size), |
m_grow_factor(grow_factor) |
{ } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ |
std::swap(m_start_size, other.m_start_size); |
std::swap(m_grow_factor, other.m_grow_factor); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
get_nearest_larger_size(size_type size) const |
{ |
size_type ret = m_start_size; |
while (ret <= size) |
{ |
const size_type next_ret = ret* m_grow_factor; |
if (next_ret < ret) |
__throw_insert_error(); |
ret = next_ret; |
} |
return ret; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
get_nearest_smaller_size(size_type size) const |
{ |
size_type ret = m_start_size; |
while (true) |
{ |
const size_type next_ret = ret* m_grow_factor; |
if (next_ret < ret) |
__throw_resize_error(); |
if (next_ret >= size) |
return (ret); |
ret = next_ret; |
} |
return ret; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp |
---|
0,0 → 1,293 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_load_check_resize_trigger_imp.hpp |
* Contains a resize trigger implementation. |
*/ |
#define PB_DS_ASSERT_VALID(X) \ |
_GLIBCXX_DEBUG_ONLY(X.assert_valid(__FILE__, __LINE__);) |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
hash_load_check_resize_trigger(float load_min, float load_max) |
: m_load_min(load_min), m_load_max(load_max), m_next_shrink_size(0), |
m_next_grow_size(0), m_resize_needed(false) |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_find_search_start() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_find_search_collision() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_find_search_end() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_insert_search_start() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_insert_search_collision() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_insert_search_end() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erase_search_start() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erase_search_collision() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erase_search_end() |
{ PB_DS_ASSERT_VALID((*this)) } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_inserted(size_type num_entries) |
{ |
m_resize_needed = (num_entries >= m_next_grow_size); |
size_base::set_size(num_entries); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erased(size_type num_entries) |
{ |
size_base::set_size(num_entries); |
m_resize_needed = num_entries <= m_next_shrink_size; |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
is_resize_needed() const |
{ |
PB_DS_ASSERT_VALID((*this)) |
return m_resize_needed; |
} |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
is_grow_needed(size_type /*size*/, size_type num_entries) const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_resize_needed); |
return num_entries >= m_next_grow_size; |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
~hash_load_check_resize_trigger() { } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_resized(size_type new_size) |
{ |
m_resize_needed = false; |
m_next_grow_size = size_type(m_load_max * new_size - 1); |
m_next_shrink_size = size_type(m_load_min * new_size); |
#ifdef PB_DS_HT_MAP_RESIZE_TRACE_ |
std::cerr << "hlcrt::notify_resized " << std::endl |
<< "1 " << new_size << std::endl |
<< "2 " << m_load_min << std::endl |
<< "3 " << m_load_max << std::endl |
<< "4 " << m_next_shrink_size << std::endl |
<< "5 " << m_next_grow_size << std::endl; |
#endif |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_externally_resized(size_type new_size) |
{ |
m_resize_needed = false; |
size_type new_grow_size = size_type(m_load_max * new_size - 1); |
size_type new_shrink_size = size_type(m_load_min * new_size); |
#ifdef PB_DS_HT_MAP_RESIZE_TRACE_ |
std::cerr << "hlcrt::notify_externally_resized " << std::endl |
<< "1 " << new_size << std::endl |
<< "2 " << m_load_min << std::endl |
<< "3 " << m_load_max << std::endl |
<< "4 " << m_next_shrink_size << std::endl |
<< "5 " << m_next_grow_size << std::endl |
<< "6 " << new_shrink_size << std::endl |
<< "7 " << new_grow_size << std::endl; |
#endif |
if (new_grow_size >= m_next_grow_size) |
{ |
_GLIBCXX_DEBUG_ASSERT(new_shrink_size >= m_next_shrink_size); |
m_next_grow_size = new_grow_size; |
} |
else |
{ |
_GLIBCXX_DEBUG_ASSERT(new_shrink_size <= m_next_shrink_size); |
m_next_shrink_size = new_shrink_size; |
} |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_cleared() |
{ |
PB_DS_ASSERT_VALID((*this)) |
size_base::set_size(0); |
m_resize_needed = (0 < m_next_shrink_size); |
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) |
size_base::swap(other); |
std::swap(m_load_min, other.m_load_min); |
std::swap(m_load_max, other.m_load_max); |
std::swap(m_resize_needed, other.m_resize_needed); |
std::swap(m_next_grow_size, other.m_next_grow_size); |
std::swap(m_next_shrink_size, other.m_next_shrink_size); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
PB_DS_CLASS_T_DEC |
inline std::pair<float, float> |
PB_DS_CLASS_C_DEC:: |
get_loads() const |
{ |
PB_DS_STATIC_ASSERT(access, external_load_access); |
return std::make_pair(m_load_min, m_load_max); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
set_loads(std::pair<float, float> load_pair) |
{ |
PB_DS_STATIC_ASSERT(access, external_load_access); |
const float old_load_min = m_load_min; |
const float old_load_max = m_load_max; |
const size_type old_next_shrink_size = m_next_shrink_size; |
const size_type old_next_grow_size = m_next_grow_size; |
const bool old_resize_needed = m_resize_needed; |
__try |
{ |
m_load_min = load_pair.first; |
m_load_max = load_pair.second; |
do_resize(static_cast<size_type>(size_base::get_size() / ((m_load_min + m_load_max) / 2))); |
} |
__catch(...) |
{ |
m_load_min = old_load_min; |
m_load_max = old_load_max; |
m_next_shrink_size = old_next_shrink_size; |
m_next_grow_size = old_next_grow_size; |
m_resize_needed = old_resize_needed; |
__throw_exception_again; |
} |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
do_resize(size_type) |
{ std::abort(); } |
#ifdef _GLIBCXX_DEBUG |
# 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) |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_valid(const char* __file, int __line) const |
{ |
PB_DS_DEBUG_VERIFY(m_load_max > m_load_min); |
PB_DS_DEBUG_VERIFY(m_next_grow_size >= m_next_shrink_size); |
} |
# undef PB_DS_DEBUG_VERIFY |
#endif |
#undef PB_DS_ASSERT_VALID |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp |
---|
0,0 → 1,94 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_load_check_resize_trigger_size_base.hpp |
* Contains an base holding size for some resize policies. |
*/ |
#ifndef PB_DS_HASH_LOAD_CHECK_RESIZE_TRIGGER_SIZE_BASE_HPP |
#define PB_DS_HASH_LOAD_CHECK_RESIZE_TRIGGER_SIZE_BASE_HPP |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Primary template. |
template<typename Size_Type, bool Hold_Size> |
class hash_load_check_resize_trigger_size_base; |
/// Specializations. |
template<typename Size_Type> |
class hash_load_check_resize_trigger_size_base<Size_Type, true> |
{ |
protected: |
typedef Size_Type size_type; |
hash_load_check_resize_trigger_size_base(): m_size(0) |
{ } |
inline void |
swap(hash_load_check_resize_trigger_size_base& other) |
{ std::swap(m_size, other.m_size); } |
inline void |
set_size(size_type size) |
{ m_size = size; } |
inline size_type |
get_size() const |
{ return m_size; } |
private: |
size_type m_size; |
}; |
template<typename Size_Type> |
class hash_load_check_resize_trigger_size_base<Size_Type, false> |
{ |
protected: |
typedef Size_Type size_type; |
protected: |
inline void |
swap(hash_load_check_resize_trigger_size_base& other) { } |
inline void |
set_size(size_type size) { } |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp |
---|
0,0 → 1,161 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_prime_size_policy_imp.hpp |
* Contains a resize size policy implementation. |
*/ |
#pragma GCC system_header |
namespace detail |
{ |
enum |
{ |
num_distinct_sizes_32_bit = 30, |
num_distinct_sizes_64_bit = 62, |
num_distinct_sizes = sizeof(std::size_t) != 8 ? |
num_distinct_sizes_32_bit : num_distinct_sizes_64_bit, |
}; |
// Originally taken from the SGI implementation; acknowledged in the docs. |
// Further modified (for 64 bits) from tr1's hashtable. |
static const std::size_t g_a_sizes[num_distinct_sizes_64_bit] = |
{ |
/* 0 */ 5ul, |
/* 1 */ 11ul, |
/* 2 */ 23ul, |
/* 3 */ 47ul, |
/* 4 */ 97ul, |
/* 5 */ 199ul, |
/* 6 */ 409ul, |
/* 7 */ 823ul, |
/* 8 */ 1741ul, |
/* 9 */ 3469ul, |
/* 10 */ 6949ul, |
/* 11 */ 14033ul, |
/* 12 */ 28411ul, |
/* 13 */ 57557ul, |
/* 14 */ 116731ul, |
/* 15 */ 236897ul, |
/* 16 */ 480881ul, |
/* 17 */ 976369ul, |
/* 18 */ 1982627ul, |
/* 19 */ 4026031ul, |
/* 20 */ 8175383ul, |
/* 21 */ 16601593ul, |
/* 22 */ 33712729ul, |
/* 23 */ 68460391ul, |
/* 24 */ 139022417ul, |
/* 25 */ 282312799ul, |
/* 26 */ 573292817ul, |
/* 27 */ 1164186217ul, |
/* 28 */ 2364114217ul, |
/* 29 */ 4294967291ul, |
/* 30 */ (std::size_t)8589934583ull, |
/* 31 */ (std::size_t)17179869143ull, |
/* 32 */ (std::size_t)34359738337ull, |
/* 33 */ (std::size_t)68719476731ull, |
/* 34 */ (std::size_t)137438953447ull, |
/* 35 */ (std::size_t)274877906899ull, |
/* 36 */ (std::size_t)549755813881ull, |
/* 37 */ (std::size_t)1099511627689ull, |
/* 38 */ (std::size_t)2199023255531ull, |
/* 39 */ (std::size_t)4398046511093ull, |
/* 40 */ (std::size_t)8796093022151ull, |
/* 41 */ (std::size_t)17592186044399ull, |
/* 42 */ (std::size_t)35184372088777ull, |
/* 43 */ (std::size_t)70368744177643ull, |
/* 44 */ (std::size_t)140737488355213ull, |
/* 45 */ (std::size_t)281474976710597ull, |
/* 46 */ (std::size_t)562949953421231ull, |
/* 47 */ (std::size_t)1125899906842597ull, |
/* 48 */ (std::size_t)2251799813685119ull, |
/* 49 */ (std::size_t)4503599627370449ull, |
/* 50 */ (std::size_t)9007199254740881ull, |
/* 51 */ (std::size_t)18014398509481951ull, |
/* 52 */ (std::size_t)36028797018963913ull, |
/* 53 */ (std::size_t)72057594037927931ull, |
/* 54 */ (std::size_t)144115188075855859ull, |
/* 55 */ (std::size_t)288230376151711717ull, |
/* 56 */ (std::size_t)576460752303423433ull, |
/* 57 */ (std::size_t)1152921504606846883ull, |
/* 58 */ (std::size_t)2305843009213693951ull, |
/* 59 */ (std::size_t)4611686018427387847ull, |
/* 60 */ (std::size_t)9223372036854775783ull, |
/* 61 */ (std::size_t)18446744073709551557ull, |
}; |
} // namespace detail |
PB_DS_CLASS_T_DEC |
inline |
PB_DS_CLASS_C_DEC:: |
hash_prime_size_policy(size_type n) : m_start_size(n) |
{ m_start_size = get_nearest_larger_size(n); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ std::swap(m_start_size, other.m_start_size); } |
PB_DS_CLASS_T_DEC |
inline PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
get_nearest_larger_size(size_type n) const |
{ |
const std::size_t* const p_upper = std::upper_bound(detail::g_a_sizes, |
detail::g_a_sizes + detail::num_distinct_sizes, n); |
if (p_upper == detail::g_a_sizes + detail::num_distinct_sizes) |
__throw_resize_error(); |
return *p_upper; |
} |
PB_DS_CLASS_T_DEC |
inline PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
get_nearest_smaller_size(size_type n) const |
{ |
const std::size_t* p_lower = std::lower_bound(detail::g_a_sizes, |
detail::g_a_sizes + detail::num_distinct_sizes, n); |
if (*p_lower >= n && p_lower != detail::g_a_sizes) |
--p_lower; |
if (*p_lower < m_start_size) |
return m_start_size; |
return *p_lower; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp |
---|
0,0 → 1,249 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_standard_resize_policy_imp.hpp |
* Contains a resize policy implementation. |
*/ |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
hash_standard_resize_policy() |
: m_size(Size_Policy::get_nearest_larger_size(1)) |
{ trigger_policy_base::notify_externally_resized(m_size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
hash_standard_resize_policy(const Size_Policy& r_size_policy) |
: Size_Policy(r_size_policy), m_size(Size_Policy::get_nearest_larger_size(1)) |
{ trigger_policy_base::notify_externally_resized(m_size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
hash_standard_resize_policy(const Size_Policy& r_size_policy, |
const Trigger_Policy& r_trigger_policy) |
: Size_Policy(r_size_policy), Trigger_Policy(r_trigger_policy), |
m_size(Size_Policy::get_nearest_larger_size(1)) |
{ trigger_policy_base::notify_externally_resized(m_size); } |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
~hash_standard_resize_policy() |
{ } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
swap(PB_DS_CLASS_C_DEC& other) |
{ |
trigger_policy_base::swap(other); |
size_policy_base::swap(other); |
std::swap(m_size, other.m_size); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_find_search_start() |
{ trigger_policy_base::notify_find_search_start(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_find_search_collision() |
{ trigger_policy_base::notify_find_search_collision(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_find_search_end() |
{ trigger_policy_base::notify_find_search_end(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_insert_search_start() |
{ trigger_policy_base::notify_insert_search_start(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_insert_search_collision() |
{ trigger_policy_base::notify_insert_search_collision(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_insert_search_end() |
{ trigger_policy_base::notify_insert_search_end(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erase_search_start() |
{ trigger_policy_base::notify_erase_search_start(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erase_search_collision() |
{ trigger_policy_base::notify_erase_search_collision(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erase_search_end() |
{ trigger_policy_base::notify_erase_search_end(); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_inserted(size_type num_e) |
{ trigger_policy_base::notify_inserted(num_e); } |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
notify_erased(size_type num_e) |
{ trigger_policy_base::notify_erased(num_e); } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_cleared() |
{ trigger_policy_base::notify_cleared(); } |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
is_resize_needed() const |
{ return trigger_policy_base::is_resize_needed(); } |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
get_new_size(size_type size, size_type num_used_e) const |
{ |
if (trigger_policy_base::is_grow_needed(size, num_used_e)) |
return size_policy_base::get_nearest_larger_size(size); |
return size_policy_base::get_nearest_smaller_size(size); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
notify_resized(size_type new_size) |
{ |
trigger_policy_base::notify_resized(new_size); |
m_size = new_size; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
get_actual_size() const |
{ |
PB_DS_STATIC_ASSERT(access, external_size_access); |
return m_size; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
resize(size_type new_size) |
{ |
PB_DS_STATIC_ASSERT(access, external_size_access); |
size_type actual_size = size_policy_base::get_nearest_larger_size(1); |
while (actual_size < new_size) |
{ |
const size_type pot = size_policy_base::get_nearest_larger_size(actual_size); |
if (pot == actual_size && pot < new_size) |
__throw_resize_error(); |
actual_size = pot; |
} |
if (actual_size > 0) |
--actual_size; |
const size_type old_size = m_size; |
__try |
{ |
do_resize(actual_size - 1); |
} |
__catch(insert_error& ) |
{ |
m_size = old_size; |
__throw_resize_error(); |
} |
__catch(...) |
{ |
m_size = old_size; |
__throw_exception_again; |
} |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
do_resize(size_type) |
{ |
// Do nothing |
} |
PB_DS_CLASS_T_DEC |
Trigger_Policy& |
PB_DS_CLASS_C_DEC:: |
get_trigger_policy() |
{ return *this; } |
PB_DS_CLASS_T_DEC |
const Trigger_Policy& |
PB_DS_CLASS_C_DEC:: |
get_trigger_policy() const |
{ return *this; } |
PB_DS_CLASS_T_DEC |
Size_Policy& |
PB_DS_CLASS_C_DEC:: |
get_size_policy() |
{ return *this; } |
PB_DS_CLASS_T_DEC |
const Size_Policy& |
PB_DS_CLASS_C_DEC:: |
get_size_policy() const |
{ return *this; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp |
---|
0,0 → 1,125 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 sample_resize_policy.hpp |
* Contains a sample resize policy for hash tables. |
*/ |
#ifndef PB_DS_SAMPLE_RESIZE_POLICY_HPP |
#define PB_DS_SAMPLE_RESIZE_POLICY_HPP |
namespace __gnu_pbds |
{ |
/// A sample resize policy. |
class sample_resize_policy |
{ |
public: |
/// Size type. |
typedef std::size_t size_type; |
/// Default constructor. |
sample_resize_policy(); |
/// Copy constructor. |
sample_range_hashing(const sample_resize_policy& other); |
/// Swaps content. |
inline void |
swap(sample_resize_policy& other); |
protected: |
/// Notifies a search started. |
inline void |
notify_insert_search_start(); |
/// Notifies a search encountered a collision. |
inline void |
notify_insert_search_collision(); |
/// Notifies a search ended. |
inline void |
notify_insert_search_end(); |
/// Notifies a search started. |
inline void |
notify_find_search_start(); |
/// Notifies a search encountered a collision. |
inline void |
notify_find_search_collision(); |
/// Notifies a search ended. |
inline void |
notify_find_search_end(); |
/// Notifies a search started. |
inline void |
notify_erase_search_start(); |
/// Notifies a search encountered a collision. |
inline void |
notify_erase_search_collision(); |
/// Notifies a search ended. |
inline void |
notify_erase_search_end(); |
/// Notifies an element was inserted. |
inline void |
notify_inserted(size_type num_e); |
/// Notifies an element was erased. |
inline void |
notify_erased(size_type num_e); |
/// Notifies the table was cleared. |
void |
notify_cleared(); |
/// Notifies the table was resized to new_size. |
void |
notify_resized(size_type new_size); |
/// Queries whether a resize is needed. |
inline bool |
is_resize_needed() const; |
/// Queries what the new size should be. |
size_type |
get_new_size(size_type size, size_type num_used_e) const; |
}; |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp |
---|
0,0 → 1,136 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 sample_resize_trigger.hpp |
* Contains a sample resize trigger policy class. |
*/ |
#ifndef PB_DS_SAMPLE_RESIZE_TRIGGER_HPP |
#define PB_DS_SAMPLE_RESIZE_TRIGGER_HPP |
namespace __gnu_pbds |
{ |
/// A sample resize trigger policy. |
class sample_resize_trigger |
{ |
public: |
/// Size type. |
typedef std::size_t size_type; |
/// Default constructor. |
sample_resize_trigger(); |
/// Copy constructor. |
sample_range_hashing(const sample_resize_trigger&); |
/// Swaps content. |
inline void |
swap(sample_resize_trigger&); |
protected: |
/// Notifies a search started. |
inline void |
notify_insert_search_start(); |
/// Notifies a search encountered a collision. |
inline void |
notify_insert_search_collision(); |
/// Notifies a search ended. |
inline void |
notify_insert_search_end(); |
/// Notifies a search started. |
inline void |
notify_find_search_start(); |
/// Notifies a search encountered a collision. |
inline void |
notify_find_search_collision(); |
/// Notifies a search ended. |
inline void |
notify_find_search_end(); |
/// Notifies a search started. |
inline void |
notify_erase_search_start(); |
/// Notifies a search encountered a collision. |
inline void |
notify_erase_search_collision(); |
/// Notifies a search ended. |
inline void |
notify_erase_search_end(); |
/// Notifies an element was inserted. the total number of entries in |
/// the table is num_entries. |
inline void |
notify_inserted(size_type num_entries); |
/// Notifies an element was erased. |
inline void |
notify_erased(size_type num_entries); |
/// Notifies the table was cleared. |
void |
notify_cleared(); |
/// Notifies the table was resized as a result of this object's |
/// signifying that a resize is needed. |
void |
notify_resized(size_type new_size); |
/// Notifies the table was resized externally. |
void |
notify_externally_resized(size_type new_size); |
/// Queries whether a resize is needed. |
inline bool |
is_resize_needed() const; |
/// Queries whether a grow is needed. |
inline bool |
is_grow_needed(size_type size, size_type num_entries) const; |
private: |
/// Resizes to new_size. |
virtual void |
do_resize(size_type); |
}; |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp |
---|
0,0 → 1,73 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 sample_size_policy.hpp |
* Contains a sample size resize-policy. |
*/ |
#ifndef PB_DS_SAMPLE_SIZE_POLICY_HPP |
#define PB_DS_SAMPLE_SIZE_POLICY_HPP |
namespace __gnu_pbds |
{ |
/// A sample size policy. |
class sample_size_policy |
{ |
public: |
/// Size type. |
typedef std::size_t size_type; |
/// Default constructor. |
sample_size_policy(); |
/// Copy constructor. |
sample_range_hashing(const sample_size_policy&); |
/// Swaps content. |
inline void |
swap(sample_size_policy& other); |
protected: |
/// Given a __size size, returns a __size that is larger. |
inline size_type |
get_nearest_larger_size(size_type size) const; |
/// Given a __size size, returns a __size that is smaller. |
inline size_type |
get_nearest_smaller_size(size_type size) const; |
}; |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,102 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/constructors_destructor_fn_imps.hpp |
* Contains an implementation class for splay_tree_. |
*/ |
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_S_TREE_NAME() |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_S_TREE_NAME(const Cmp_Fn& r_cmp_fn) : |
base_type(r_cmp_fn) |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_S_TREE_NAME(const Cmp_Fn& r_cmp_fn, const node_update& r_node_update) : |
base_type(r_cmp_fn, r_node_update) |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
PB_DS_S_TREE_NAME(const PB_DS_CLASS_C_DEC& other) : |
base_type(other) |
{ |
initialize(); |
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) |
base_type::swap(other); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
initialize() |
{ base_type::m_p_head->m_special = true; } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp |
---|
0,0 → 1,75 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/debug_fn_imps.hpp |
* Contains an implementation class for splay_tree_. |
*/ |
#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(__file, __line); |
const node_pointer p_head = base_type::m_p_head; |
assert_special_imp(p_head, __file, __line); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_special_imp(const node_pointer p_nd, |
const char* __file, int __line) const |
{ |
if (p_nd == 0) |
return; |
if (p_nd == base_type::m_p_head) |
{ |
PB_DS_DEBUG_VERIFY(p_nd->m_special); |
assert_special_imp(p_nd->m_p_parent, __file, __line); |
return; |
} |
PB_DS_DEBUG_VERIFY(!p_nd->m_special); |
assert_special_imp(p_nd->m_p_left, __file, __line); |
assert_special_imp(p_nd->m_p_right, __file, __line); |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp |
---|
0,0 → 1,157 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/erase_fn_imps.hpp |
* Contains an implementation class for splay_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
inline bool |
PB_DS_CLASS_C_DEC:: |
erase(key_const_reference r_key) |
{ |
point_iterator it = find(r_key); |
if (it == base_type::end()) |
return false; |
erase(it); |
return true; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
erase(iterator it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (it == base_type::end()) |
return it; |
iterator ret_it = it; |
++ret_it; |
erase_node(it.m_p_nd); |
PB_DS_ASSERT_VALID((*this)) |
return ret_it; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::reverse_iterator |
PB_DS_CLASS_C_DEC:: |
erase(reverse_iterator it) |
{ |
PB_DS_ASSERT_VALID((*this)) |
if (it.m_p_nd == base_type::m_p_head) |
return (it); |
reverse_iterator ret_it = it; |
++ret_it; |
erase_node(it.m_p_nd); |
PB_DS_ASSERT_VALID((*this)) |
return ret_it; |
} |
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) |
{ |
PB_DS_ASSERT_VALID((*this)) |
size_type num_ersd = 0; |
iterator it = base_type::begin(); |
while (it != base_type::end()) |
{ |
if (pred(*it)) |
{ |
++num_ersd; |
it = erase(it); |
} |
else |
++it; |
} |
PB_DS_ASSERT_VALID((*this)) |
return num_ersd; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
erase_node(node_pointer p_nd) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
splay(p_nd); |
PB_DS_ASSERT_VALID((*this)) |
_GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); |
node_pointer p_l = p_nd->m_p_left; |
node_pointer p_r = p_nd->m_p_right; |
base_type::update_min_max_for_erased_node(p_nd); |
base_type::actual_erase_node(p_nd); |
if (p_r == 0) |
{ |
base_type::m_p_head->m_p_parent = p_l; |
if (p_l != 0) |
p_l->m_p_parent = base_type::m_p_head; |
PB_DS_ASSERT_VALID((*this)) |
return; |
} |
node_pointer p_target_r = leftmost(p_r); |
_GLIBCXX_DEBUG_ASSERT(p_target_r != 0); |
p_r->m_p_parent = base_type::m_p_head; |
base_type::m_p_head->m_p_parent = p_r; |
splay(p_target_r); |
_GLIBCXX_DEBUG_ONLY(p_target_r->m_p_left = 0); |
_GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_parent == this->m_p_head); |
_GLIBCXX_DEBUG_ASSERT(this->m_p_head->m_p_parent == p_target_r); |
p_target_r->m_p_left = p_l; |
if (p_l != 0) |
p_l->m_p_parent = p_target_r; |
PB_DS_ASSERT_VALID((*this)) |
this->apply_update(p_target_r, (node_update*)this); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
leftmost(node_pointer p_nd) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
while (p_nd->m_p_left != 0) |
p_nd = p_nd->m_p_left; |
return p_nd; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp |
---|
0,0 → 1,100 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/find_fn_imps.hpp |
* Contains an implementation class for splay_tree_. |
*/ |
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) |
{ |
node_pointer p_found = find_imp(r_key); |
if (p_found != base_type::m_p_head) |
splay(p_found); |
return point_iterator(p_found); |
} |
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 |
{ |
const node_pointer p_found = find_imp(r_key); |
if (p_found != base_type::m_p_head) |
const_cast<PB_DS_CLASS_C_DEC* >(this)->splay(p_found); |
return point_iterator(p_found); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
find_imp(key_const_reference r_key) |
{ |
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__, |
__LINE__);) |
node_pointer p_nd = base_type::m_p_head->m_p_parent; |
while (p_nd != 0) |
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) |
{ |
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) |
return p_nd; |
p_nd = p_nd->m_p_left; |
} |
else |
p_nd = p_nd->m_p_right; |
return base_type::m_p_head; |
} |
PB_DS_CLASS_T_DEC |
inline const typename PB_DS_CLASS_C_DEC::node_pointer |
PB_DS_CLASS_C_DEC:: |
find_imp(key_const_reference r_key) const |
{ |
PB_DS_ASSERT_VALID((*this)) |
node_pointer p_nd = base_type::m_p_head->m_p_parent; |
while (p_nd != 0) |
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), r_key)) |
{ |
if (!Cmp_Fn::operator()(r_key, PB_DS_V2F(p_nd->m_value))) |
return p_nd; |
p_nd = p_nd->m_p_left; |
} |
else |
p_nd = p_nd->m_p_right; |
return base_type::m_p_head; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp |
---|
0,0 → 1,39 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/info_fn_imps.hpp |
* Contains an implementation. |
*/ |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp |
---|
0,0 → 1,94 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/insert_fn_imps.hpp |
* Contains an implementation class for splay_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> |
PB_DS_CLASS_C_DEC:: |
insert(const_reference r_value) |
{ |
PB_DS_ASSERT_VALID((*this)) |
std::pair<point_iterator, bool> ins_pair = insert_leaf_imp(r_value); |
ins_pair.first.m_p_nd->m_special = false; |
PB_DS_ASSERT_VALID((*this)) |
splay(ins_pair.first.m_p_nd); |
PB_DS_ASSERT_VALID((*this)) |
return ins_pair; |
} |
PB_DS_CLASS_T_DEC |
inline std::pair<typename PB_DS_CLASS_C_DEC::point_iterator, bool> |
PB_DS_CLASS_C_DEC:: |
insert_leaf_imp(const_reference r_value) |
{ |
_GLIBCXX_DEBUG_ONLY(base_type::structure_only_assert_valid(__FILE__, |
__LINE__);) |
if (base_type::m_size == 0) |
return std::make_pair(base_type::insert_imp_empty(r_value), true); |
node_pointer p_nd = base_type::m_p_head->m_p_parent; |
node_pointer p_pot = base_type::m_p_head; |
while (p_nd != 0) |
if (!Cmp_Fn::operator()(PB_DS_V2F(p_nd->m_value), PB_DS_V2F(r_value))) |
{ |
if (!Cmp_Fn::operator()(PB_DS_V2F(r_value), PB_DS_V2F(p_nd->m_value))) |
{ |
return std::make_pair(point_iterator(p_nd), false); |
} |
p_pot = p_nd; |
p_nd = p_nd->m_p_left; |
} |
else |
p_nd = p_nd->m_p_right; |
if (p_pot == base_type::m_p_head) |
return std::make_pair(base_type::insert_leaf_new(r_value, base_type::m_p_head->m_p_right, false), true); |
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(base_type::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(this->insert_leaf_new(r_value, p_nd, false), true); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/node.hpp |
---|
0,0 → 1,126 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/node.hpp |
* Contains an implementation struct for splay_tree_'s node. |
*/ |
#ifndef PB_DS_SPLAY_TREE_NODE_HPP |
#define PB_DS_SPLAY_TREE_NODE_HPP |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Node for splay tree. |
template<typename Value_Type, class Metadata, typename _Alloc> |
struct splay_tree_node_ |
{ |
public: |
typedef Value_Type value_type; |
typedef Metadata metadata_type; |
typedef |
typename _Alloc::template rebind< |
splay_tree_node_<Value_Type, Metadata, _Alloc> >::other::pointer |
node_pointer; |
typedef |
typename _Alloc::template rebind<metadata_type>::other::reference |
metadata_reference; |
typedef |
typename _Alloc::template rebind<metadata_type>::other::const_reference |
metadata_const_reference; |
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ |
void |
trace() const |
{ std::cout << PB_DS_V2F(m_value) << "(" << m_metadata << ")"; } |
#endif |
inline bool |
special() const |
{ return m_special; } |
inline metadata_const_reference |
get_metadata() const |
{ return m_metadata; } |
inline metadata_reference |
get_metadata() |
{ return m_metadata; } |
value_type m_value; |
bool m_special; |
node_pointer m_p_left; |
node_pointer m_p_right; |
node_pointer m_p_parent; |
metadata_type m_metadata; |
}; |
template<typename Value_Type, typename _Alloc> |
struct splay_tree_node_<Value_Type, null_type, _Alloc> |
{ |
public: |
typedef Value_Type value_type; |
typedef null_type metadata_type; |
typedef |
typename _Alloc::template rebind< |
splay_tree_node_<Value_Type, null_type, _Alloc> >::other::pointer |
node_pointer; |
inline bool |
special() const |
{ return m_special; } |
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_ |
void |
trace() const |
{ std::cout << PB_DS_V2F(m_value); } |
#endif |
node_pointer m_p_left; |
node_pointer m_p_right; |
node_pointer m_p_parent; |
value_type m_value; |
bool m_special; |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp |
---|
0,0 → 1,281 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/splay_fn_imps.hpp |
* Contains an implementation class for splay_tree_. |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
splay(node_pointer p_nd) |
{ |
while (p_nd->m_p_parent != base_type::m_p_head) |
{ |
#ifdef _GLIBCXX_DEBUG |
{ |
node_pointer p_head = base_type::m_p_head; |
assert_special_imp(p_head, __FILE__, __LINE__); |
} |
#endif |
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd) |
if (p_nd->m_p_parent->m_p_parent == base_type::m_p_head) |
{ |
base_type::rotate_parent(p_nd); |
_GLIBCXX_DEBUG_ASSERT(p_nd == this->m_p_head->m_p_parent); |
} |
else |
{ |
const node_pointer p_parent = p_nd->m_p_parent; |
const node_pointer p_grandparent = p_parent->m_p_parent; |
#ifdef _GLIBCXX_DEBUG |
const size_type total = |
base_type::recursive_count(p_grandparent); |
_GLIBCXX_DEBUG_ASSERT(total >= 3); |
#endif |
if (p_parent->m_p_left == p_nd && |
p_grandparent->m_p_right == p_parent) |
splay_zig_zag_left(p_nd, p_parent, p_grandparent); |
else if (p_parent->m_p_right == p_nd && |
p_grandparent->m_p_left == p_parent) |
splay_zig_zag_right(p_nd, p_parent, p_grandparent); |
else if (p_parent->m_p_left == p_nd && |
p_grandparent->m_p_left == p_parent) |
splay_zig_zig_left(p_nd, p_parent, p_grandparent); |
else |
splay_zig_zig_right(p_nd, p_parent, p_grandparent); |
_GLIBCXX_DEBUG_ASSERT(total ==this->recursive_count(p_nd)); |
} |
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd) |
} |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
splay_zig_zag_left(node_pointer p_nd, node_pointer p_parent, |
node_pointer p_grandparent) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); |
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); |
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) |
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && |
p_grandparent->m_p_right == p_parent); |
splay_zz_start(p_nd, p_parent, p_grandparent); |
node_pointer p_b = p_nd->m_p_right; |
node_pointer p_c = p_nd->m_p_left; |
p_nd->m_p_right = p_parent; |
p_parent->m_p_parent = p_nd; |
p_nd->m_p_left = p_grandparent; |
p_grandparent->m_p_parent = p_nd; |
p_parent->m_p_left = p_b; |
if (p_b != 0) |
p_b->m_p_parent = p_parent; |
p_grandparent->m_p_right = p_c; |
if (p_c != 0) |
p_c->m_p_parent = p_grandparent; |
splay_zz_end(p_nd, p_parent, p_grandparent); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
splay_zig_zag_right(node_pointer p_nd, node_pointer p_parent, |
node_pointer p_grandparent) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); |
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); |
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) |
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && |
p_grandparent->m_p_left == p_parent); |
splay_zz_start(p_nd, p_parent, p_grandparent); |
node_pointer p_b = p_nd->m_p_left; |
node_pointer p_c = p_nd->m_p_right; |
p_nd->m_p_left = p_parent; |
p_parent->m_p_parent = p_nd; |
p_nd->m_p_right = p_grandparent; |
p_grandparent->m_p_parent = p_nd; |
p_parent->m_p_right = p_b; |
if (p_b != 0) |
p_b->m_p_parent = p_parent; |
p_grandparent->m_p_left = p_c; |
if (p_c != 0) |
p_c->m_p_parent = p_grandparent; |
splay_zz_end(p_nd, p_parent, p_grandparent); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
splay_zig_zig_left(node_pointer p_nd, node_pointer p_parent, |
node_pointer p_grandparent) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); |
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); |
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) |
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_left == p_nd && |
p_nd->m_p_parent->m_p_parent->m_p_left == p_nd->m_p_parent); |
splay_zz_start(p_nd, p_parent, p_grandparent); |
node_pointer p_b = p_nd->m_p_right; |
node_pointer p_c = p_parent->m_p_right; |
p_nd->m_p_right = p_parent; |
p_parent->m_p_parent = p_nd; |
p_parent->m_p_right = p_grandparent; |
p_grandparent->m_p_parent = p_parent; |
p_parent->m_p_left = p_b; |
if (p_b != 0) |
p_b->m_p_parent = p_parent; |
p_grandparent->m_p_left = p_c; |
if (p_c != 0) |
p_c->m_p_parent = p_grandparent; |
splay_zz_end(p_nd, p_parent, p_grandparent); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
splay_zig_zig_right(node_pointer p_nd, node_pointer p_parent, |
node_pointer p_grandparent) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_parent == p_nd->m_p_parent); |
_GLIBCXX_DEBUG_ASSERT(p_grandparent == p_parent->m_p_parent); |
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_grandparent) |
_GLIBCXX_DEBUG_ASSERT(p_parent->m_p_right == p_nd && |
p_nd->m_p_parent->m_p_parent->m_p_right == p_nd->m_p_parent); |
splay_zz_start(p_nd, p_parent, p_grandparent); |
node_pointer p_b = p_nd->m_p_left; |
node_pointer p_c = p_parent->m_p_left; |
p_nd->m_p_left = p_parent; |
p_parent->m_p_parent = p_nd; |
p_parent->m_p_left = p_grandparent; |
p_grandparent->m_p_parent = p_parent; |
p_parent->m_p_right = p_b; |
if (p_b != 0) |
p_b->m_p_parent = p_parent; |
p_grandparent->m_p_right = p_c; |
if (p_c != 0) |
p_c->m_p_parent = p_grandparent; |
base_type::update_to_top(p_grandparent, (node_update*)this); |
splay_zz_end(p_nd, p_parent, p_grandparent); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
splay_zz_start(node_pointer p_nd, |
#ifdef _GLIBCXX_DEBUG |
node_pointer p_parent, |
#else |
node_pointer /*p_parent*/, |
#endif |
node_pointer p_grandparent) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
_GLIBCXX_DEBUG_ASSERT(p_parent != 0); |
_GLIBCXX_DEBUG_ASSERT(p_grandparent != 0); |
const bool grandparent_head = p_grandparent->m_p_parent == base_type::m_p_head; |
if (grandparent_head) |
{ |
base_type::m_p_head->m_p_parent = base_type::m_p_head->m_p_parent; |
p_nd->m_p_parent = base_type::m_p_head; |
return; |
} |
node_pointer p_greatgrandparent = p_grandparent->m_p_parent; |
p_nd->m_p_parent = p_greatgrandparent; |
if (p_grandparent == p_greatgrandparent->m_p_left) |
p_greatgrandparent->m_p_left = p_nd; |
else |
p_greatgrandparent->m_p_right = p_nd; |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
splay_zz_end(node_pointer p_nd, node_pointer p_parent, |
node_pointer p_grandparent) |
{ |
if (p_nd->m_p_parent == base_type::m_p_head) |
base_type::m_p_head->m_p_parent = p_nd; |
this->apply_update(p_grandparent, (node_update*)this); |
this->apply_update(p_parent, (node_update*)this); |
this->apply_update(p_nd, (node_update*)this); |
PB_DS_ASSERT_BASE_NODE_CONSISTENT(p_nd) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp |
---|
0,0 → 1,275 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/splay_tree_.hpp |
* Contains an implementation class for splay trees. |
*/ |
/* |
* This implementation uses an idea from the SGI STL (using a @a header node |
* which is needed for efficient iteration). Following is the SGI STL |
* copyright. |
* |
* 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. |
* |
* |
* 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. |
* |
* |
*/ |
#include <utility> |
#include <vector> |
#include <assert.h> |
#include <debug/debug.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
# define PB_DS_S_TREE_NAME splay_tree_map |
# define PB_DS_S_TREE_BASE_NAME bin_search_tree_map |
#endif |
#ifdef PB_DS_DATA_FALSE_INDICATOR |
# define PB_DS_S_TREE_NAME splay_tree_set |
# define PB_DS_S_TREE_BASE_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_S_TREE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc> |
#define PB_DS_S_TREE_BASE \ |
PB_DS_S_TREE_BASE_NAME<Key, Mapped, Cmp_Fn, Node_And_It_Traits, _Alloc> |
/** |
* @brief Splay tree. |
* @ingroup branch-detail |
*/ |
template<typename Key, typename Mapped, typename Cmp_Fn, |
typename Node_And_It_Traits, typename _Alloc> |
class PB_DS_S_TREE_NAME : public PB_DS_S_TREE_BASE |
{ |
private: |
typedef PB_DS_S_TREE_BASE base_type; |
#ifdef _GLIBCXX_DEBUG |
typedef base_type debug_base; |
#endif |
typedef typename base_type::node_pointer node_pointer; |
public: |
typedef splay_tree_tag container_category; |
typedef _Alloc allocator_type; |
typedef typename _Alloc::size_type size_type; |
typedef typename _Alloc::difference_type difference_type; |
typedef Cmp_Fn cmp_fn; |
typedef typename base_type::key_type key_type; |
typedef typename base_type::key_pointer key_pointer; |
typedef typename base_type::key_const_pointer key_const_pointer; |
typedef typename base_type::key_reference key_reference; |
typedef typename base_type::key_const_reference key_const_reference; |
typedef typename base_type::mapped_type mapped_type; |
typedef typename base_type::mapped_pointer mapped_pointer; |
typedef typename base_type::mapped_const_pointer mapped_const_pointer; |
typedef typename base_type::mapped_reference mapped_reference; |
typedef typename base_type::mapped_const_reference mapped_const_reference; |
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::reference reference; |
typedef typename base_type::const_reference const_reference; |
typedef typename base_type::point_iterator point_iterator; |
typedef typename base_type::const_iterator point_const_iterator; |
typedef typename base_type::iterator iterator; |
typedef typename base_type::const_iterator const_iterator; |
typedef typename base_type::reverse_iterator reverse_iterator; |
typedef typename base_type::const_reverse_iterator const_reverse_iterator; |
typedef typename base_type::node_update node_update; |
PB_DS_S_TREE_NAME(); |
PB_DS_S_TREE_NAME(const Cmp_Fn&); |
PB_DS_S_TREE_NAME(const Cmp_Fn&, const node_update&); |
PB_DS_S_TREE_NAME(const PB_DS_CLASS_C_DEC&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
template<typename It> |
void |
copy_from_range(It, It); |
void |
initialize(); |
inline std::pair<point_iterator, bool> |
insert(const_reference r_value); |
inline mapped_reference |
operator[](key_const_reference r_key) |
{ |
#ifdef PB_DS_DATA_TRUE_INDICATOR |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
std::pair<point_iterator, bool> ins_pair = |
insert_leaf_imp(value_type(r_key, mapped_type())); |
ins_pair.first.m_p_nd->m_special = false; |
_GLIBCXX_DEBUG_ONLY(base_type::assert_valid(__FILE__, __LINE__)); |
splay(ins_pair.first.m_p_nd); |
_GLIBCXX_DEBUG_ONLY(assert_valid(__FILE__, __LINE__);) |
return ins_pair.first.m_p_nd->m_value.second; |
#else |
insert(r_key); |
return base_type::s_null_type; |
#endif |
} |
inline point_iterator |
find(key_const_reference); |
inline point_const_iterator |
find(key_const_reference) const; |
inline bool |
erase(key_const_reference); |
inline iterator |
erase(iterator it); |
inline reverse_iterator |
erase(reverse_iterator); |
template<typename Pred> |
inline size_type |
erase_if(Pred); |
void |
join(PB_DS_CLASS_C_DEC&); |
void |
split(key_const_reference, PB_DS_CLASS_C_DEC&); |
private: |
inline std::pair<point_iterator, bool> |
insert_leaf_imp(const_reference); |
inline node_pointer |
find_imp(key_const_reference); |
inline const node_pointer |
find_imp(key_const_reference) const; |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char* file, int line) const; |
void |
assert_special_imp(const node_pointer, const char* file, int line) const; |
#endif |
void |
splay(node_pointer); |
inline void |
splay_zig_zag_left(node_pointer, node_pointer, node_pointer); |
inline void |
splay_zig_zag_right(node_pointer, node_pointer, node_pointer); |
inline void |
splay_zig_zig_left(node_pointer, node_pointer, node_pointer); |
inline void |
splay_zig_zig_right(node_pointer, node_pointer, node_pointer); |
inline void |
splay_zz_start(node_pointer, node_pointer, node_pointer); |
inline void |
splay_zz_end(node_pointer, node_pointer, node_pointer); |
inline node_pointer |
leftmost(node_pointer); |
void |
erase_node(node_pointer); |
}; |
#define PB_DS_ASSERT_BASE_NODE_CONSISTENT(_Node) \ |
_GLIBCXX_DEBUG_ONLY(base_type::assert_node_consistent(_Node, \ |
__FILE__, __LINE__);) |
#include <ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp> |
#include <ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp> |
#include <ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp> |
#include <ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp> |
#undef PB_DS_ASSERT_BASE_NODE_CONSISTENT |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_S_TREE_NAME |
#undef PB_DS_S_TREE_BASE_NAME |
#undef PB_DS_S_TREE_BASE |
} // namespace detail |
} // namespace __gnu_pbds |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp |
---|
0,0 → 1,112 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/split_join_fn_imps.hpp |
* Contains an implementation class for splay_tree_. |
*/ |
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) |
if (base_type::join_prep(other) == false) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
node_pointer p_target_r = other.leftmost(other.m_p_head); |
_GLIBCXX_DEBUG_ASSERT(p_target_r != 0); |
other.splay(p_target_r); |
_GLIBCXX_DEBUG_ASSERT(p_target_r == other.m_p_head->m_p_parent); |
_GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left == 0); |
p_target_r->m_p_left = base_type::m_p_head->m_p_parent; |
_GLIBCXX_DEBUG_ASSERT(p_target_r->m_p_left != 0); |
p_target_r->m_p_left->m_p_parent = p_target_r; |
base_type::m_p_head->m_p_parent = p_target_r; |
p_target_r->m_p_parent = base_type::m_p_head; |
this->apply_update(p_target_r, (node_update*)this); |
base_type::join_finish(other); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
split(key_const_reference r_key, PB_DS_CLASS_C_DEC& other) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
if (base_type::split_prep(r_key, other) == false) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
return; |
} |
node_pointer p_upper_bound = this->upper_bound(r_key).m_p_nd; |
_GLIBCXX_DEBUG_ASSERT(p_upper_bound != 0); |
splay(p_upper_bound); |
_GLIBCXX_DEBUG_ASSERT(p_upper_bound->m_p_parent == this->m_p_head); |
node_pointer p_new_root = p_upper_bound->m_p_left; |
_GLIBCXX_DEBUG_ASSERT(p_new_root != 0); |
base_type::m_p_head->m_p_parent = p_new_root; |
p_new_root->m_p_parent = base_type::m_p_head; |
other.m_p_head->m_p_parent = p_upper_bound; |
p_upper_bound->m_p_parent = other.m_p_head; |
p_upper_bound->m_p_left = 0; |
this->apply_update(p_upper_bound, (node_update*)this); |
base_type::split_finish(other); |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/splay_tree_/traits.hpp |
---|
0,0 → 1,95 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 splay_tree_/traits.hpp |
* Contains an implementation for splay_tree_. |
*/ |
#ifndef PB_DS_SPLAY_TREE_NODE_AND_IT_TRAITS_HPP |
#define PB_DS_SPLAY_TREE_NODE_AND_IT_TRAITS_HPP |
#include <ext/pb_ds/detail/splay_tree_/node.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Specialization. |
/// @ingroup traits |
template<typename Key, |
typename Mapped, |
typename Cmp_Fn, |
template<typename Node_CItr, |
typename Node_Itr, |
typename Cmp_Fn_, |
typename _Alloc_> |
class Node_Update, |
typename _Alloc> |
struct tree_traits<Key, Mapped, Cmp_Fn, Node_Update, splay_tree_tag, _Alloc> |
: public bin_search_tree_traits<Key, Mapped, Cmp_Fn, Node_Update, |
splay_tree_node_< |
typename types_traits<Key, Mapped, _Alloc, false>::value_type, |
typename tree_node_metadata_dispatch<Key, Mapped, Cmp_Fn, Node_Update, |
_Alloc>::type, |
_Alloc>, |
_Alloc> |
{ }; |
/// Specialization. |
/// @ingroup traits |
template<typename Key, |
class Cmp_Fn, |
template<typename Node_CItr, |
class Node_Itr, |
class Cmp_Fn_, |
typename _Alloc_> |
class Node_Update, |
typename _Alloc> |
struct tree_traits<Key, null_type, Cmp_Fn, Node_Update, |
splay_tree_tag, _Alloc> |
: public bin_search_tree_traits<Key, null_type, Cmp_Fn, Node_Update, |
splay_tree_node_< |
typename types_traits<Key, null_type, _Alloc, false>::value_type, |
typename tree_node_metadata_dispatch<Key, null_type, Cmp_Fn, Node_Update, |
_Alloc>::type, |
_Alloc>, |
_Alloc> |
{ }; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifndef PB_DS_SPLAY_TREE_NODE_AND_IT_TRAITS_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/standard_policies.hpp |
---|
0,0 → 1,158 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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/standard_policies.hpp |
* Contains standard policies for containers. |
*/ |
#ifndef PB_DS_STANDARD_POLICIES_HPP |
#define PB_DS_STANDARD_POLICIES_HPP |
#include <memory> |
#include <ext/pb_ds/hash_policy.hpp> |
#include <ext/pb_ds/list_update_policy.hpp> |
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp> |
#include <ext/pb_ds/tree_policy.hpp> |
#include <ext/pb_ds/trie_policy.hpp> |
#include <ext/pb_ds/tag_and_trait.hpp> |
#include <tr1/functional> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Primary template, default_hash_fn. |
template<typename Key> |
struct default_hash_fn |
{ |
/// Dispatched type. |
typedef std::tr1::hash<Key> type; |
}; |
/// Primary template, default_eq_fn. |
template<typename Key> |
struct default_eq_fn |
{ |
/// Dispatched type. |
typedef std::equal_to<Key> type; |
}; |
/// Enumeration for default behavior of stored hash data. |
enum |
{ |
default_store_hash = false |
}; |
/// Primary template, default_comb_hash_fn. |
struct default_comb_hash_fn |
{ |
/// Dispatched type. |
typedef direct_mask_range_hashing<> type; |
}; |
/// Primary template, default_resize_policy. |
template<typename Comb_Hash_Fn> |
struct default_resize_policy |
{ |
private: |
typedef typename Comb_Hash_Fn::size_type size_type; |
typedef direct_mask_range_hashing<size_type> default_fn; |
typedef is_same<default_fn, Comb_Hash_Fn> same_type; |
typedef hash_exponential_size_policy<size_type> iftrue; |
typedef hash_prime_size_policy iffalse; |
typedef __conditional_type<same_type::value, iftrue, iffalse> cond_type; |
typedef typename cond_type::__type size_policy_type; |
typedef hash_load_check_resize_trigger<false, size_type> trigger; |
public: |
/// Dispatched type. |
typedef hash_standard_resize_policy<size_policy_type, trigger, |
false, size_type> type; |
}; |
/// Default update policy. |
struct default_update_policy |
{ |
/// Dispatched type. |
typedef lu_move_to_front_policy<> type; |
}; |
/// Primary template, default_probe_fn. |
template<typename Comb_Probe_Fn> |
struct default_probe_fn |
{ |
private: |
typedef typename Comb_Probe_Fn::size_type size_type; |
typedef direct_mask_range_hashing<size_type> default_fn; |
typedef is_same<default_fn, Comb_Probe_Fn> same_type; |
typedef linear_probe_fn<size_type> iftrue; |
typedef quadratic_probe_fn<size_type> iffalse; |
typedef __conditional_type<same_type::value, iftrue, iffalse> cond_type; |
public: |
/// Dispatched type. |
typedef typename cond_type::__type type; |
}; |
/// Primary template, default_trie_access_traits. |
template<typename Key> |
struct default_trie_access_traits; |
#define __dtrie_alloc std::allocator<char> |
#define __dtrie_string std::basic_string<Char, Char_Traits, __dtrie_alloc> |
/// Partial specialization, default_trie_access_traits. |
template<typename Char, typename Char_Traits> |
struct default_trie_access_traits<__dtrie_string> |
{ |
private: |
typedef __dtrie_string string_type; |
public: |
/// Dispatched type. |
typedef trie_string_access_traits<string_type> type; |
}; |
#undef __dtrie_alloc |
#undef __dtrie_string |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifndef PB_DS_STANDARD_POLICIES_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp |
---|
0,0 → 1,105 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 thin_heap_/constructors_destructor_fn_imps.hpp |
* Contains an implementation for thin_heap_. |
*/ |
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((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
thin_heap() : m_p_max(0) |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
thin_heap(const Cmp_Fn& r_cmp_fn) |
: base_type(r_cmp_fn), m_p_max(0) |
{ |
initialize(); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
thin_heap(const PB_DS_CLASS_C_DEC& other) |
: base_type(other) |
{ |
initialize(); |
m_p_max = base_type::m_p_root; |
for (node_pointer p_nd = base_type::m_p_root; p_nd != 0; |
p_nd = p_nd->m_p_next_sibling) |
if (Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value)) |
m_p_max = p_nd; |
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)) |
base_type::swap(other); |
std::swap(m_p_max, other.m_p_max); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
~thin_heap() |
{ } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
initialize() |
{ std::fill(m_a_aux, m_a_aux + max_rank, static_cast<node_pointer>(0)); } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp |
---|
0,0 → 1,119 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 thin_heap_/debug_fn_imps.hpp |
* Contains an implementation for thin_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(__file, __line); |
assert_node_consistent(base_type::m_p_root, true, __file, __line); |
assert_max(__file, __line); |
assert_aux_null(__file, __line); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_aux_null(const char* __file, int __line) const |
{ |
for (size_type i = 0; i < max_rank; ++i) |
PB_DS_DEBUG_VERIFY(m_a_aux[i] == 0); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
assert_max(const char* __file, int __line) const |
{ |
if (m_p_max == 0) |
{ |
PB_DS_DEBUG_VERIFY(base_type::empty()); |
return; |
} |
PB_DS_DEBUG_VERIFY(!base_type::empty()); |
PB_DS_DEBUG_VERIFY(base_type::parent(m_p_max) == 0); |
PB_DS_DEBUG_VERIFY(m_p_max->m_p_prev_or_parent == 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 root, |
const char* __file, int __line) const |
{ |
base_type::assert_node_consistent(p_nd, root, __file, __line); |
if (p_nd == 0) |
return; |
assert_node_consistent(p_nd->m_p_next_sibling, root, __file, __line); |
assert_node_consistent(p_nd->m_p_l_child, false, __file, __line); |
if (!root) |
{ |
if (p_nd->m_metadata == 0) |
PB_DS_DEBUG_VERIFY(p_nd->m_p_next_sibling == 0); |
else |
PB_DS_DEBUG_VERIFY(p_nd->m_metadata == p_nd->m_p_next_sibling->m_metadata + 1); |
} |
if (p_nd->m_p_l_child != 0) |
PB_DS_DEBUG_VERIFY(p_nd->m_p_l_child->m_metadata + 1 == base_type::degree(p_nd)); |
const bool unmarked_valid = |
(p_nd->m_p_l_child == 0 && p_nd->m_metadata == 0) |
|| (p_nd->m_p_l_child != 0 |
&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 1); |
const bool marked_valid = |
(p_nd->m_p_l_child == 0 && p_nd->m_metadata == 1) |
|| (p_nd->m_p_l_child != 0 |
&& p_nd->m_metadata == p_nd->m_p_l_child->m_metadata + 2); |
PB_DS_DEBUG_VERIFY(unmarked_valid || marked_valid); |
if (root) |
PB_DS_DEBUG_VERIFY(unmarked_valid); |
} |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp |
---|
0,0 → 1,255 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 thin_heap_/erase_fn_imps.hpp |
* Contains an implementation for thin_heap_. |
*/ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
pop() |
{ |
PB_DS_ASSERT_VALID((*this)) |
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); |
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0); |
node_pointer p_nd = m_p_max; |
remove_max_node(); |
base_type::actual_erase_node(p_nd); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
remove_max_node() |
{ |
to_aux_except_max(); |
make_from_aux(); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
to_aux_except_max() |
{ |
node_pointer p_add = base_type::m_p_root; |
while (p_add != m_p_max) |
{ |
node_pointer p_next_add = p_add->m_p_next_sibling; |
add_to_aux(p_add); |
p_add = p_next_add; |
} |
p_add = m_p_max->m_p_l_child; |
while (p_add != 0) |
{ |
node_pointer p_next_add = p_add->m_p_next_sibling; |
p_add->m_metadata = p_add->m_p_l_child == 0 ? |
0 : p_add->m_p_l_child->m_metadata + 1; |
add_to_aux(p_add); |
p_add = p_next_add; |
} |
p_add = m_p_max->m_p_next_sibling; |
while (p_add != 0) |
{ |
node_pointer p_next_add = p_add->m_p_next_sibling; |
add_to_aux(p_add); |
p_add = p_next_add; |
} |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
add_to_aux(node_pointer p_nd) |
{ |
size_type r = p_nd->m_metadata; |
while (m_a_aux[r] != 0) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < rank_bound()); |
if (Cmp_Fn::operator()(m_a_aux[r]->m_value, p_nd->m_value)) |
make_child_of(m_a_aux[r], p_nd); |
else |
{ |
make_child_of(p_nd, m_a_aux[r]); |
p_nd = m_a_aux[r]; |
} |
m_a_aux[r] = 0; |
++r; |
} |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata < rank_bound()); |
m_a_aux[r] = p_nd; |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
make_child_of(node_pointer p_nd, node_pointer p_new_parent) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_nd->m_metadata == p_new_parent->m_metadata); |
_GLIBCXX_DEBUG_ASSERT(m_a_aux[p_nd->m_metadata] == p_nd || |
m_a_aux[p_nd->m_metadata] == p_new_parent); |
++p_new_parent->m_metadata; |
base_type::make_child_of(p_nd, p_new_parent); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
make_from_aux() |
{ |
base_type::m_p_root = m_p_max = 0; |
const size_type rnk_bnd = rank_bound(); |
size_type i = 0; |
while (i < rnk_bnd) |
{ |
if (m_a_aux[i] != 0) |
{ |
make_root_and_link(m_a_aux[i]); |
m_a_aux[i] = 0; |
} |
++i; |
} |
PB_DS_ASSERT_AUX_NULL((*this)) |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
remove_node(node_pointer p_nd) |
{ |
node_pointer p_parent = p_nd; |
while (base_type::parent(p_parent) != 0) |
p_parent = base_type::parent(p_parent); |
base_type::bubble_to_top(p_nd); |
m_p_max = p_nd; |
node_pointer p_fix = base_type::m_p_root; |
while (p_fix != 0&& p_fix->m_p_next_sibling != p_parent) |
p_fix = p_fix->m_p_next_sibling; |
if (p_fix != 0) |
p_fix->m_p_next_sibling = p_nd; |
remove_max_node(); |
} |
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((*this)) |
_GLIBCXX_DEBUG_ASSERT(!base_type::empty()); |
node_pointer p_nd = it.m_p_nd; |
remove_node(p_nd); |
base_type::actual_erase_node(p_nd); |
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)) |
if (base_type::empty()) |
{ |
PB_DS_ASSERT_VALID((*this)) |
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; |
m_p_max = base_type::m_p_root = 0; |
while (p_cur != 0) |
{ |
node_pointer p_next = p_cur->m_p_next_sibling; |
make_root_and_link(p_cur); |
p_cur = p_next; |
} |
PB_DS_ASSERT_VALID((*this)) |
return ersd; |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
rank_bound() |
{ |
using namespace std; |
const size_t* const p_upper = |
std::upper_bound(g_a_rank_bounds, |
g_a_rank_bounds + num_distinct_rank_bounds, |
base_type::m_size); |
if (p_upper == g_a_rank_bounds + num_distinct_rank_bounds) |
return max_rank; |
return (p_upper - g_a_rank_bounds); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp |
---|
0,0 → 1,51 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 thin_heap_/find_fn_imps.hpp |
* Contains an implementation for thin_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(!base_type::empty()); |
_GLIBCXX_DEBUG_ASSERT(m_p_max != 0); |
return m_p_max->m_value; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp |
---|
0,0 → 1,280 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 thin_heap_/insert_fn_imps.hpp |
* Contains an implementation for thin_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)) |
node_pointer p_nd = base_type::get_new_node_for_insert(r_val); |
p_nd->m_metadata = 0; |
p_nd->m_p_prev_or_parent = p_nd->m_p_l_child = 0; |
if (base_type::m_p_root == 0) |
{ |
p_nd->m_p_next_sibling = 0; |
m_p_max = base_type::m_p_root = p_nd; |
PB_DS_ASSERT_VALID((*this)) |
return point_iterator(p_nd); |
} |
p_nd->m_p_next_sibling = base_type::m_p_root; |
base_type::m_p_root->m_p_prev_or_parent = 0; |
base_type::m_p_root = p_nd; |
update_max(p_nd); |
PB_DS_ASSERT_VALID((*this)) |
return point_iterator(p_nd); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
make_root(node_pointer p_nd) |
{ |
p_nd->m_metadata = p_nd->m_p_l_child == 0 |
? 0 : 1 + p_nd->m_p_l_child->m_metadata; |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
make_root_and_link(node_pointer p_nd) |
{ |
make_root(p_nd); |
p_nd->m_p_prev_or_parent = 0; |
p_nd->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 = 0; |
base_type::m_p_root = p_nd; |
update_max(p_nd); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
fix(node_pointer p_y) |
{ |
while (true) |
{ |
if (p_y->m_p_prev_or_parent == 0) |
{ |
fix_root(p_y); |
return; |
} |
else if (p_y->m_metadata == 1&& p_y->m_p_next_sibling == 0) |
{ |
if (p_y->m_p_l_child != 0) |
{ |
fix_sibling_rank_1_unmarked(p_y); |
return; |
} |
fix_sibling_rank_1_marked(p_y); |
p_y = p_y->m_p_prev_or_parent; |
} |
else if (p_y->m_metadata > p_y->m_p_next_sibling->m_metadata + 1) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child != 0); |
if (p_y->m_metadata != p_y->m_p_l_child->m_metadata + 2) |
{ |
fix_sibling_general_unmarked(p_y); |
return; |
} |
fix_sibling_general_marked(p_y); |
p_y = p_y->m_p_prev_or_parent; |
} |
else if ((p_y->m_p_l_child == 0&& |
p_y->m_metadata == 2) ||(p_y->m_p_l_child != 0&& |
p_y->m_metadata == p_y->m_p_l_child->m_metadata + 3)) |
{ |
node_pointer p_z = p_y->m_p_prev_or_parent; |
fix_child(p_y); |
p_y = p_z; |
} |
else |
return; |
} |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
fix_root(node_pointer p_y) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent == 0); |
make_root(p_y); |
PB_DS_ASSERT_NODE_CONSISTENT(p_y, true) |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
fix_sibling_rank_1_unmarked(node_pointer p_y) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); |
_GLIBCXX_DEBUG_ONLY(node_pointer p_w = p_y->m_p_l_child;) |
_GLIBCXX_DEBUG_ASSERT(p_w != 0); |
_GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling == 0); |
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_next_sibling == 0); |
p_y->m_p_next_sibling = p_y->m_p_l_child; |
p_y->m_p_next_sibling->m_p_prev_or_parent = p_y; |
p_y->m_p_l_child = 0; |
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
fix_sibling_rank_1_marked(node_pointer p_y) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); |
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_l_child == 0); |
p_y->m_metadata = 0; |
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
fix_sibling_general_unmarked(node_pointer p_y) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); |
node_pointer p_w = p_y->m_p_l_child; |
_GLIBCXX_DEBUG_ASSERT(p_w != 0); |
_GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0); |
p_y->m_p_l_child = p_w->m_p_next_sibling; |
p_w->m_p_next_sibling->m_p_prev_or_parent = p_y; |
p_w->m_p_next_sibling = p_y->m_p_next_sibling; |
_GLIBCXX_DEBUG_ASSERT(p_w->m_p_next_sibling != 0); |
p_w->m_p_next_sibling->m_p_prev_or_parent = p_w; |
p_y->m_p_next_sibling = p_w; |
p_w->m_p_prev_or_parent = p_y; |
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
fix_sibling_general_marked(node_pointer p_y) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); |
--p_y->m_metadata; |
PB_DS_ASSERT_NODE_CONSISTENT(p_y, false) |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
fix_child(node_pointer p_y) |
{ |
_GLIBCXX_DEBUG_ASSERT(p_y->m_p_prev_or_parent != 0); |
if (p_y->m_p_next_sibling != 0) |
p_y->m_p_next_sibling->m_p_prev_or_parent = p_y->m_p_prev_or_parent; |
if (p_y->m_p_prev_or_parent->m_p_l_child == p_y) |
p_y->m_p_prev_or_parent->m_p_l_child = p_y->m_p_next_sibling; |
else |
p_y->m_p_prev_or_parent->m_p_next_sibling = p_y->m_p_next_sibling; |
make_root_and_link(p_y); |
} |
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)) |
node_pointer p_nd = it.m_p_nd; |
_GLIBCXX_DEBUG_ASSERT(p_nd != 0); |
const bool smaller = Cmp_Fn::operator()(r_new_val, p_nd->m_value); |
p_nd->m_value = r_new_val; |
if (smaller) |
{ |
remove_node(p_nd); |
p_nd->m_p_l_child = 0; |
make_root_and_link(p_nd); |
PB_DS_ASSERT_VALID((*this)) |
return; |
} |
if (p_nd->m_p_prev_or_parent == 0) |
{ |
update_max(p_nd); |
PB_DS_ASSERT_VALID((*this)) |
return; |
} |
node_pointer p_y = p_nd->m_p_prev_or_parent; |
_GLIBCXX_DEBUG_ASSERT(p_y != 0); |
if (p_nd->m_p_next_sibling != 0) |
p_nd->m_p_next_sibling->m_p_prev_or_parent = p_y; |
if (p_y->m_p_l_child == p_nd) |
p_y->m_p_l_child = p_nd->m_p_next_sibling; |
else |
p_y->m_p_next_sibling = p_nd->m_p_next_sibling; |
fix(p_y); |
make_root_and_link(p_nd); |
PB_DS_ASSERT_VALID((*this)) |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
update_max(node_pointer p_nd) |
{ |
if (m_p_max == 0 || Cmp_Fn::operator()(m_p_max->m_value, p_nd->m_value)) |
m_p_max = p_nd; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp |
---|
0,0 → 1,108 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 thin_heap_/split_join_fn_imps.hpp |
* Contains an implementation for thin_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)) |
PB_DS_ASSERT_VALID(other) |
other.clear(); |
if (base_type::empty()) |
{ |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
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; |
other.make_root_and_link(p_out); |
p_out = p_next; |
} |
PB_DS_ASSERT_VALID(other) |
node_pointer p_cur = base_type::m_p_root; |
m_p_max = 0; |
base_type::m_p_root = 0; |
while (p_cur != 0) |
{ |
node_pointer p_next = p_cur->m_p_next_sibling; |
make_root_and_link(p_cur); |
p_cur = p_next; |
} |
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) |
node_pointer p_other = other.m_p_root; |
while (p_other != 0) |
{ |
node_pointer p_next = p_other->m_p_next_sibling; |
make_root_and_link(p_other); |
p_other = p_next; |
} |
base_type::m_size += other.m_size; |
other.m_p_root = 0; |
other.m_size = 0; |
other.m_p_max = 0; |
PB_DS_ASSERT_VALID((*this)) |
PB_DS_ASSERT_VALID(other) |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp |
---|
0,0 → 1,324 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 thin_heap_/thin_heap_.hpp |
* Contains an implementation class for a thin heap. |
*/ |
#ifndef PB_DS_THIN_HEAP_HPP |
#define PB_DS_THIN_HEAP_HPP |
#include <algorithm> |
#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> |
#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 \ |
thin_heap<Value_Type, Cmp_Fn, _Alloc> |
#ifdef _GLIBCXX_DEBUG |
#define PB_DS_BASE_T_P \ |
<Value_Type, Cmp_Fn, typename _Alloc::size_type, _Alloc, true> |
#else |
#define PB_DS_BASE_T_P \ |
<Value_Type, Cmp_Fn, typename _Alloc::size_type, _Alloc> |
#endif |
/** |
* Thin heap. |
* |
* @ingroup heap-detail |
* |
* See Tarjan and Kaplan. |
*/ |
template<typename Value_Type, typename Cmp_Fn, typename _Alloc> |
class thin_heap |
: public left_child_next_sibling_heap PB_DS_BASE_T_P |
{ |
private: |
typedef typename _Alloc::template rebind<Value_Type>::other __rebind_a; |
typedef left_child_next_sibling_heap PB_DS_BASE_T_P 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_a::pointer pointer; |
typedef typename __rebind_a::const_pointer const_pointer; |
typedef typename __rebind_a::reference reference; |
typedef typename __rebind_a::const_reference const_reference; |
typedef typename base_type::point_iterator point_iterator; |
typedef typename base_type::point_const_iterator point_const_iterator; |
typedef typename base_type::iterator iterator; |
typedef typename base_type::const_iterator const_iterator; |
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: |
thin_heap(); |
thin_heap(const Cmp_Fn&); |
thin_heap(const PB_DS_CLASS_C_DEC&); |
void |
swap(PB_DS_CLASS_C_DEC&); |
~thin_heap(); |
template<typename It> |
void |
copy_from_range(It, It); |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char*, int) const; |
void |
assert_max(const char*, int) const; |
#endif |
#ifdef PB_DS_THIN_HEAP_TRACE_ |
void |
trace() const; |
#endif |
private: |
enum |
{ |
max_rank = (sizeof(size_type) << 4) + 2 |
}; |
void |
initialize(); |
inline void |
update_max(node_pointer); |
inline void |
fix(node_pointer); |
inline void |
fix_root(node_pointer); |
inline void |
fix_sibling_rank_1_unmarked(node_pointer); |
inline void |
fix_sibling_rank_1_marked(node_pointer); |
inline void |
fix_sibling_general_unmarked(node_pointer); |
inline void |
fix_sibling_general_marked(node_pointer); |
inline void |
fix_child(node_pointer); |
inline static void |
make_root(node_pointer); |
inline void |
make_root_and_link(node_pointer); |
inline void |
remove_max_node(); |
void |
to_aux_except_max(); |
inline void |
add_to_aux(node_pointer); |
inline void |
make_from_aux(); |
inline size_type |
rank_bound(); |
inline void |
make_child_of(node_pointer, node_pointer); |
inline void |
remove_node(node_pointer); |
inline node_pointer |
join(node_pointer, node_pointer) const; |
#ifdef _GLIBCXX_DEBUG |
void |
assert_node_consistent(node_const_pointer, bool, const char*, int) const; |
void |
assert_aux_null(const char*, int) const; |
#endif |
node_pointer m_p_max; |
node_pointer m_a_aux[max_rank]; |
}; |
enum |
{ |
num_distinct_rank_bounds = 48 |
}; |
// Taken from the SGI implementation; acknowledged in the docs. |
static const std::size_t g_a_rank_bounds[num_distinct_rank_bounds] = |
{ |
/* Dealing cards... */ |
/* 0 */ 0ul, |
/* 1 */ 1ul, |
/* 2 */ 1ul, |
/* 3 */ 2ul, |
/* 4 */ 4ul, |
/* 5 */ 6ul, |
/* 6 */ 11ul, |
/* 7 */ 17ul, |
/* 8 */ 29ul, |
/* 9 */ 46ul, |
/* 10 */ 76ul, |
/* 11 */ 122ul, |
/* 12 */ 199ul, |
/* 13 */ 321ul, |
/* 14 */ 521ul, |
/* 15 */ 842ul, |
/* 16 */ 1364ul, |
/* 17 */ 2206ul, |
/* 18 */ 3571ul, |
/* 19 */ 5777ul, |
/* 20 */ 9349ul, |
/* 21 */ 15126ul, |
/* 22 */ 24476ul, |
/* 23 */ 39602ul, |
/* 24 */ 64079ul, |
/* 25 */ 103681ul, |
/* 26 */ 167761ul, |
/* 27 */ 271442ul, |
/* 28 */ 439204ul, |
/* 29 */ 710646ul, |
/* 30 */ 1149851ul, |
/* 31 */ 1860497ul, |
/* 32 */ 3010349ul, |
/* 33 */ 4870846ul, |
/* 34 */ 7881196ul, |
/* 35 */ 12752042ul, |
/* 36 */ 20633239ul, |
/* 37 */ 33385282ul, |
/* 38 */ 54018521ul, |
/* 39 */ 87403803ul, |
/* 40 */ 141422324ul, |
/* 41 */ 228826127ul, |
/* 42 */ 370248451ul, |
/* 43 */ 599074578ul, |
/* 44 */ 969323029ul, |
/* 45 */ 1568397607ul, |
/* 46 */ 2537720636ul, |
/* 47 */ 4106118243ul |
/* Pot's good, let's play */ |
}; |
#define PB_DS_ASSERT_NODE_CONSISTENT(_Node, _Bool) \ |
_GLIBCXX_DEBUG_ONLY(assert_node_consistent(_Node, _Bool, \ |
__FILE__, __LINE__);) |
#define PB_DS_ASSERT_AUX_NULL(X) \ |
_GLIBCXX_DEBUG_ONLY(X.assert_aux_null(__FILE__, __LINE__);) |
#include <ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp> |
#include <ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp> |
#include <ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp> |
#include <ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp> |
#include <ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp> |
#include <ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp> |
#include <ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp> |
#undef PB_DS_ASSERT_AUX_NULL |
#undef PB_DS_ASSERT_NODE_CONSISTENT |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_BASE_T_P |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp |
---|
0,0 → 1,53 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 thin_heap_/trace_fn_imps.hpp |
* Contains an implementation class for left_child_next_sibling_heap_. |
*/ |
#ifdef PB_DS_THIN_HEAP_TRACE_ |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace() const |
{ |
std::cerr << std::endl; |
std::cerr << "m_p_max " << m_p_max << std::endl; |
base_type::trace(); |
} |
#endif // #ifdef PB_DS_THIN_HEAP_TRACE_ |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp |
---|
0,0 → 1,103 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 tree_policy/node_metadata_selector.hpp |
* Contains an implementation class for trees. |
*/ |
#ifndef PB_DS_TREE_NODE_METADATA_DISPATCH_HPP |
#define PB_DS_TREE_NODE_METADATA_DISPATCH_HPP |
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp> |
#include <ext/pb_ds/detail/types_traits.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/** |
* @addtogroup traits Traits |
* @{ |
*/ |
/// Tree metadata helper. |
template<typename Node_Update, bool _BTp> |
struct tree_metadata_helper; |
/// Specialization, false. |
template<typename Node_Update> |
struct tree_metadata_helper<Node_Update, false> |
{ |
typedef typename Node_Update::metadata_type type; |
}; |
/// Specialization, true. |
template<typename Node_Update> |
struct tree_metadata_helper<Node_Update, true> |
{ |
typedef null_type type; |
}; |
/// Tree node metadata dispatch. |
template<typename Key, |
typename Data, |
typename Cmp_Fn, |
template<typename Node_CItr, |
typename Const_Iterator, |
typename Cmp_Fn_, |
typename _Alloc_> |
class Node_Update, |
typename _Alloc> |
struct tree_node_metadata_dispatch |
{ |
private: |
typedef dumnode_const_iterator<Key, Data, _Alloc> __it_type; |
typedef Node_Update<__it_type, __it_type, Cmp_Fn, _Alloc> __node_u; |
typedef null_node_update<__it_type, __it_type, Cmp_Fn, _Alloc> __nnode_u; |
enum |
{ |
null_update = is_same<__node_u, __nnode_u>::value |
}; |
public: |
typedef typename tree_metadata_helper<__node_u, null_update>::type type; |
}; |
//@} |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifndef PB_DS_TREE_NODE_METADATA_DISPATCH_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp |
---|
0,0 → 1,121 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 tree_policy/order_statistics_imp.hpp |
* Contains forward declarations for order_statistics_key |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
find_by_order(size_type order) |
{ |
node_iterator it = node_begin(); |
node_iterator end_it = node_end(); |
while (it != end_it) |
{ |
node_iterator l_it = it.get_l_child(); |
const size_type o = (l_it == end_it)? 0 : l_it.get_metadata(); |
if (order == o) |
return *it; |
else if (order < o) |
it = l_it; |
else |
{ |
order -= o + 1; |
it = it.get_r_child(); |
} |
} |
return base_type::end_iterator(); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
find_by_order(size_type order) const |
{ return const_cast<PB_DS_CLASS_C_DEC*>(this)->find_by_order(order); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
order_of_key(key_const_reference r_key) const |
{ |
node_const_iterator it = node_begin(); |
node_const_iterator end_it = node_end(); |
const cmp_fn& r_cmp_fn = const_cast<PB_DS_CLASS_C_DEC*>(this)->get_cmp_fn(); |
size_type ord = 0; |
while (it != end_it) |
{ |
node_const_iterator l_it = it.get_l_child(); |
if (r_cmp_fn(r_key, this->extract_key(*(*it)))) |
it = l_it; |
else if (r_cmp_fn(this->extract_key(*(*it)), r_key)) |
{ |
ord += (l_it == end_it)? 1 : 1 + l_it.get_metadata(); |
it = it.get_r_child(); |
} |
else |
{ |
ord += (l_it == end_it)? 0 : l_it.get_metadata(); |
it = end_it; |
} |
} |
return ord; |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
operator()(node_iterator node_it, node_const_iterator end_nd_it) const |
{ |
node_iterator l_it = node_it.get_l_child(); |
const size_type l_rank = (l_it == end_nd_it) ? 0 : l_it.get_metadata(); |
node_iterator r_it = node_it.get_r_child(); |
const size_type r_rank = (r_it == end_nd_it) ? 0 : r_it.get_metadata(); |
const_cast<metadata_reference>(node_it.get_metadata())= 1 + l_rank + r_rank; |
} |
PB_DS_CLASS_T_DEC |
PB_DS_CLASS_C_DEC:: |
~tree_order_statistics_node_update() |
{ } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp |
---|
0,0 → 1,62 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 tree_policy/sample_tree_node_update.hpp |
* Contains a samle node update functor. |
*/ |
#ifndef PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP |
#define PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP |
namespace __gnu_pbds |
{ |
/// A sample node updator. |
template<typename Const_Node_Iter, typename Node_Iter, typename Cmp_Fn, |
typename _Alloc> |
class sample_tree_node_update |
{ |
typedef std::size_t metadata_type; |
/// Default constructor. |
sample_tree_node_update(); |
/// Updates the rank of a node through a node_iterator node_it; |
/// end_nd_it is the end node iterator. |
inline void |
operator()(node_iterator node_it, node_const_iterator end_nd_it) const; |
}; |
} |
#endif // #ifndef PB_DS_SAMPLE_TREE_NODE_UPDATOR_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/tree_trace_base.hpp |
---|
0,0 → 1,179 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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/tree_trace_base.hpp |
* Contains tree-related policies. |
*/ |
#ifndef PB_DS_TREE_TRACE_BASE_HPP |
#define PB_DS_TREE_TRACE_BASE_HPP |
#ifdef PB_DS_TREE_TRACE |
#include <ext/pb_ds/detail/branch_policy/branch_policy.hpp> |
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
#ifdef PB_DS_TREE_TRACE |
#define PB_DS_CLASS_T_DEC \ |
template<typename Node_CItr, typename Node_Itr, \ |
typename Cmp_Fn, bool Node_Based, typename _Alloc> |
#define PB_DS_CLASS_C_DEC \ |
tree_trace_base<Node_CItr, Node_Itr, Cmp_Fn, \ |
Node_Based, _Alloc> |
#define PB_DS_TRACE_BASE \ |
branch_policy<Node_CItr, Node_Itr, _Alloc> |
/// Tracing base class. |
template<typename Node_CItr, typename Node_Itr, |
typename Cmp_Fn, bool Node_Based, typename _Alloc> |
class tree_trace_base : private PB_DS_TRACE_BASE |
{ |
public: |
void |
trace() const; |
private: |
typedef PB_DS_TRACE_BASE base_type; |
typedef Node_CItr node_const_iterator; |
typedef typename _Alloc::size_type size_type; |
void |
trace_node(node_const_iterator, size_type) const; |
virtual bool |
empty() const = 0; |
virtual node_const_iterator |
node_begin() const = 0; |
virtual node_const_iterator |
node_end() const = 0; |
static void |
print_node_pointer(Node_CItr, integral_constant<int,true>); |
static void |
print_node_pointer(Node_CItr, integral_constant<int,false>); |
template<typename Metadata_> |
static void |
trace_it_metadata(Node_CItr, type_to_type<Metadata_>); |
static void |
trace_it_metadata(Node_CItr, type_to_type<null_type>); |
}; |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace() const |
{ |
if (empty()) |
return; |
trace_node(node_begin(), 0); |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace_node(node_const_iterator nd_it, size_type level) const |
{ |
if (nd_it.get_r_child() != node_end()) |
trace_node(nd_it.get_r_child(), level + 1); |
for (size_type i = 0; i < level; ++i) |
std::cerr << ' '; |
print_node_pointer(nd_it, integral_constant<int,Node_Based>()); |
std::cerr << base_type::extract_key(*(*nd_it)); |
typedef type_to_type<typename node_const_iterator::metadata_type> |
m_type_ind_t; |
trace_it_metadata(nd_it, m_type_ind_t()); |
std::cerr << std::endl; |
if (nd_it.get_l_child() != node_end()) |
trace_node(nd_it.get_l_child(), level + 1); |
} |
PB_DS_CLASS_T_DEC |
template<typename Metadata_> |
void |
PB_DS_CLASS_C_DEC:: |
trace_it_metadata(Node_CItr nd_it, type_to_type<Metadata_>) |
{ |
const unsigned long ul = static_cast<unsigned long>(nd_it.get_metadata()); |
std::cerr << " (" << ul << ") "; |
} |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
trace_it_metadata(Node_CItr, type_to_type<null_type>) |
{ } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
print_node_pointer(Node_CItr nd_it, integral_constant<int,true>) |
{ std::cerr << nd_it.m_p_nd << " "; } |
PB_DS_CLASS_T_DEC |
void |
PB_DS_CLASS_C_DEC:: |
print_node_pointer(Node_CItr nd_it, integral_constant<int,false>) |
{ std::cerr << *nd_it << " "; } |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_TRACE_BASE |
#endif // #ifdef PB_DS_TREE_TRACE |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifdef PB_DS_TREE_TRACE |
#endif // #ifndef PB_DS_TREE_TRACE_BASE_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp |
---|
0,0 → 1,103 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 trie_policy/node_metadata_selector.hpp |
* Contains an implementation class for tries. |
*/ |
#ifndef PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP |
#define PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP |
#include <ext/pb_ds/detail/branch_policy/null_node_metadata.hpp> |
#include <ext/pb_ds/detail/types_traits.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/** |
* @addtogroup traits Traits |
* @{ |
*/ |
/// Trie metadata helper. |
template<typename Node_Update, bool _BTp> |
struct trie_metadata_helper; |
/// Specialization, false. |
template<typename Node_Update> |
struct trie_metadata_helper<Node_Update, false> |
{ |
typedef typename Node_Update::metadata_type type; |
}; |
/// Specialization, true. |
template<typename Node_Update> |
struct trie_metadata_helper<Node_Update, true> |
{ |
typedef null_type type; |
}; |
/// Trie node metadata dispatch. |
template<typename Key, |
typename Data, |
typename Cmp_Fn, |
template<typename Node_CItr, |
typename Const_Iterator, |
typename Cmp_Fn_, |
typename _Alloc_> |
class Node_Update, |
typename _Alloc> |
struct trie_node_metadata_dispatch |
{ |
private: |
typedef dumnode_const_iterator<Key, Data, _Alloc> __it_type; |
typedef Node_Update<__it_type, __it_type, Cmp_Fn, _Alloc> __node_u; |
typedef null_node_update<__it_type, __it_type, Cmp_Fn, _Alloc> __nnode_u; |
enum |
{ |
null_update = is_same<__node_u, __nnode_u>::value |
}; |
public: |
typedef typename trie_metadata_helper<__node_u, null_update>::type type; |
}; |
//@} |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifndef PB_DS_TRIE_NODE_METADATA_DISPATCH_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp |
---|
0,0 → 1,160 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 trie_policy/order_statistics_imp.hpp |
* Contains forward declarations for order_statistics_key |
*/ |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
find_by_order(size_type order) |
{ |
if (empty()) |
return end(); |
++order; |
node_iterator nd_it = node_begin(); |
while (true) |
{ |
if (order > nd_it.get_metadata()) |
return ++base_type::rightmost_it(nd_it); |
const size_type num_children = nd_it.num_children(); |
if (num_children == 0) |
return *nd_it; |
for (size_type i = 0; i < num_children; ++i) |
{ |
node_iterator child_nd_it = nd_it.get_child(i); |
if (order <= child_nd_it.get_metadata()) |
{ |
i = num_children; |
nd_it = child_nd_it; |
} |
else |
order -= child_nd_it.get_metadata(); |
} |
} |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
find_by_order(size_type order) const |
{ return const_cast<PB_DS_CLASS_C_DEC*>(this)->find_by_order(order); } |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
order_of_key(key_const_reference r_key) const |
{ |
const _ATraits& r_traits = |
const_cast<PB_DS_CLASS_C_DEC* >(this)->get_access_traits(); |
return order_of_prefix(r_traits.begin(r_key), r_traits.end(r_key)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
order_of_prefix(typename access_traits::const_iterator b, |
typename access_traits::const_iterator e) const |
{ |
if (empty()) |
return 0; |
const _ATraits& r_traits = |
const_cast<PB_DS_CLASS_C_DEC*>(this)->get_access_traits(); |
node_const_iterator nd_it = node_begin(); |
node_const_iterator end_nd_it = node_end(); |
size_type ord = 0; |
while (true) |
{ |
const size_type num_children = nd_it.num_children(); |
if (num_children == 0) |
{ |
key_const_reference r_key = base_type::extract_key(*(*nd_it)); |
typename access_traits::const_iterator key_b = |
r_traits.begin(r_key); |
typename access_traits::const_iterator key_e = |
r_traits.end(r_key); |
return (base_type::less(key_b, key_e, b, e, r_traits)) ? |
ord + 1 : ord; |
} |
node_const_iterator next_nd_it = end_nd_it; |
size_type i = num_children - 1; |
do |
{ |
node_const_iterator child_nd_it = nd_it.get_child(i); |
if (next_nd_it != end_nd_it) |
ord += child_nd_it.get_metadata(); |
else if (!base_type::less(b, e, |
child_nd_it.valid_prefix().first, |
child_nd_it.valid_prefix().second, |
r_traits)) |
next_nd_it = child_nd_it; |
} |
while (i-- > 0); |
if (next_nd_it == end_nd_it) |
return ord; |
nd_it = next_nd_it; |
} |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
operator()(node_iterator nd_it, node_const_iterator /*end_nd_it*/) const |
{ |
const size_type num_children = nd_it.num_children(); |
size_type children_rank = 0; |
for (size_type i = 0; i < num_children; ++i) |
children_rank += nd_it.get_child(i).get_metadata(); |
const size_type res = (num_children == 0) ? 1 : children_rank; |
const_cast<size_type&>(nd_it.get_metadata()) = res; |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp |
---|
0,0 → 1,139 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 trie_policy/prefix_search_node_update_imp.hpp |
* Contains an implementation of prefix_search_node_update. |
*/ |
PB_DS_CLASS_T_DEC |
std::pair< |
typename PB_DS_CLASS_C_DEC::const_iterator, |
typename PB_DS_CLASS_C_DEC::const_iterator> |
PB_DS_CLASS_C_DEC:: |
prefix_range(key_const_reference r_key) const |
{ |
const access_traits& r_traits = get_access_traits(); |
return (prefix_range(r_traits.begin(r_key), r_traits.end(r_key))); |
} |
PB_DS_CLASS_T_DEC |
std::pair< |
typename PB_DS_CLASS_C_DEC::iterator, |
typename PB_DS_CLASS_C_DEC::iterator> |
PB_DS_CLASS_C_DEC:: |
prefix_range(key_const_reference r_key) |
{ |
return (prefix_range(get_access_traits().begin(r_key), |
get_access_traits().end(r_key))); |
} |
PB_DS_CLASS_T_DEC |
std::pair< |
typename PB_DS_CLASS_C_DEC::const_iterator, |
typename PB_DS_CLASS_C_DEC::const_iterator> |
PB_DS_CLASS_C_DEC:: |
prefix_range(typename access_traits::const_iterator b, |
typename access_traits::const_iterator e) const |
{ |
const std::pair<iterator, iterator> non_const_ret = |
const_cast<PB_DS_CLASS_C_DEC* >(this)->prefix_range(b, e); |
return (std::make_pair(const_iterator(non_const_ret.first), |
const_iterator(non_const_ret.second))); |
} |
PB_DS_CLASS_T_DEC |
std::pair< |
typename PB_DS_CLASS_C_DEC::iterator, |
typename PB_DS_CLASS_C_DEC::iterator> |
PB_DS_CLASS_C_DEC:: |
prefix_range(typename access_traits::const_iterator b, |
typename access_traits::const_iterator e) |
{ |
Node_Itr nd_it = node_begin(); |
Node_Itr end_nd_it = node_end(); |
const access_traits& r_traits = get_access_traits(); |
const size_type given_range_length = std::distance(b, e); |
while (true) |
{ |
if (nd_it == end_nd_it) |
return (std::make_pair(end(), end())); |
const size_type common_range_length = |
base_type::common_prefix_len(nd_it, b, e, r_traits); |
if (common_range_length >= given_range_length) |
{ |
iterator ret_b = this->leftmost_it(nd_it); |
iterator ret_e = this->rightmost_it(nd_it); |
return (std::make_pair(ret_b, ++ret_e)); |
} |
nd_it = next_child(nd_it, b, e, end_nd_it, r_traits); |
} |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::node_iterator |
PB_DS_CLASS_C_DEC:: |
next_child(node_iterator nd_it, typename access_traits::const_iterator b, |
typename access_traits::const_iterator e, node_iterator end_nd_it, |
const access_traits& r_traits) |
{ |
const size_type num_children = nd_it.num_children(); |
node_iterator ret = end_nd_it; |
size_type max_length = 0; |
for (size_type i = 0; i < num_children; ++i) |
{ |
node_iterator pot = nd_it.get_child(i); |
const size_type common_range_length = |
base_type::common_prefix_len(pot, b, e, r_traits); |
if (common_range_length > max_length) |
{ |
ret = pot; |
max_length = common_range_length; |
} |
} |
return (ret); |
} |
PB_DS_CLASS_T_DEC |
inline void |
PB_DS_CLASS_C_DEC:: |
operator()(node_iterator /*nd_it*/, node_const_iterator /*end_nd_it*/) const |
{ } |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/trie_policy/sample_trie_access_traits.hpp |
---|
0,0 → 1,77 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 trie_policy/sample_trie_access_traits.hpp |
* Contains a sample probe policy. |
*/ |
#ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP |
#define PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP |
namespace __gnu_pbds |
{ |
/// A sample trie element access traits. |
struct sample_trie_access_traits |
{ |
typedef std::size_t size_type; |
typedef std::string key_type; |
typedef typename _Alloc::template rebind<key_type> __rebind_k; |
typedef typename __rebind_k::other::const_reference key_const_reference; |
typedef std::string::const_iterator const_iterator; |
/// Element type. |
typedef char e_type; |
enum |
{ |
max_size = 4 |
}; |
/// Returns a const_iterator to the first element of r_key. |
inline static const_iterator |
begin(key_const_reference); |
/// Returns a const_iterator to the after-last element of r_key. |
inline static const_iterator |
end(key_const_reference); |
/// Maps an element to a position. |
inline static size_type |
e_pos(e_type); |
}; |
} |
#endif // #ifndef PB_DS_SAMPLE_TRIE_E_ACCESS_TRAITS_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp |
---|
0,0 → 1,64 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 trie_policy/sample_trie_node_update.hpp |
* Contains a samle node update functor. |
*/ |
#ifndef PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP |
#define PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP |
namespace __gnu_pbds |
{ |
/// A sample node updator. |
template<typename Node_CItr, typename Node_Itr, |
typename _ATraits, typename _Alloc> |
class sample_trie_node_update |
{ |
public: |
typedef std::size_t metadata_type; |
protected: |
/// Default constructor. |
sample_trie_node_update(); |
/// Updates the rank of a node through a node_iterator node_it; |
/// end_nd_it is the end node iterator. |
inline void |
operator()(node_iterator, node_const_iterator) const; |
}; |
} |
#endif // #ifndef PB_DS_SAMPLE_TRIE_NODE_UPDATOR_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp |
---|
0,0 → 1,207 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 trie_policy/trie_policy_base.hpp |
* Contains an implementation of trie_policy_base. |
*/ |
#ifndef PB_DS_TRIE_POLICY_BASE_HPP |
#define PB_DS_TRIE_POLICY_BASE_HPP |
#include <ext/pb_ds/detail/branch_policy/branch_policy.hpp> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/// Base class for trie policies. |
template<typename Node_CItr, typename Node_Itr, |
typename _ATraits, typename _Alloc> |
class trie_policy_base |
: public branch_policy<Node_CItr, Node_Itr, _Alloc> |
{ |
typedef branch_policy<Node_CItr, Node_Itr, _Alloc> base_type; |
public: |
typedef _ATraits access_traits; |
typedef _Alloc allocator_type; |
typedef typename allocator_type::size_type size_type; |
typedef null_type metadata_type; |
typedef Node_CItr node_const_iterator; |
typedef Node_Itr node_iterator; |
typedef typename node_const_iterator::value_type const_iterator; |
typedef typename node_iterator::value_type iterator; |
typedef typename base_type::key_type key_type; |
typedef typename base_type::key_const_reference key_const_reference; |
protected: |
virtual const_iterator |
end() const = 0; |
virtual iterator |
end() = 0; |
virtual node_const_iterator |
node_begin() const = 0; |
virtual node_iterator |
node_begin() = 0; |
virtual node_const_iterator |
node_end() const = 0; |
virtual node_iterator |
node_end() = 0; |
virtual const access_traits& |
get_access_traits() const = 0; |
private: |
typedef typename access_traits::const_iterator e_const_iterator; |
typedef std::pair<e_const_iterator, e_const_iterator> prefix_range_t; |
protected: |
static size_type |
common_prefix_len(node_iterator, e_const_iterator, |
e_const_iterator, const access_traits&); |
static iterator |
leftmost_it(node_iterator); |
static iterator |
rightmost_it(node_iterator); |
static bool |
less(e_const_iterator, e_const_iterator, e_const_iterator, |
e_const_iterator, const access_traits&); |
}; |
#define PB_DS_CLASS_T_DEC \ |
template<typename Node_CItr, typename Node_Itr, \ |
typename _ATraits, typename _Alloc> |
#define PB_DS_CLASS_C_DEC \ |
trie_policy_base<Node_CItr, Node_Itr, _ATraits, _Alloc> |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
common_prefix_len(node_iterator nd_it, e_const_iterator b_r, |
e_const_iterator e_r, const access_traits& r_traits) |
{ |
prefix_range_t pref_range = nd_it.valid_prefix(); |
e_const_iterator b_l = pref_range.first; |
e_const_iterator e_l = pref_range.second; |
const size_type range_length_l = std::distance(b_l, e_l); |
const size_type range_length_r = std::distance(b_r, e_r); |
if (range_length_r < range_length_l) |
{ |
std::swap(b_l, b_r); |
std::swap(e_l, e_r); |
} |
size_type ret = 0; |
while (b_l != e_l) |
{ |
if (r_traits.e_pos(*b_l) != r_traits.e_pos(*b_r)) |
return ret; |
++ret; |
++b_l; |
++b_r; |
} |
return ret; |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
leftmost_it(node_iterator nd_it) |
{ |
if (nd_it.num_children() == 0) |
return *nd_it; |
return leftmost_it(nd_it.get_child(0)); |
} |
PB_DS_CLASS_T_DEC |
typename PB_DS_CLASS_C_DEC::iterator |
PB_DS_CLASS_C_DEC:: |
rightmost_it(node_iterator nd_it) |
{ |
const size_type num_children = nd_it.num_children(); |
if (num_children == 0) |
return *nd_it; |
return rightmost_it(nd_it.get_child(num_children - 1)); |
} |
PB_DS_CLASS_T_DEC |
bool |
PB_DS_CLASS_C_DEC:: |
less(e_const_iterator b_l, e_const_iterator e_l, |
e_const_iterator b_r, e_const_iterator e_r, |
const access_traits& r_traits) |
{ |
while (b_l != e_l) |
{ |
if (b_r == e_r) |
return false; |
size_type l_pos = r_traits.e_pos(*b_l); |
size_type r_pos = r_traits.e_pos(*b_r); |
if (l_pos != r_pos) |
return (l_pos < r_pos); |
++b_l; |
++b_r; |
} |
return b_r != e_r; |
} |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
} // namespace detail |
} // namespace __gnu_pbds |
#endif // #ifndef PB_DS_TRIE_POLICY_BASE_HPP |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/trie_policy/trie_string_access_traits_imp.hpp |
---|
0,0 → 1,99 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 trie_policy/trie_string_access_traits_imp.hpp |
* Contains a policy for extracting character positions from |
* a string for a vector-based PATRICIA tree |
*/ |
PB_DS_CLASS_T_DEC |
detail::integral_constant<int, Reverse> PB_DS_CLASS_C_DEC::s_rev_ind; |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::size_type |
PB_DS_CLASS_C_DEC:: |
e_pos(e_type e) |
{ |
return (static_cast<size_type>(e - min_e_val)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
begin(key_const_reference r_key) |
{ |
return (begin_imp(r_key, s_rev_ind)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
end(key_const_reference r_key) |
{ |
return (end_imp(r_key, s_rev_ind)); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
begin_imp(key_const_reference r_key, detail::false_type) |
{ |
return (r_key.begin()); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
begin_imp(key_const_reference r_key, detail::true_type) |
{ |
return (r_key.rbegin()); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
end_imp(key_const_reference r_key, detail::false_type) |
{ |
return (r_key.end()); |
} |
PB_DS_CLASS_T_DEC |
inline typename PB_DS_CLASS_C_DEC::const_iterator |
PB_DS_CLASS_C_DEC:: |
end_imp(key_const_reference r_key, detail::true_type) |
{ |
return (r_key.rend()); |
} |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/type_utils.hpp |
---|
0,0 → 1,167 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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/type_utils.hpp |
* Contains utilities for handnling types. All of these classes are based on |
* Modern C++ by Andrei Alxandrescu. |
*/ |
#ifndef PB_DS_TYPE_UTILS_HPP |
#define PB_DS_TYPE_UTILS_HPP |
#include <cstddef> |
#include <utility> |
#include <tr1/type_traits> |
#include <ext/type_traits.h> |
#include <ext/numeric_traits.h> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
using std::tr1::is_same; |
using std::tr1::is_const; |
using std::tr1::is_pointer; |
using std::tr1::is_reference; |
using std::tr1::is_fundamental; |
using std::tr1::is_member_object_pointer; |
using std::tr1::is_member_pointer; |
using std::tr1::is_base_of; |
using std::tr1::remove_const; |
using std::tr1::remove_reference; |
// Need integral_const<bool, true> <-> integral_const<int, 1>, so |
// because of this use the following typedefs instead of importing |
// std::tr1's. |
using std::tr1::integral_constant; |
typedef std::tr1::integral_constant<int, 1> true_type; |
typedef std::tr1::integral_constant<int, 0> false_type; |
using __gnu_cxx::__conditional_type; |
using __gnu_cxx::__numeric_traits; |
template<typename T> |
struct is_const_pointer |
{ |
enum |
{ |
value = is_const<T>::value && is_pointer<T>::value |
}; |
}; |
template<typename T> |
struct is_const_reference |
{ |
enum |
{ |
value = is_const<T>::value && is_reference<T>::value |
}; |
}; |
template<typename T> |
struct is_simple |
{ |
enum |
{ |
value = is_fundamental<typename remove_const<T>::type>::value |
|| is_pointer<typename remove_const<T>::type>::value |
|| is_member_pointer<T>::value |
}; |
}; |
template<typename T> |
class is_pair |
{ |
private: |
template<typename U> |
struct is_pair_imp |
{ |
enum |
{ |
value = 0 |
}; |
}; |
template<typename U, typename V> |
struct is_pair_imp<std::pair<U,V> > |
{ |
enum |
{ |
value = 1 |
}; |
}; |
public: |
enum |
{ |
value = is_pair_imp<T>::value |
}; |
}; |
// Use C++0x's static_assert if possible. |
#if __cplusplus >= 201103L |
#define PB_DS_STATIC_ASSERT(UNIQUE, E) static_assert(E, #UNIQUE) |
#else |
template<bool> |
struct __static_assert; |
template<> |
struct __static_assert<true> |
{ }; |
template<int> |
struct __static_assert_dumclass |
{ |
enum |
{ |
v = 1 |
}; |
}; |
#define PB_DS_STATIC_ASSERT(UNIQUE, E) \ |
typedef __gnu_pbds::detail::__static_assert_dumclass<sizeof(__gnu_pbds::detail::__static_assert<bool(E)>)> UNIQUE##__static_assert_type |
#endif |
template<typename Type> |
struct type_to_type |
{ |
typedef Type type; |
}; |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/types_traits.hpp |
---|
0,0 → 1,288 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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/types_traits.hpp |
* Contains a traits class of types used by containers. |
*/ |
#ifndef PB_DS_TYPES_TRAITS_HPP |
#define PB_DS_TYPES_TRAITS_HPP |
#include <algorithm> |
#include <utility> |
#include <ext/pb_ds/tag_and_trait.hpp> |
#include <ext/pb_ds/detail/type_utils.hpp> |
#include <utility> |
namespace __gnu_pbds |
{ |
namespace detail |
{ |
/** |
* @addtogroup traits Traits |
* @{ |
*/ |
/// Primary template. |
template<typename Key, typename Mapped> |
struct no_throw_copies |
{ |
static const bool __simple = is_simple<Key>::value |
&& is_simple<Mapped>::value; |
typedef integral_constant<int, __simple> indicator; |
}; |
/// Specialization. |
template<typename Key> |
struct no_throw_copies<Key, null_type> |
{ |
typedef integral_constant<int, is_simple<Key>::value> indicator; |
}; |
/// Stored value. |
template<typename _Tv> |
struct stored_value |
{ |
typedef _Tv value_type; |
value_type m_value; |
}; |
/// Stored hash. |
template<typename _Th> |
struct stored_hash |
{ |
typedef _Th hash_type; |
hash_type m_hash; |
}; |
/// Primary template for representation of stored data. |
/// Two types of data can be stored: value and hash. |
template<typename _Tv, typename _Th> |
struct stored_data |
: public stored_value<_Tv>, public stored_hash<_Th> |
{ }; |
/// Specialization for representation of stored data of just value type. |
template<typename _Tv> |
struct stored_data<_Tv, null_type> |
: public stored_value<_Tv> |
{ }; |
/// Primary template. |
template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash> |
struct type_base; |
/** |
* Specialization of type_base for the case where the hash value |
* is not stored alongside each value. |
*/ |
template<typename Key, typename Mapped, typename _Alloc> |
struct type_base<Key, Mapped, _Alloc, false> |
{ |
public: |
typedef typename _Alloc::size_type size_type; |
private: |
typedef typename _Alloc::template rebind<Mapped> __rebind_m; |
typedef typename __rebind_m::other __rebind_ma; |
typedef std::pair<const Key, Mapped> __value_type; |
typedef typename _Alloc::template rebind<__value_type> __rebind_v; |
typedef typename __rebind_v::other __rebind_va; |
public: |
typedef typename __rebind_ma::value_type mapped_type; |
typedef typename __rebind_ma::pointer mapped_pointer; |
typedef typename __rebind_ma::const_pointer mapped_const_pointer; |
typedef typename __rebind_ma::reference mapped_reference; |
typedef typename __rebind_ma::const_reference mapped_const_reference; |
typedef typename __rebind_va::value_type value_type; |
typedef typename __rebind_va::pointer pointer; |
typedef typename __rebind_va::const_pointer const_pointer; |
typedef typename __rebind_va::reference reference; |
typedef typename __rebind_va::const_reference const_reference; |
typedef stored_data<value_type, null_type> stored_data_type; |
}; |
/** |
* Specialization of type_base for the case where the hash value |
* is stored alongside each value. |
*/ |
template<typename Key, typename Mapped, typename _Alloc> |
struct type_base<Key, Mapped, _Alloc, true> |
{ |
public: |
typedef typename _Alloc::size_type size_type; |
private: |
typedef typename _Alloc::template rebind<Mapped> __rebind_m; |
typedef typename __rebind_m::other __rebind_ma; |
typedef std::pair<const Key, Mapped> __value_type; |
typedef typename _Alloc::template rebind<__value_type> __rebind_v; |
typedef typename __rebind_v::other __rebind_va; |
public: |
typedef typename __rebind_ma::value_type mapped_type; |
typedef typename __rebind_ma::pointer mapped_pointer; |
typedef typename __rebind_ma::const_pointer mapped_const_pointer; |
typedef typename __rebind_ma::reference mapped_reference; |
typedef typename __rebind_ma::const_reference mapped_const_reference; |
typedef typename __rebind_va::value_type value_type; |
typedef typename __rebind_va::pointer pointer; |
typedef typename __rebind_va::const_pointer const_pointer; |
typedef typename __rebind_va::reference reference; |
typedef typename __rebind_va::const_reference const_reference; |
typedef stored_data<value_type, size_type> stored_data_type; |
}; |
/** |
* Specialization of type_base for the case where the hash value |
* is not stored alongside each value. |
*/ |
template<typename Key, typename _Alloc> |
struct type_base<Key, null_type, _Alloc, false> |
{ |
public: |
typedef typename _Alloc::size_type size_type; |
typedef Key value_type; |
private: |
typedef typename _Alloc::template rebind<null_type> __rebind_m; |
typedef typename __rebind_m::other __rebind_ma; |
typedef typename _Alloc::template rebind<value_type> __rebind_v; |
typedef typename __rebind_v::other __rebind_va; |
public: |
typedef typename __rebind_ma::value_type mapped_type; |
typedef typename __rebind_ma::pointer mapped_pointer; |
typedef typename __rebind_ma::const_pointer mapped_const_pointer; |
typedef typename __rebind_ma::reference mapped_reference; |
typedef typename __rebind_ma::const_reference mapped_const_reference; |
typedef typename __rebind_va::pointer pointer; |
typedef typename __rebind_va::const_pointer const_pointer; |
typedef typename __rebind_va::reference reference; |
typedef typename __rebind_va::const_reference const_reference; |
typedef stored_data<value_type, null_type> stored_data_type; |
static null_type s_null_type; |
}; |
template<typename Key, typename _Alloc> |
null_type |
type_base<Key, null_type, _Alloc, false>::s_null_type; |
/** |
* Specialization of type_base for the case where the hash value |
* is stored alongside each value. |
*/ |
template<typename Key, typename _Alloc> |
struct type_base<Key, null_type, _Alloc, true> |
{ |
public: |
typedef typename _Alloc::size_type size_type; |
typedef Key value_type; |
private: |
typedef typename _Alloc::template rebind<null_type> __rebind_m; |
typedef typename __rebind_m::other __rebind_ma; |
typedef typename _Alloc::template rebind<value_type> __rebind_v; |
typedef typename __rebind_v::other __rebind_va; |
public: |
typedef typename __rebind_ma::value_type mapped_type; |
typedef typename __rebind_ma::pointer mapped_pointer; |
typedef typename __rebind_ma::const_pointer mapped_const_pointer; |
typedef typename __rebind_ma::reference mapped_reference; |
typedef typename __rebind_ma::const_reference mapped_const_reference; |
typedef typename __rebind_va::pointer pointer; |
typedef typename __rebind_va::const_pointer const_pointer; |
typedef typename __rebind_va::reference reference; |
typedef typename __rebind_va::const_reference const_reference; |
typedef stored_data<value_type, size_type> stored_data_type; |
static null_type s_null_type; |
}; |
template<typename Key, typename _Alloc> |
null_type |
type_base<Key, null_type, _Alloc, true>::s_null_type; |
/// Type base dispatch. |
template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash> |
struct type_dispatch |
{ |
typedef type_base<Key, Mapped, _Alloc, Store_Hash> type; |
}; |
/// Traits for abstract types. |
template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash> |
struct types_traits |
: public type_dispatch<Key, Mapped, _Alloc, Store_Hash>::type |
{ |
private: |
typedef no_throw_copies<Key, Mapped> __nothrowcopy; |
typedef typename _Alloc::template rebind<Key>::other __rebind_a; |
public: |
typedef typename _Alloc::size_type size_type; |
typedef typename __rebind_a::value_type key_type; |
typedef typename __rebind_a::pointer key_pointer; |
typedef typename __rebind_a::const_pointer key_const_pointer; |
typedef typename __rebind_a::reference key_reference; |
typedef typename __rebind_a::const_reference key_const_reference; |
typedef std::pair<size_type, size_type> comp_hash; |
typedef integral_constant<int, Store_Hash> store_extra; |
typedef typename __nothrowcopy::indicator no_throw_indicator; |
store_extra m_store_extra_indicator; |
no_throw_indicator m_no_throw_copies_indicator; |
}; |
//@} |
} // namespace detail |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp |
---|
0,0 → 1,111 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 unordered_iterator/const_iterator.hpp |
* Contains an iterator class used for const ranging over the elements of the |
* table. |
*/ |
/// Const range-type iterator. |
class const_iterator_ |
: public point_const_iterator_ |
{ |
public: |
/// Category. |
typedef std::forward_iterator_tag iterator_category; |
/// Difference type. |
typedef typename _Alloc::difference_type difference_type; |
/// Iterator's value type. |
typedef value_type_ value_type; |
/// Iterator's pointer type. |
typedef pointer_ pointer; |
/// Iterator's const pointer type. |
typedef const_pointer_ const_pointer; |
/// Iterator's reference type. |
typedef reference_ reference; |
/// Iterator's const reference type. |
typedef const_reference_ const_reference; |
/// Default constructor. |
const_iterator_() : m_p_tbl(0) |
{ } |
/// Increments. |
const_iterator_& |
operator++() |
{ |
m_p_tbl->inc_it_state(base_type::m_p_value, m_pos); |
return *this; |
} |
/// Increments. |
const_iterator_ |
operator++(int) |
{ |
const_iterator_ ret =* this; |
m_p_tbl->inc_it_state(base_type::m_p_value, m_pos); |
return ret; |
} |
protected: |
typedef point_const_iterator_ base_type; |
/** |
* Constructor used by the table to initiate the generalized |
* pointer and position (e.g., this is called from within a find() |
* of a table. |
* */ |
const_iterator_(const_pointer_ p_value, PB_DS_GEN_POS pos, |
const PB_DS_CLASS_C_DEC* p_tbl) |
: point_const_iterator_(p_value), m_p_tbl(p_tbl), m_pos(pos) |
{ } |
/** |
* Pointer to the table object which created the iterator (used for |
* incrementing its position. |
* */ |
const PB_DS_CLASS_C_DEC* m_p_tbl; |
PB_DS_GEN_POS m_pos; |
friend class PB_DS_CLASS_C_DEC; |
}; |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/iterator.hpp |
---|
0,0 → 1,130 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 iterator.hpp |
* Contains an iterator_ class used for ranging over the elements of the |
* table. |
*/ |
/// Range-type iterator. |
class iterator_ |
: public const_iterator_ |
{ |
public: |
/// Category. |
typedef std::forward_iterator_tag iterator_category; |
/// Difference type. |
typedef typename _Alloc::difference_type difference_type; |
/// Iterator's value type. |
typedef value_type_ value_type; |
/// Iterator's pointer type. |
typedef pointer_ pointer; |
/// Iterator's const pointer type. |
typedef const_pointer_ const_pointer; |
/// Iterator's reference type. |
typedef reference_ reference; |
/// Iterator's const reference type. |
typedef const_reference_ const_reference; |
/// Default constructor. |
inline |
iterator_() |
: const_iterator_(0, PB_DS_GEN_POS(), 0) { } |
/// Conversion to a point-type iterator. |
inline |
operator point_iterator_() |
{ return point_iterator_(const_cast<pointer>(const_iterator_::m_p_value)); } |
/// Conversion to a point-type iterator. |
inline |
operator const point_iterator_() const |
{ return point_iterator_(const_cast<pointer>(const_iterator_::m_p_value)); } |
/// Access. |
pointer |
operator->() const |
{ |
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_value != 0); |
return (const_cast<pointer>(base_type::m_p_value)); |
} |
/// Access. |
reference |
operator*() const |
{ |
_GLIBCXX_DEBUG_ASSERT(base_type::m_p_value != 0); |
return (const_cast<reference>(*base_type::m_p_value)); |
} |
/// Increments. |
iterator_& |
operator++() |
{ |
base_type::m_p_tbl->inc_it_state(base_type::m_p_value, base_type::m_pos); |
return *this; |
} |
/// Increments. |
iterator_ |
operator++(int) |
{ |
iterator_ ret =* this; |
base_type::m_p_tbl->inc_it_state(base_type::m_p_value, base_type::m_pos); |
return ret; |
} |
protected: |
typedef const_iterator_ base_type; |
/** |
* Constructor used by the table to initiate the generalized |
* pointer and position (e.g., this is called from within a find() |
* of a table. |
* */ |
inline |
iterator_(pointer p_value, PB_DS_GEN_POS pos, PB_DS_CLASS_C_DEC* p_tbl) |
: const_iterator_(p_value, pos, p_tbl) |
{ } |
friend class PB_DS_CLASS_C_DEC; |
}; |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp |
---|
0,0 → 1,133 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 unordered_iterator/point_const_iterator.hpp |
* Contains an iterator class returned by the tables' const find and insert |
* methods. |
*/ |
class point_iterator_; |
/// Const point-type iterator. |
class point_const_iterator_ |
{ |
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 pointer_ pointer; |
/// Iterator's const pointer type. |
typedef const_pointer_ const_pointer; |
/// Iterator's reference type. |
typedef reference_ reference; |
/// Iterator's const reference type. |
typedef const_reference_ const_reference; |
inline |
point_const_iterator_(const_pointer p_value) : m_p_value(p_value) |
{ } |
/// Default constructor. |
inline |
point_const_iterator_() : m_p_value(0) |
{ } |
/// Copy constructor. |
inline |
point_const_iterator_(const point_const_iterator_& other) |
: m_p_value(other.m_p_value) |
{ } |
/// Copy constructor. |
inline |
point_const_iterator_(const point_iterator_& other) |
: m_p_value(other.m_p_value) |
{ } |
/// Access. |
const_pointer |
operator->() const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_value != 0); |
return m_p_value; |
} |
/// Access. |
const_reference |
operator*() const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_value != 0); |
return *m_p_value; |
} |
/// Compares content to a different iterator object. |
bool |
operator==(const point_iterator_& other) const |
{ return m_p_value == other.m_p_value; } |
/// Compares content to a different iterator object. |
bool |
operator==(const point_const_iterator_& other) const |
{ return m_p_value == other.m_p_value; } |
/// Compares content (negatively) to a different iterator object. |
bool |
operator!=(const point_iterator_& other) const |
{ return m_p_value != other.m_p_value; } |
/// Compares content (negatively) to a different iterator object. |
bool |
operator!=(const point_const_iterator_& other) const |
{ return m_p_value != other.m_p_value; } |
protected: |
const_pointer m_p_value; |
friend class point_iterator_; |
friend class PB_DS_CLASS_C_DEC; |
}; |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp |
---|
0,0 → 1,126 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 point_iterator.hpp |
* Contains an iterator class returned by the tables' find and insert |
* methods. |
*/ |
/// Find type iterator. |
class point_iterator_ |
{ |
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 pointer_ pointer; |
/// Iterator's const pointer type. |
typedef const_pointer_ const_pointer; |
/// Iterator's reference type. |
typedef reference_ reference; |
/// Iterator's const reference type. |
typedef const_reference_ const_reference; |
/// Default constructor. |
inline |
point_iterator_() |
: m_p_value(0) |
{ } |
/// Copy constructor. |
inline |
point_iterator_(const point_iterator_& other) |
: m_p_value(other.m_p_value) |
{ } |
/// Access. |
pointer |
operator->() const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_value != 0); |
return (m_p_value); |
} |
/// Access. |
reference |
operator*() const |
{ |
_GLIBCXX_DEBUG_ASSERT(m_p_value != 0); |
return (*m_p_value); |
} |
/// Compares content to a different iterator object. |
bool |
operator==(const point_iterator_& other) const |
{ return m_p_value == other.m_p_value; } |
/// Compares content to a different iterator object. |
bool |
operator==(const point_const_iterator_& other) const |
{ return m_p_value == other.m_p_value; } |
/// Compares content to a different iterator object. |
bool |
operator!=(const point_iterator_& other) const |
{ return m_p_value != other.m_p_value; } |
/// Compares content (negatively) to a different iterator object. |
bool |
operator!=(const point_const_iterator_& other) const |
{ return m_p_value != other.m_p_value; } |
inline |
point_iterator_(pointer p_value) : m_p_value(p_value) |
{ } |
protected: |
friend class point_const_iterator_; |
friend class PB_DS_CLASS_C_DEC; |
protected: |
pointer m_p_value; |
}; |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/exception.hpp |
---|
0,0 → 1,93 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 exception.hpp |
* Contains exception classes. |
*/ |
#ifndef PB_DS_EXCEPTION_HPP |
#define PB_DS_EXCEPTION_HPP |
#include <bits/c++config.h> |
#include <stdexcept> |
#include <cstdlib> |
namespace __gnu_pbds |
{ |
/** |
* @defgroup exceptions-pbds Exceptions |
* @ingroup pbds |
* @{ |
*/ |
/// Base class for exceptions. |
struct container_error : public std::logic_error |
{ |
container_error() |
: std::logic_error(__N("__gnu_pbds::container_error")) { } |
}; |
/// An entry cannot be inserted into a container object for logical |
/// reasons (not, e.g., if memory is unabvailable, in which case |
/// the allocator_type's exception will be thrown). |
struct insert_error : public container_error { }; |
/// A join cannot be performed logical reasons (i.e., the ranges of |
/// the two container objects being joined overlaps. |
struct join_error : public container_error { }; |
/// A container cannot be resized. |
struct resize_error : public container_error { }; |
inline void |
__throw_container_error() |
{ _GLIBCXX_THROW_OR_ABORT(container_error()); } |
inline void |
__throw_insert_error() |
{ _GLIBCXX_THROW_OR_ABORT(insert_error()); } |
inline void |
__throw_join_error() |
{ _GLIBCXX_THROW_OR_ABORT(join_error()); } |
inline void |
__throw_resize_error() |
{ _GLIBCXX_THROW_OR_ABORT(resize_error()); } |
//@} |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/hash_policy.hpp |
---|
0,0 → 1,617 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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_policy.hpp |
* Contains hash-related policies. |
*/ |
#ifndef PB_DS_HASH_POLICY_HPP |
#define PB_DS_HASH_POLICY_HPP |
#include <bits/c++config.h> |
#include <algorithm> |
#include <vector> |
#include <cmath> |
#include <ext/pb_ds/exception.hpp> |
#include <ext/pb_ds/detail/type_utils.hpp> |
#include <ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp> |
#include <ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp> |
#include <ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp> |
namespace __gnu_pbds |
{ |
#define PB_DS_CLASS_T_DEC template<typename Size_Type> |
#define PB_DS_CLASS_C_DEC linear_probe_fn<Size_Type> |
/// A probe sequence policy using fixed increments. |
template<typename Size_Type = std::size_t> |
class linear_probe_fn |
{ |
public: |
typedef Size_Type size_type; |
void |
swap(PB_DS_CLASS_C_DEC& other); |
protected: |
/// Returns the i-th offset from the hash value. |
inline size_type |
operator()(size_type i) const; |
}; |
#include <ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC template<typename Size_Type> |
#define PB_DS_CLASS_C_DEC quadratic_probe_fn<Size_Type> |
/// A probe sequence policy using square increments. |
template<typename Size_Type = std::size_t> |
class quadratic_probe_fn |
{ |
public: |
typedef Size_Type size_type; |
void |
swap(PB_DS_CLASS_C_DEC& other); |
protected: |
/// Returns the i-th offset from the hash value. |
inline size_type |
operator()(size_type i) const; |
}; |
#include <ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC template<typename Size_Type> |
#define PB_DS_CLASS_C_DEC direct_mask_range_hashing<Size_Type> |
/// A mask range-hashing class (uses a bitmask). |
template<typename Size_Type = std::size_t> |
class direct_mask_range_hashing |
: public detail::mask_based_range_hashing<Size_Type> |
{ |
private: |
typedef detail::mask_based_range_hashing<Size_Type> mask_based_base; |
public: |
typedef Size_Type size_type; |
void |
swap(PB_DS_CLASS_C_DEC& other); |
protected: |
void |
notify_resized(size_type size); |
/// Transforms the __hash value hash into a ranged-hash value |
/// (using a bit-mask). |
inline size_type |
operator()(size_type hash) const; |
}; |
#include <ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC template<typename Size_Type> |
#define PB_DS_CLASS_C_DEC direct_mod_range_hashing<Size_Type> |
/// A mod range-hashing class (uses the modulo function). |
template<typename Size_Type = std::size_t> |
class direct_mod_range_hashing |
: public detail::mod_based_range_hashing<Size_Type> |
{ |
public: |
typedef Size_Type size_type; |
void |
swap(PB_DS_CLASS_C_DEC& other); |
protected: |
void |
notify_resized(size_type size); |
/// Transforms the __hash value hash into a ranged-hash value |
/// (using a modulo operation). |
inline size_type |
operator()(size_type hash) const; |
private: |
typedef detail::mod_based_range_hashing<size_type> mod_based_base; |
}; |
#include <ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC template<bool External_Load_Access, typename Size_Type> |
#define PB_DS_CLASS_C_DEC hash_load_check_resize_trigger<External_Load_Access, Size_Type> |
#define PB_DS_SIZE_BASE_C_DEC detail::hash_load_check_resize_trigger_size_base<Size_Type, External_Load_Access> |
/// A resize trigger policy based on a load check. It keeps the |
/// load factor between some load factors load_min and load_max. |
template<bool External_Load_Access = false, typename Size_Type = std::size_t> |
class hash_load_check_resize_trigger : private PB_DS_SIZE_BASE_C_DEC |
{ |
public: |
typedef Size_Type size_type; |
enum |
{ |
/// Specifies whether the load factor can be accessed |
/// externally. The two options have different trade-offs in |
/// terms of flexibility, genericity, and encapsulation. |
external_load_access = External_Load_Access |
}; |
/// Default constructor, or constructor taking load_min and |
/// load_max load factors between which this policy will keep the |
/// actual load. |
hash_load_check_resize_trigger(float load_min = 0.125, |
float load_max = 0.5); |
void |
swap(hash_load_check_resize_trigger& other); |
virtual |
~hash_load_check_resize_trigger(); |
/// Returns a pair of the minimal and maximal loads, respectively. |
inline std::pair<float, float> |
get_loads() const; |
/// Sets the loads through a pair of the minimal and maximal |
/// loads, respectively. |
void |
set_loads(std::pair<float, float> load_pair); |
protected: |
inline void |
notify_insert_search_start(); |
inline void |
notify_insert_search_collision(); |
inline void |
notify_insert_search_end(); |
inline void |
notify_find_search_start(); |
inline void |
notify_find_search_collision(); |
inline void |
notify_find_search_end(); |
inline void |
notify_erase_search_start(); |
inline void |
notify_erase_search_collision(); |
inline void |
notify_erase_search_end(); |
/// Notifies an element was inserted. The total number of entries |
/// in the table is num_entries. |
inline void |
notify_inserted(size_type num_entries); |
inline void |
notify_erased(size_type num_entries); |
/// Notifies the table was cleared. |
void |
notify_cleared(); |
/// Notifies the table was resized as a result of this object's |
/// signifying that a resize is needed. |
void |
notify_resized(size_type new_size); |
void |
notify_externally_resized(size_type new_size); |
inline bool |
is_resize_needed() const; |
inline bool |
is_grow_needed(size_type size, size_type num_entries) const; |
private: |
virtual void |
do_resize(size_type new_size); |
typedef PB_DS_SIZE_BASE_C_DEC size_base; |
#ifdef _GLIBCXX_DEBUG |
void |
assert_valid(const char* file, int line) const; |
#endif |
float m_load_min; |
float m_load_max; |
size_type m_next_shrink_size; |
size_type m_next_grow_size; |
bool m_resize_needed; |
}; |
#include <ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_SIZE_BASE_C_DEC |
#define PB_DS_CLASS_T_DEC template<bool External_Load_Access, typename Size_Type> |
#define PB_DS_CLASS_C_DEC cc_hash_max_collision_check_resize_trigger<External_Load_Access, Size_Type> |
/// A resize trigger policy based on collision checks. It keeps the |
/// simulated load factor lower than some given load factor. |
template<bool External_Load_Access = false, typename Size_Type = std::size_t> |
class cc_hash_max_collision_check_resize_trigger |
{ |
public: |
typedef Size_Type size_type; |
enum |
{ |
/// Specifies whether the load factor can be accessed |
/// externally. The two options have different trade-offs in |
/// terms of flexibility, genericity, and encapsulation. |
external_load_access = External_Load_Access |
}; |
/// Default constructor, or constructor taking load, a __load |
/// factor which it will attempt to maintain. |
cc_hash_max_collision_check_resize_trigger(float load = 0.5); |
void |
swap(PB_DS_CLASS_C_DEC& other); |
/// Returns the current load. |
inline float |
get_load() const; |
/// Sets the load; does not resize the container. |
void |
set_load(float load); |
protected: |
/// Notifies an insert search started. |
inline void |
notify_insert_search_start(); |
/// Notifies a search encountered a collision. |
inline void |
notify_insert_search_collision(); |
/// Notifies a search ended. |
inline void |
notify_insert_search_end(); |
/// Notifies a find search started. |
inline void |
notify_find_search_start(); |
/// Notifies a search encountered a collision. |
inline void |
notify_find_search_collision(); |
/// Notifies a search ended. |
inline void |
notify_find_search_end(); |
/// Notifies an erase search started. |
inline void |
notify_erase_search_start(); |
/// Notifies a search encountered a collision. |
inline void |
notify_erase_search_collision(); |
/// Notifies a search ended. |
inline void |
notify_erase_search_end(); |
/// Notifies an element was inserted. |
inline void |
notify_inserted(size_type num_entries); |
/// Notifies an element was erased. |
inline void |
notify_erased(size_type num_entries); |
/// Notifies the table was cleared. |
void |
notify_cleared(); |
/// Notifies the table was resized as a result of this object's |
/// signifying that a resize is needed. |
void |
notify_resized(size_type new_size); |
/// Notifies the table was resized externally. |
void |
notify_externally_resized(size_type new_size); |
/// Queries whether a resize is needed. |
inline bool |
is_resize_needed() const; |
/// Queries whether a grow is needed. This method is called only |
/// if this object indicated is needed. |
inline bool |
is_grow_needed(size_type size, size_type num_entries) const; |
private: |
void |
calc_max_num_coll(); |
inline void |
calc_resize_needed(); |
float m_load; |
size_type m_size; |
size_type m_num_col; |
size_type m_max_col; |
bool m_resize_needed; |
}; |
#include <ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC template<typename Size_Type> |
#define PB_DS_CLASS_C_DEC hash_exponential_size_policy<Size_Type> |
/// A size policy whose sequence of sizes form an exponential |
/// sequence (typically powers of 2. |
template<typename Size_Type = std::size_t> |
class hash_exponential_size_policy |
{ |
public: |
typedef Size_Type size_type; |
/// Default constructor, or onstructor taking a start_size, or |
/// constructor taking a start size and grow_factor. The policy |
/// will use the sequence of sizes start_size, start_size* |
/// grow_factor, start_size* grow_factor^2, ... |
hash_exponential_size_policy(size_type start_size = 8, |
size_type grow_factor = 2); |
void |
swap(PB_DS_CLASS_C_DEC& other); |
protected: |
size_type |
get_nearest_larger_size(size_type size) const; |
size_type |
get_nearest_smaller_size(size_type size) const; |
private: |
size_type m_start_size; |
size_type m_grow_factor; |
}; |
#include <ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC |
#define PB_DS_CLASS_C_DEC hash_prime_size_policy |
/// A size policy whose sequence of sizes form a nearly-exponential |
/// sequence of primes. |
class hash_prime_size_policy |
{ |
public: |
/// Size type. |
typedef std::size_t size_type; |
/// Default constructor, or onstructor taking a start_size The |
/// policy will use the sequence of sizes approximately |
/// start_size, start_size* 2, start_size* 2^2, ... |
hash_prime_size_policy(size_type start_size = 8); |
inline void |
swap(PB_DS_CLASS_C_DEC& other); |
protected: |
size_type |
get_nearest_larger_size(size_type size) const; |
size_type |
get_nearest_smaller_size(size_type size) const; |
private: |
size_type m_start_size; |
}; |
#include <ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC template<typename Size_Policy, typename Trigger_Policy, bool External_Size_Access, typename Size_Type> |
#define PB_DS_CLASS_C_DEC hash_standard_resize_policy<Size_Policy, Trigger_Policy, External_Size_Access, Size_Type> |
/// A resize policy which delegates operations to size and trigger policies. |
template<typename Size_Policy = hash_exponential_size_policy<>, |
typename Trigger_Policy = hash_load_check_resize_trigger<>, |
bool External_Size_Access = false, |
typename Size_Type = std::size_t> |
class hash_standard_resize_policy |
: public Size_Policy, public Trigger_Policy |
{ |
public: |
typedef Size_Type size_type; |
typedef Trigger_Policy trigger_policy; |
typedef Size_Policy size_policy; |
enum |
{ |
external_size_access = External_Size_Access |
}; |
/// Default constructor. |
hash_standard_resize_policy(); |
/// constructor taking some policies r_size_policy will be copied |
/// by the Size_Policy object of this object. |
hash_standard_resize_policy(const Size_Policy& r_size_policy); |
/// constructor taking some policies. r_size_policy will be |
/// copied by the Size_Policy object of this |
/// object. r_trigger_policy will be copied by the Trigger_Policy |
/// object of this object. |
hash_standard_resize_policy(const Size_Policy& r_size_policy, |
const Trigger_Policy& r_trigger_policy); |
virtual |
~hash_standard_resize_policy(); |
inline void |
swap(PB_DS_CLASS_C_DEC& other); |
/// Access to the Size_Policy object used. |
Size_Policy& |
get_size_policy(); |
/// Const access to the Size_Policy object used. |
const Size_Policy& |
get_size_policy() const; |
/// Access to the Trigger_Policy object used. |
Trigger_Policy& |
get_trigger_policy(); |
/// Access to the Trigger_Policy object used. |
const Trigger_Policy& |
get_trigger_policy() const; |
/// Returns the actual size of the container. |
inline size_type |
get_actual_size() const; |
/// Resizes the container to suggested_new_size, a suggested size |
/// (the actual size will be determined by the Size_Policy |
/// object). |
void |
resize(size_type suggested_new_size); |
protected: |
inline void |
notify_insert_search_start(); |
inline void |
notify_insert_search_collision(); |
inline void |
notify_insert_search_end(); |
inline void |
notify_find_search_start(); |
inline void |
notify_find_search_collision(); |
inline void |
notify_find_search_end(); |
inline void |
notify_erase_search_start(); |
inline void |
notify_erase_search_collision(); |
inline void |
notify_erase_search_end(); |
inline void |
notify_inserted(size_type num_e); |
inline void |
notify_erased(size_type num_e); |
void |
notify_cleared(); |
void |
notify_resized(size_type new_size); |
inline bool |
is_resize_needed() const; |
/// Queries what the new size should be, when the container is |
/// resized naturally. The current __size of the container is |
/// size, and the number of used entries within the container is |
/// num_used_e. |
size_type |
get_new_size(size_type size, size_type num_used_e) const; |
private: |
/// Resizes to new_size. |
virtual void |
do_resize(size_type new_size); |
typedef Trigger_Policy trigger_policy_base; |
typedef Size_Policy size_policy_base; |
size_type m_size; |
}; |
#include <ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/list_update_policy.hpp |
---|
0,0 → 1,130 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 list_update_policy.hpp |
* Contains policies for list update containers. |
*/ |
#ifndef PB_DS_LU_POLICY_HPP |
#define PB_DS_LU_POLICY_HPP |
#include <bits/c++config.h> |
#include <cstdlib> |
#include <ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp> |
#include <ext/pb_ds/tag_and_trait.hpp> |
namespace __gnu_pbds |
{ |
/** |
* A list-update policy that unconditionally moves elements to the |
* front of the list. A null type means that each link in a |
* list-based container does not actually need metadata. |
*/ |
template<typename _Alloc = std::allocator<char> > |
class lu_move_to_front_policy |
{ |
public: |
typedef _Alloc allocator_type; |
/// Metadata on which this functor operates. |
typedef null_type metadata_type; |
private: |
typedef typename _Alloc::template rebind<metadata_type> __rebind_m; |
public: |
/// Reference to metadata on which this functor operates. |
typedef typename __rebind_m::other::reference metadata_reference; |
/// Creates a metadata object. |
metadata_type |
operator()() const |
{ return s_metadata; } |
/// Decides whether a metadata object should be moved to the front |
/// of the list. |
inline bool |
operator()(metadata_reference r_metadata) const |
{ return true; } |
private: |
static null_type s_metadata; |
}; |
/** |
* A list-update policy that moves elements to the front of the |
* list based on the counter algorithm. |
*/ |
template<std::size_t Max_Count = 5, typename _Alloc = std::allocator<char> > |
class lu_counter_policy |
: private detail::lu_counter_policy_base<typename _Alloc::size_type> |
{ |
public: |
typedef _Alloc allocator_type; |
typedef typename allocator_type::size_type size_type; |
enum |
{ |
/// When some element is accessed this number of times, it |
/// will be moved to the front of the list. |
max_count = Max_Count |
}; |
/// Metadata on which this functor operates. |
typedef detail::lu_counter_metadata<size_type> metadata_type; |
private: |
typedef detail::lu_counter_policy_base<size_type> base_type; |
typedef typename _Alloc::template rebind<metadata_type> __rebind_m; |
public: |
/// Reference to metadata on which this functor operates. |
typedef typename __rebind_m::other::reference metadata_reference; |
/// Creates a metadata object. |
metadata_type |
operator()() const |
{ return base_type::operator()(max_count); } |
/// Decides whether a metadata object should be moved to the front |
/// of the list. |
bool |
operator()(metadata_reference r_data) const |
{ return base_type::operator()(r_data, max_count); } |
}; |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/priority_queue.hpp |
---|
0,0 → 1,157 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 priority_queue.hpp |
* Contains priority_queues. |
*/ |
#ifndef PB_DS_PRIORITY_QUEUE_HPP |
#define PB_DS_PRIORITY_QUEUE_HPP |
#include <bits/c++config.h> |
#include <ext/pb_ds/tag_and_trait.hpp> |
#include <ext/pb_ds/detail/priority_queue_base_dispatch.hpp> |
#include <ext/pb_ds/detail/standard_policies.hpp> |
namespace __gnu_pbds |
{ |
/** |
* @defgroup heap-based Heap-Based |
* @ingroup containers-pbds |
* @{ |
*/ |
/** |
* @defgroup heap-detail Base and Policy Classes |
* @ingroup heap-based |
*/ |
/** |
* A priority queue composed of one specific heap policy. |
* |
* @tparam _Tv Value type. |
* @tparam Cmp_Fn Comparison functor. |
* @tparam Tag Instantiating data structure type, |
* see container_tag. |
* @tparam _Alloc Allocator type. |
* |
* Base is dispatched at compile time via Tag, from the following |
* choices: binary_heap_tag, binomial_heap_tag, pairing_heap_tag, |
* rc_binomial_heap_tag, thin_heap_tag |
* |
* Base choices are: detail::binary_heap, detail::binomial_heap, |
* detail::pairing_heap, detail::rc_binomial_heap, |
* detail::thin_heap. |
*/ |
template<typename _Tv, |
typename Cmp_Fn = std::less<_Tv>, |
typename Tag = pairing_heap_tag, |
typename _Alloc = std::allocator<char> > |
class priority_queue |
: public detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc, Tag>::type |
{ |
public: |
typedef _Tv value_type; |
typedef Cmp_Fn cmp_fn; |
typedef Tag container_category; |
typedef _Alloc allocator_type; |
typedef typename allocator_type::size_type size_type; |
typedef typename allocator_type::difference_type difference_type; |
private: |
typedef typename detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc, |
Tag>::type |
base_type; |
typedef typename _Alloc::template rebind<_Tv> __rebind_v; |
typedef typename __rebind_v::other __rebind_va; |
public: |
typedef typename __rebind_va::reference reference; |
typedef typename __rebind_va::const_reference const_reference; |
typedef typename __rebind_va::pointer pointer; |
typedef typename __rebind_va::const_pointer const_pointer; |
typedef typename base_type::point_iterator point_iterator; |
typedef typename base_type::point_const_iterator point_const_iterator; |
typedef typename base_type::iterator iterator; |
typedef typename base_type::const_iterator const_iterator; |
priority_queue() { } |
/// Constructor taking some policy objects. r_cmp_fn will be |
/// copied by the Cmp_Fn object of the container object. |
priority_queue(const cmp_fn& r_cmp_fn) : base_type(r_cmp_fn) { } |
/// 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> |
priority_queue(It first_it, It last_it) |
{ base_type::copy_from_range(first_it, last_it); } |
/// 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> |
priority_queue(It first_it, It last_it, const cmp_fn& r_cmp_fn) |
: base_type(r_cmp_fn) |
{ base_type::copy_from_range(first_it, last_it); } |
priority_queue(const priority_queue& other) |
: base_type((const base_type& )other) { } |
virtual |
~priority_queue() { } |
priority_queue& |
operator=(const priority_queue& other) |
{ |
if (this != &other) |
{ |
priority_queue tmp(other); |
swap(tmp); |
} |
return *this; |
} |
void |
swap(priority_queue& other) |
{ base_type::swap(other); } |
}; |
} // namespace __gnu_pbds |
//@} heap-based |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/tag_and_trait.hpp |
---|
0,0 → 1,454 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 tag_and_trait.hpp |
* Contains tags and traits, e.g., ones describing underlying |
* data structures. |
*/ |
#ifndef PB_DS_TAG_AND_TRAIT_HPP |
#define PB_DS_TAG_AND_TRAIT_HPP |
#include <bits/c++config.h> |
#include <ext/pb_ds/detail/type_utils.hpp> |
/** |
* @namespace __gnu_pbds |
* @brief GNU extensions for policy-based data structures for public use. |
*/ |
namespace __gnu_pbds |
{ |
/** @defgroup pbds Policy-Based Data Structures |
* @ingroup extensions |
* |
* This is a library of policy-based elementary data structures: |
* associative containers and priority queues. It is designed for |
* high-performance, flexibility, semantic safety, and conformance |
* to the corresponding containers in std (except for some points |
* where it differs by design). |
* |
* For details, see: |
* http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/index.html |
* |
* @{ |
*/ |
/** |
* @defgroup tags Tags |
* @{ |
*/ |
/// A trivial iterator tag. Signifies that the iterators has none of |
/// std::iterators's movement abilities. |
struct trivial_iterator_tag |
{ }; |
/// Prohibit moving trivial iterators. |
typedef void trivial_iterator_difference_type; |
/** |
* @defgroup invalidation_tags Invalidation Guarantees |
* @ingroup tags |
* @{ |
*/ |
/** |
* Signifies a basic invalidation guarantee that any iterator, |
* pointer, or reference to a container object's mapped value type |
* is valid as long as the container is not modified. |
*/ |
struct basic_invalidation_guarantee |
{ }; |
/** |
* Signifies an invalidation guarantee that includes all those of |
* its base, and additionally, that any point-type iterator, |
* pointer, or reference to a container object's mapped value type |
* is valid as long as its corresponding entry has not be erased, |
* regardless of modifications to the container object. |
*/ |
struct point_invalidation_guarantee : public basic_invalidation_guarantee |
{ }; |
/** |
* Signifies an invalidation guarantee that includes all those of |
* its base, and additionally, that any range-type iterator |
* (including the returns of begin() and end()) is in the correct |
* relative positions to other range-type iterators as long as its |
* corresponding entry has not be erased, regardless of |
* modifications to the container object. |
*/ |
struct range_invalidation_guarantee : public point_invalidation_guarantee |
{ }; |
//@} |
/** |
* @defgroup ds_tags Data Structure Type |
* @ingroup tags |
* @{ |
*/ |
/// Base data structure tag. |
struct container_tag |
{ }; |
/// Basic sequence. |
struct sequence_tag : public container_tag { }; |
/// Basic string container, inclusive of strings, ropes, etc. |
struct string_tag : public sequence_tag { }; |
/// Basic associative-container. |
struct associative_tag : public container_tag { }; |
/// Basic hash structure. |
struct basic_hash_tag : public associative_tag { }; |
/// Collision-chaining hash. |
struct cc_hash_tag : public basic_hash_tag { }; |
/// General-probing hash. |
struct gp_hash_tag : public basic_hash_tag { }; |
/// Basic branch structure. |
struct basic_branch_tag : public associative_tag { }; |
/// Basic tree structure. |
struct tree_tag : public basic_branch_tag { }; |
/// Red-black tree. |
struct rb_tree_tag : public tree_tag { }; |
/// Splay tree. |
struct splay_tree_tag : public tree_tag { }; |
/// Ordered-vector tree. |
struct ov_tree_tag : public tree_tag { }; |
/// Basic trie structure. |
struct trie_tag : public basic_branch_tag { }; |
/// PATRICIA trie. |
struct pat_trie_tag : public trie_tag { }; |
/// List-update. |
struct list_update_tag : public associative_tag { }; |
/// Basic priority-queue. |
struct priority_queue_tag : public container_tag { }; |
/// Pairing-heap. |
struct pairing_heap_tag : public priority_queue_tag { }; |
/// Binomial-heap. |
struct binomial_heap_tag : public priority_queue_tag { }; |
/// Redundant-counter binomial-heap. |
struct rc_binomial_heap_tag : public priority_queue_tag { }; |
/// Binary-heap (array-based). |
struct binary_heap_tag : public priority_queue_tag { }; |
/// Thin heap. |
struct thin_heap_tag : public priority_queue_tag { }; |
//@} |
//@} |
/** |
* @defgroup traits Traits |
* @{ |
*/ |
/** |
* @brief Represents no type, or absence of type, for template tricks. |
* |
* In a mapped-policy, indicates that an associative container is a set. |
* |
* In a list-update policy, indicates that each link does not need |
* metadata. |
* |
* In a hash policy, indicates that the combining hash function |
* is actually a ranged hash function. |
* |
* In a probe policy, indicates that the combining probe function |
* is actually a ranged probe function. |
*/ |
struct null_type { }; |
/// A null node updator, indicating that no node updates are required. |
template<typename _Tp1, typename _Tp2, typename _Tp3, typename _Tp4> |
struct null_node_update : public null_type |
{ }; |
/// Primary template, container traits base. |
template<typename _Tag> |
struct container_traits_base; |
/// Specialization, cc hash. |
template<> |
struct container_traits_base<cc_hash_tag> |
{ |
typedef cc_hash_tag container_category; |
typedef point_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = false, |
erase_can_throw = false, |
split_join_can_throw = false, |
reverse_iteration = false |
}; |
}; |
/// Specialization, gp hash. |
template<> |
struct container_traits_base<gp_hash_tag> |
{ |
typedef gp_hash_tag container_category; |
typedef basic_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = false, |
erase_can_throw = false, |
split_join_can_throw = false, |
reverse_iteration = false |
}; |
}; |
/// Specialization, rb tree. |
template<> |
struct container_traits_base<rb_tree_tag> |
{ |
typedef rb_tree_tag container_category; |
typedef range_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = true, |
erase_can_throw = false, |
split_join_can_throw = false, |
reverse_iteration = true |
}; |
}; |
/// Specialization, splay tree. |
template<> |
struct container_traits_base<splay_tree_tag> |
{ |
typedef splay_tree_tag container_category; |
typedef range_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = true, |
erase_can_throw = false, |
split_join_can_throw = false, |
reverse_iteration = true |
}; |
}; |
/// Specialization, ov tree. |
template<> |
struct container_traits_base<ov_tree_tag> |
{ |
typedef ov_tree_tag container_category; |
typedef basic_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = true, |
erase_can_throw = true, |
split_join_can_throw = true, |
reverse_iteration = false |
}; |
}; |
/// Specialization, pat trie. |
template<> |
struct container_traits_base<pat_trie_tag> |
{ |
typedef pat_trie_tag container_category; |
typedef range_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = true, |
erase_can_throw = false, |
split_join_can_throw = true, |
reverse_iteration = true |
}; |
}; |
/// Specialization, list update. |
template<> |
struct container_traits_base<list_update_tag> |
{ |
typedef list_update_tag container_category; |
typedef point_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = false, |
erase_can_throw = false, |
split_join_can_throw = false, |
reverse_iteration = false |
}; |
}; |
/// Specialization, pairing heap. |
template<> |
struct container_traits_base<pairing_heap_tag> |
{ |
typedef pairing_heap_tag container_category; |
typedef point_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = false, |
erase_can_throw = false, |
split_join_can_throw = false, |
reverse_iteration = false |
}; |
}; |
/// Specialization, thin heap. |
template<> |
struct container_traits_base<thin_heap_tag> |
{ |
typedef thin_heap_tag container_category; |
typedef point_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = false, |
erase_can_throw = false, |
split_join_can_throw = false, |
reverse_iteration = false |
}; |
}; |
/// Specialization, binomial heap. |
template<> |
struct container_traits_base<binomial_heap_tag> |
{ |
typedef binomial_heap_tag container_category; |
typedef point_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = false, |
erase_can_throw = false, |
split_join_can_throw = false, |
reverse_iteration = false |
}; |
}; |
/// Specialization, rc binomial heap. |
template<> |
struct container_traits_base<rc_binomial_heap_tag> |
{ |
typedef rc_binomial_heap_tag container_category; |
typedef point_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = false, |
erase_can_throw = false, |
split_join_can_throw = false, |
reverse_iteration = false |
}; |
}; |
/// Specialization, binary heap. |
template<> |
struct container_traits_base<binary_heap_tag> |
{ |
typedef binary_heap_tag container_category; |
typedef basic_invalidation_guarantee invalidation_guarantee; |
enum |
{ |
order_preserving = false, |
erase_can_throw = false, |
split_join_can_throw = true, |
reverse_iteration = false |
}; |
}; |
/// Container traits. |
// See Matt Austern for the name, S. Meyers MEFC++ #2, others. |
template<typename Cntnr> |
struct container_traits |
: public container_traits_base<typename Cntnr::container_category> |
{ |
typedef Cntnr container_type; |
typedef typename Cntnr::container_category container_category; |
typedef container_traits_base<container_category> base_type; |
typedef typename base_type::invalidation_guarantee invalidation_guarantee; |
enum |
{ |
/// True only if Cntnr objects guarantee storing keys by order. |
order_preserving = base_type::order_preserving, |
/// True only if erasing a key can throw. |
erase_can_throw = base_type::erase_can_throw, |
/// True only if split or join operations can throw. |
split_join_can_throw = base_type::split_join_can_throw, |
/// True only reverse iterators are supported. |
reverse_iteration = base_type::reverse_iteration |
}; |
}; |
//@} |
namespace detail |
{ |
/// Dispatch mechanism, primary template for associative types. |
template<typename Key, typename Mapped, typename _Alloc, typename Tag, |
typename Policy_Tl = null_type> |
struct container_base_dispatch; |
} // namespace __detail |
//@} |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/tree_policy.hpp |
---|
0,0 → 1,157 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 tree_policy.hpp |
* Contains tree-related policies. |
*/ |
#ifndef PB_DS_TREE_POLICY_HPP |
#define PB_DS_TREE_POLICY_HPP |
#include <bits/c++config.h> |
#include <iterator> |
#include <ext/pb_ds/detail/type_utils.hpp> |
#include <ext/pb_ds/detail/branch_policy/branch_policy.hpp> |
namespace __gnu_pbds |
{ |
#define PB_DS_CLASS_T_DEC \ |
template<typename Node_CItr, typename Node_Itr, typename Cmp_Fn, \ |
typename _Alloc> |
#define PB_DS_CLASS_C_DEC \ |
tree_order_statistics_node_update<Node_CItr, Node_Itr, Cmp_Fn, _Alloc> |
#define PB_DS_BRANCH_POLICY_BASE \ |
detail::branch_policy<Node_CItr, Node_Itr, _Alloc> |
/// Functor updating ranks of entrees. |
template<typename Node_CItr, typename Node_Itr, |
typename Cmp_Fn, typename _Alloc> |
class tree_order_statistics_node_update : private PB_DS_BRANCH_POLICY_BASE |
{ |
private: |
typedef PB_DS_BRANCH_POLICY_BASE base_type; |
public: |
typedef Cmp_Fn cmp_fn; |
typedef _Alloc allocator_type; |
typedef typename allocator_type::size_type size_type; |
typedef typename base_type::key_type key_type; |
typedef typename base_type::key_const_reference key_const_reference; |
typedef size_type metadata_type; |
typedef Node_CItr node_const_iterator; |
typedef Node_Itr node_iterator; |
typedef typename node_const_iterator::value_type const_iterator; |
typedef typename node_iterator::value_type iterator; |
/// Finds an entry by __order. Returns a const_iterator to the |
/// entry with the __order order, or a const_iterator to the |
/// container object's end if order is at least the size of the |
/// container object. |
inline const_iterator |
find_by_order(size_type) const; |
/// Finds an entry by __order. Returns an iterator to the entry |
/// with the __order order, or an iterator to the container |
/// object's end if order is at least the size of the container |
/// object. |
inline iterator |
find_by_order(size_type); |
/// Returns the order of a key within a sequence. For exapmle, if |
/// r_key is the smallest key, this method will return 0; if r_key |
/// is a key between the smallest and next key, this method will |
/// return 1; if r_key is a key larger than the largest key, this |
/// method will return the size of r_c. |
inline size_type |
order_of_key(key_const_reference) const; |
private: |
/// Const reference to the container's value-type. |
typedef typename base_type::const_reference const_reference; |
/// Const pointer to the container's value-type. |
typedef typename base_type::const_pointer const_pointer; |
typedef typename _Alloc::template rebind<metadata_type>::other __rebind_m; |
/// Const metadata reference. |
typedef typename __rebind_m::const_reference metadata_const_reference; |
/// Metadata reference. |
typedef typename __rebind_m::reference metadata_reference; |
/// Returns the node_const_iterator associated with the tree's root node. |
virtual node_const_iterator |
node_begin() const = 0; |
/// Returns the node_iterator associated with the tree's root node. |
virtual node_iterator |
node_begin() = 0; |
/// Returns the node_const_iterator associated with a just-after leaf node. |
virtual node_const_iterator |
node_end() const = 0; |
/// Returns the node_iterator associated with a just-after leaf node. |
virtual node_iterator |
node_end() = 0; |
/// Access to the cmp_fn object. |
virtual cmp_fn& |
get_cmp_fn() = 0; |
protected: |
/// Updates the rank of a node through a node_iterator node_it; |
/// end_nd_it is the end node iterator. |
inline void |
operator()(node_iterator, node_const_iterator) const; |
virtual |
~tree_order_statistics_node_update(); |
}; |
#include <ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_BRANCH_POLICY_BASE |
} // namespace __gnu_pbds |
#endif |
/contrib/sdk/sources/libstdc++-v3/include/ext/pb_ds/trie_policy.hpp |
---|
0,0 → 1,360 |
// -*- C++ -*- |
// Copyright (C) 2005-2013 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 trie_policy.hpp |
* Contains trie-related policies. |
*/ |
#ifndef PB_DS_TRIE_POLICY_HPP |
#define PB_DS_TRIE_POLICY_HPP |
#include <bits/c++config.h> |
#include <string> |
#include <ext/pb_ds/detail/type_utils.hpp> |
#include <ext/pb_ds/detail/trie_policy/trie_policy_base.hpp> |
namespace __gnu_pbds |
{ |
#define PB_DS_CLASS_T_DEC \ |
template<typename String, typename String::value_type Min_E_Val, \ |
typename String::value_type Max_E_Val, bool Reverse, \ |
typename _Alloc> |
#define PB_DS_CLASS_C_DEC \ |
trie_string_access_traits<String, Min_E_Val,Max_E_Val,Reverse,_Alloc> |
/** |
* Element access traits for string types. |
* |
* @tparam String String type. |
* @tparam Min_E_Val Minimal element value. |
* @tparam Max_E_Val Maximum element value. |
* @tparam Reverse Reverse iteration should be used. |
* Default: false. |
* @tparam _Alloc Allocator type. |
*/ |
template<typename String = std::string, |
typename String::value_type Min_E_Val = detail::__numeric_traits<typename String::value_type>::__min, |
typename String::value_type Max_E_Val = detail::__numeric_traits<typename String::value_type>::__max, |
bool Reverse = false, |
typename _Alloc = std::allocator<char> > |
struct trie_string_access_traits |
{ |
public: |
typedef typename _Alloc::size_type size_type; |
typedef String key_type; |
typedef typename _Alloc::template rebind<key_type> __rebind_k; |
typedef typename __rebind_k::other::const_reference key_const_reference; |
enum |
{ |
reverse = Reverse |
}; |
/// Element const iterator type. |
typedef typename detail::__conditional_type<Reverse, \ |
typename String::const_reverse_iterator, \ |
typename String::const_iterator>::__type const_iterator; |
/// Element type. |
typedef typename std::iterator_traits<const_iterator>::value_type e_type; |
enum |
{ |
min_e_val = Min_E_Val, |
max_e_val = Max_E_Val, |
max_size = max_e_val - min_e_val + 1 |
}; |
PB_DS_STATIC_ASSERT(min_max_size, max_size >= 2); |
/// Returns a const_iterator to the first element of |
/// key_const_reference agumnet. |
inline static const_iterator |
begin(key_const_reference); |
/// Returns a const_iterator to the after-last element of |
/// key_const_reference argument. |
inline static const_iterator |
end(key_const_reference); |
/// Maps an element to a position. |
inline static size_type |
e_pos(e_type e); |
private: |
inline static const_iterator |
begin_imp(key_const_reference, detail::false_type); |
inline static const_iterator |
begin_imp(key_const_reference, detail::true_type); |
inline static const_iterator |
end_imp(key_const_reference, detail::false_type); |
inline static const_iterator |
end_imp(key_const_reference, detail::true_type); |
static detail::integral_constant<int, Reverse> s_rev_ind; |
}; |
#include <ext/pb_ds/detail/trie_policy/trie_string_access_traits_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_T_DEC \ |
template<typename Node_CItr,typename Node_Itr, \ |
typename _ATraits, typename _Alloc> |
#define PB_DS_CLASS_C_DEC \ |
trie_prefix_search_node_update<Node_CItr, Node_Itr, \ |
_ATraits,_Alloc> |
#define PB_DS_TRIE_POLICY_BASE \ |
detail::trie_policy_base<Node_CItr,Node_Itr,_ATraits, _Alloc> |
/// A node updator that allows tries to be searched for the range of |
/// values that match a certain prefix. |
template<typename Node_CItr, |
typename Node_Itr, |
typename _ATraits, |
typename _Alloc> |
class trie_prefix_search_node_update : private PB_DS_TRIE_POLICY_BASE |
{ |
private: |
typedef PB_DS_TRIE_POLICY_BASE base_type; |
public: |
typedef typename base_type::key_type key_type; |
typedef typename base_type::key_const_reference key_const_reference; |
/// Element access traits. |
typedef _ATraits access_traits; |
/// Const element iterator. |
typedef typename access_traits::const_iterator a_const_iterator; |
/// _Alloc type. |
typedef _Alloc allocator_type; |
/// Size type. |
typedef typename allocator_type::size_type size_type; |
typedef null_type metadata_type; |
typedef Node_Itr node_iterator; |
typedef Node_CItr node_const_iterator; |
typedef typename node_iterator::value_type iterator; |
typedef typename node_const_iterator::value_type const_iterator; |
/// Finds the const iterator range corresponding to all values |
/// whose prefixes match r_key. |
std::pair<const_iterator, const_iterator> |
prefix_range(key_const_reference) const; |
/// Finds the iterator range corresponding to all values whose |
/// prefixes match r_key. |
std::pair<iterator, iterator> |
prefix_range(key_const_reference); |
/// Finds the const iterator range corresponding to all values |
/// whose prefixes match [b, e). |
std::pair<const_iterator, const_iterator> |
prefix_range(a_const_iterator, a_const_iterator) const; |
/// Finds the iterator range corresponding to all values whose |
/// prefixes match [b, e). |
std::pair<iterator, iterator> |
prefix_range(a_const_iterator, a_const_iterator); |
protected: |
/// Called to update a node's metadata. |
inline void |
operator()(node_iterator node_it, node_const_iterator end_nd_it) const; |
private: |
node_iterator |
next_child(node_iterator, a_const_iterator, a_const_iterator, |
node_iterator, const access_traits&); |
/// Returns the const iterator associated with the just-after last element. |
virtual const_iterator |
end() const = 0; |
/// Returns the iterator associated with the just-after last element. |
virtual iterator |
end() = 0; |
/// Returns the node_const_iterator associated with the trie's root node. |
virtual node_const_iterator |
node_begin() const = 0; |
/// Returns the node_iterator associated with the trie's root node. |
virtual node_iterator |
node_begin() = 0; |
/// Returns the node_const_iterator associated with a just-after leaf node. |
virtual node_const_iterator |
node_end() const = 0; |
/// Returns the node_iterator associated with a just-after leaf node. |
virtual node_iterator |
node_end() = 0; |
/// Access to the cmp_fn object. |
virtual const access_traits& |
get_access_traits() const = 0; |
}; |
#include <ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp> |
#undef PB_DS_CLASS_C_DEC |
#define PB_DS_CLASS_C_DEC \ |
trie_order_statistics_node_update<Node_CItr, Node_Itr, \ |
_ATraits, _Alloc> |
/// Functor updating ranks of entrees. |
template<typename Node_CItr, |
typename Node_Itr, |
typename _ATraits, |
typename _Alloc> |
class trie_order_statistics_node_update : private PB_DS_TRIE_POLICY_BASE |
{ |
private: |
typedef PB_DS_TRIE_POLICY_BASE base_type; |
public: |
typedef _ATraits access_traits; |
typedef typename access_traits::const_iterator a_const_iterator; |
typedef _Alloc allocator_type; |
typedef typename allocator_type::size_type size_type; |
typedef typename base_type::key_type key_type; |
typedef typename base_type::key_const_reference key_const_reference; |
typedef size_type metadata_type; |
typedef Node_CItr node_const_iterator; |
typedef Node_Itr node_iterator; |
typedef typename node_const_iterator::value_type const_iterator; |
typedef typename node_iterator::value_type iterator; |
/// Finds an entry by __order. Returns a const_iterator to the |
/// entry with the __order order, or a const_iterator to the |
/// container object's end if order is at least the size of the |
/// container object. |
inline const_iterator |
find_by_order(size_type) const; |
/// Finds an entry by __order. Returns an iterator to the entry |
/// with the __order order, or an iterator to the container |
/// object's end if order is at least the size of the container |
/// object. |
inline iterator |
find_by_order(size_type); |
/// Returns the order of a key within a sequence. For exapmle, if |
/// r_key is the smallest key, this method will return 0; if r_key |
/// is a key between the smallest and next key, this method will |
/// return 1; if r_key is a key larger than the largest key, this |
/// method will return the size of r_c. |
inline size_type |
order_of_key(key_const_reference) const; |
/// Returns the order of a prefix within a sequence. For exapmle, |
/// if [b, e] is the smallest prefix, this method will return 0; if |
/// r_key is a key between the smallest and next key, this method |
/// will return 1; if r_key is a key larger than the largest key, |
/// this method will return the size of r_c. |
inline size_type |
order_of_prefix(a_const_iterator, a_const_iterator) const; |
protected: |
/// Updates the rank of a node through a node_iterator node_it; |
/// end_nd_it is the end node iterator. |
inline void |
operator()(node_iterator, node_const_iterator) const; |
private: |
typedef typename base_type::const_reference const_reference; |
typedef typename base_type::const_pointer const_pointer; |
typedef typename _Alloc::template rebind<metadata_type> __rebind_m; |
typedef typename __rebind_m::other __rebind_ma; |
typedef typename __rebind_ma::const_reference metadata_const_reference; |
typedef typename __rebind_ma::reference metadata_reference; |
/// Returns true if the container is empty. |
virtual bool |
empty() const = 0; |
/// Returns the iterator associated with the trie's first element. |
virtual iterator |
begin() = 0; |
/// Returns the iterator associated with the trie's |
/// just-after-last element. |
virtual iterator |
end() = 0; |
/// Returns the node_const_iterator associated with the trie's root node. |
virtual node_const_iterator |
node_begin() const = 0; |
/// Returns the node_iterator associated with the trie's root node. |
virtual node_iterator |
node_begin() = 0; |
/// Returns the node_const_iterator associated with a just-after |
/// leaf node. |
virtual node_const_iterator |
node_end() const = 0; |
/// Returns the node_iterator associated with a just-after leaf node. |
virtual node_iterator |
node_end() = 0; |
/// Access to the cmp_fn object. |
virtual access_traits& |
get_access_traits() = 0; |
}; |
#include <ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp> |
#undef PB_DS_CLASS_T_DEC |
#undef PB_DS_CLASS_C_DEC |
#undef PB_DS_TRIE_POLICY_BASE |
} // namespace __gnu_pbds |
#endif |