#pragma once
#ifndef _XTREE_
#define _XTREE_
#ifndef RC_INVOKED
#include <xmemory>
#include <stdexcept>
#if _HAS_CXX17
#include <xnode_handle.h>
#endif /* _HAS_CXX17 */
#pragma pack(push,_CRT_PACKING)
#pragma warning(push,_STL_WARNING_LEVEL)
#pragma warning(disable: _STL_DISABLED_WARNINGS)
#pragma warning(disable:
4455
4494
4619
4643
4702
4984
4988
)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
template
<
class
,
class
=
>
class
_Tree_unchecked_const_iterator
:
public
{
public
:
using
=
bidirectional_iterator_tag
;
using
=
typename
::_Nodeptr;
using
=
typename
::value_type;
using
=
typename
::difference_type;
using
=
typename
::const_pointer;
using
=
const
&;
_Tree_unchecked_const_iterator
()
: _Ptr()
{
}
_Tree_unchecked_const_iterator
(
,
const
*
)
: _Ptr(
)
{
this
->_Adopt(
);
}
_NODISCARD reference operator*() const
{
return
(
->_Myval);
}
_NODISCARD pointer operator->() const
{
return
(
<
>::
(
*
this
));
}
_Tree_unchecked_const_iterator
&
()
{
if
(
->_Right->_Isnil)
{
;
while
(!(
_Pnode
=
->_Parent)->_Isnil &&
==
_Pnode
->_Right)
{
=
_Pnode
;
}
=
_Pnode
;
}
else
{
=
::_Min(
->_Right);
}
return
(*
this
);
}
_Tree_unchecked_const_iterator
(
int
)
{
_Tree_unchecked_const_iterator
= *
this
;
*
this
;
return
(
_Tmp
);
}
_Tree_unchecked_const_iterator
&
()
{
if
(
->_Isnil)
{
=
->_Right;
}
else
if
(
->_Left->_Isnil)
{
;
while
(!(
_Pnode
=
->_Parent)->_Isnil &&
==
_Pnode
->_Left)
{
=
_Pnode
;
}
if
(!
->_Isnil)
{
=
_Pnode
;
}
}
else
{
=
::_Max(
->_Left);
}
return
(*
this
);
}
_Tree_unchecked_const_iterator
(
int
)
{
_Tree_unchecked_const_iterator
= *
this
;
*
this
;
return
(
_Tmp
);
}
_NODISCARD bool operator==(const _Tree_unchecked_const_iterator& _Right) const
bool
(
const
_Tree_unchecked_const_iterator
&
)
const
{
return
(
==
.
);
}
_NODISCARD bool operator!=(const _Tree_unchecked_const_iterator& _Right) const
bool
(
const
_Tree_unchecked_const_iterator
&
)
const
{
return
(!(*
this
));
}
;
};
template
<
class
>
class
:
public
_Tree_unchecked_const_iterator
<
>
{
public
:
using
=
_Tree_unchecked_const_iterator
<
>;
using
=
bidirectional_iterator_tag
;
using
=
typename
::_Nodeptr;
using
=
typename
::value_type;
using
=
typename
::difference_type;
using
=
typename
::pointer;
using
=
&;
()
{
}
(
,
const
*
)
:
(
,
)
{
}
_NODISCARD reference operator*() const
{
return
((
)
*(
*)
this
);
}
_NODISCARD pointer operator->() const
{
return
(
<
>::
(
*
this
));
}
&
()
{
static_cast
<
&>(*
this
);
return
(*
this
);
}
(
int
)
{
= *
this
;
*
this
;
return
(
_Tmp
);
}
&
()
{
static_cast
<
&>(*
this
);
return
(*
this
);
}
(
int
)
{
= *
this
;
*
this
;
return
(
_Tmp
);
}
};
template
<
class
>
class
:
public
_Tree_unchecked_const_iterator
<
,
>
{
public
:
using
=
_Tree_unchecked_const_iterator
<
,
>;
using
=
bidirectional_iterator_tag
;
using
=
typename
::_Nodeptr;
using
=
typename
::value_type;
using
=
typename
::difference_type;
using
=
typename
::const_pointer;
using
=
const
&;
()
:
()
{
}
(
,
const
*
)
:
(
,
)
{
}
_NODISCARD reference operator*() const
{
#if _ITERATOR_DEBUG_LEVEL != 0
const
auto
=
static_cast
<
const
*>(
this
->
());
_STL_ASSERT(_Mycont, "cannot dereference value-initialized map/set iterator");
do
{
if
(
_Mycont
) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
221
,
0
,
"%s"
,
"cannot dereference value-initialized map/set iterator"
)) || (__debugbreak(),
0
)); ::
(
L"\"cannot dereference value-initialized map/set iterator\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
221
,
0
); }
while
(
false
); } ; }
while
(
false
);
_STL_VERIFY(this->_Ptr != _Mycont->_Myhead, "cannot dereference end map/set iterator");
#endif /* _ITERATOR_DEBUG_LEVEL != 0 */
do
{
if
(
this
->
!=
_Mycont
->_Myhead) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
222
,
0
,
"%s"
,
"cannot dereference end map/set iterator"
)) || (__debugbreak(),
0
)); ::
(
L"\"cannot dereference end map/set iterator\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
222
,
0
); }
while
(
false
); } ; }
while
(
false
);
return
(
this
->
->_Myval);
}
_NODISCARD pointer operator->() const
{
return
(
<
>::
(
*
this
));
}
&
()
{
#if _ITERATOR_DEBUG_LEVEL != 0
_STL_VERIFY(this->_Getcont(), "cannot increment value-initialized map/set iterator");
do
{
if
(
this
->
()) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
236
,
0
,
"%s"
,
"cannot increment value-initialized map/set iterator"
)) || (__debugbreak(),
0
)); ::
(
L"\"cannot increment value-initialized map/set iterator\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
236
,
0
); }
while
(
false
); } ; }
while
(
false
);
_STL_VERIFY(!this->_Ptr->_Isnil, "cannot increment end map/set iterator");
#endif /* _ITERATOR_DEBUG_LEVEL != 0 */
do
{
if
(!
this
->
->_Isnil) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
237
,
0
,
"%s"
,
"cannot increment end map/set iterator"
)) || (__debugbreak(),
0
)); ::
(
L"\"cannot increment end map/set iterator\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
237
,
0
); }
while
(
false
); } ; }
while
(
false
);
static_cast
<
&>(*
this
);
return
(*
this
);
}
(
int
)
{
= *
this
;
*
this
;
return
(
_Tmp
);
}
&
()
{
#if _ITERATOR_DEBUG_LEVEL == 0
--static_cast<_Mybase&>(*this);
#else /* ^^^ _ITERATOR_DEBUG_LEVEL == 0 ^^^ // vvv _ITERATOR_DEBUG_LEVEL != 0 vvv */
_STL_ASSERT(this->_Getcont(), "cannot decrement value-initialized map/set iterator");
do
{
if
(
this
->
()) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
256
,
0
,
"%s"
,
"cannot decrement value-initialized map/set iterator"
)) || (__debugbreak(),
0
)); ::
(
L"\"cannot decrement value-initialized map/set iterator\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
256
,
0
); }
while
(
false
); } ; }
while
(
false
);
=
this
->
;
static_cast
<
&>(*
this
);
_STL_VERIFY(_Ptrsav != this->_Ptr, "cannot decrement begin map/set iterator");
#endif /* _ITERATOR_DEBUG_LEVEL == 0 */
do
{
if
(
_Ptrsav
!=
this
->
) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
259
,
0
,
"%s"
,
"cannot decrement begin map/set iterator"
)) || (__debugbreak(),
0
)); ::
(
L"\"cannot decrement begin map/set iterator\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
259
,
0
); }
while
(
false
); } ; }
while
(
false
);
return
(*
this
);
}
(
int
)
{
= *
this
;
*
this
;
return
(
_Tmp
);
}
_NODISCARD bool operator==(const _Tree_const_iterator& _Right) const
{
#if _ITERATOR_DEBUG_LEVEL != 0
_STL_VERIFY(this->_Getcont() == _Right._Getcont(), "map/set iterators incompatible");
#endif /* _ITERATOR_DEBUG_LEVEL != 0 */
do
{
if
(
this
->
()
.
()) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
275
,
0
,
"%s"
,
"map/set iterators incompatible"
)) || (__debugbreak(),
0
)); ::
(
L"\"map/set iterators incompatible\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
275
,
0
); }
while
(
false
); } ; }
while
(
false
);
return
(
this
->
==
.
);
}
_NODISCARD bool operator!=(const _Tree_const_iterator& _Right) const
{
return
(!(*
this
));
}
#if _ITERATOR_DEBUG_LEVEL != 0
friend
void
(
const
&
,
const
&
)
{
_STL_VERIFY(_First._Getcont() == _Last._Getcont(),
"map/set iterators in range are from different containers");
do
{
if
(
.
()
.
()) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
290
,
0
,
"%s"
,
"map/set iterators in range are from different containers"
)) || (__debugbreak(),
0
)); ::
(
L"\"map/set iterators in range are from different containers\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
290
,
0
); }
while
(
false
); } ; }
while
(
false
);
}
#endif /* _ITERATOR_DEBUG_LEVEL != 0 */
_NODISCARD _Tree_unchecked_const_iterator<_Mytree> _Unwrapped() const
_Tree_unchecked_const_iterator
<
>
()
const
{
return
(
_Tree_unchecked_const_iterator
<
>(
this
->
,
static_cast
<
const
*>(
this
->
())));
}
void
(
const
_Tree_unchecked_const_iterator
<
>
)
{
this
->
=
.
;
}
};
template
<
class
>
class
:
public
<
>
{
public
:
using
=
<
>;
using
=
bidirectional_iterator_tag
;
using
=
typename
::_Nodeptr;
using
=
typename
::value_type;
using
=
typename
::difference_type;
using
=
typename
::pointer;
using
=
&;
()
{
}
(
,
const
*
)
:
(
,
)
{
}
_NODISCARD reference operator*() const
{
return
((
)
*(
*)
this
);
}
_NODISCARD pointer operator->() const
{
return
(
<
>::
(
*
this
));
}
&
()
{
static_cast
<
&>(*
this
);
return
(*
this
);
}
(
int
)
{
= *
this
;
*
this
;
return
(
_Tmp
);
}
&
()
{
static_cast
<
&>(*
this
);
return
(*
this
);
}
(
int
)
{
= *
this
;
*
this
;
return
(
_Tmp
);
}
_NODISCARD _Tree_unchecked_iterator<_Mytree> _Unwrapped() const
{
return
(
<
>(
this
->
,
static_cast
<
const
*>(
this
->
())));
}
};
template
<
class
,
class
,
class
,
class
,
class
,
class
,
class
,
class
>
struct
{
using
=
;
using
=
;
using
=
;
using
=
;
using
=
;
using
=
;
};
template
<
class
,
class
>
struct
{
using
=
<
,
>;
;
;
;
char
;
char
;
;
&
(
const
&) =
delete
;
template
<
class
>
static
void
(
&
,
)
noexcept
{
using
=
<
,
>;
using
=
<
>;
(
);
_Alnode_traits::destroy(_Node_alloc, _STD addressof(_Ptr->_Left));
::
(
_Node_alloc
, ::
std
::
(
->
));
_Alnode_traits::destroy(_Node_alloc, _STD addressof(_Ptr->_Parent));
::
(
_Node_alloc
, ::
std
::
(
->
));
_Alnode_traits::destroy(_Node_alloc, _STD addressof(_Ptr->_Right));
::
(
_Node_alloc
, ::
std
::
(
->
));
::
(
_Node_alloc
,
,
1
);
}
};
template
<
class
>
struct
:
public
<
>
{
using
=
<
,
void
*>;
using
=
*;
};
template
<
class
,
class
>
struct
{
using
=
<
,
>;
using
=
<
>;
using
=
<
,
typename
<
>::
>;
using
=
<
,
>;
using
=
<
>;
using
=
typename
::
;
using
=
<
<
>,
<
>,
<
,
typename
::
,
typename
::
,
typename
::
,
typename
::
,
&,
const
&,
>>;
};
template
<
class
>
class
:
public
{
public
:
using
=
typename
::_Nodeptr;
using
=
typename
::value_type;
using
=
typename
::size_type;
using
=
typename
::difference_type;
using
=
typename
::pointer;
using
=
typename
::const_pointer;
using
=
&;
using
=
const
&;
using
=
<
>;
()
: _Myhead(),
_Mysize(
0
)
{
}
enum
{
,
};
static
(
)
{
while
(!
->_Right->_Isnil)
=
->_Right;
return
(
);
}
static
(
)
{
while
(!
->_Left->_Isnil)
=
->_Left;
return
(
);
}
&
()
const
{
return
(
->_Parent);
}
&
()
const
{
return
(
->_Left);
}
&
()
const
{
return
(
->_Right);
}
void
(
)
{
=
->_Right;
->_Right =
_Pnode
->_Left;
if
(!
_Pnode
->_Left->_Isnil)
{
_Pnode
->_Left->_Parent =
;
}
_Pnode
->_Parent =
->_Parent;
if
(
==
->_Parent)
{
->_Parent =
_Pnode
;
}
else
if
(
==
->_Parent->_Left)
{
->_Parent->_Left =
_Pnode
;
}
else
{
->_Parent->_Right =
_Pnode
;
}
_Pnode
->_Left =
;
->_Parent =
_Pnode
;
}
void
(
)
{
=
->_Left;
->_Left =
_Pnode
->_Right;
if
(!
_Pnode
->_Right->_Isnil)
_Pnode
->_Right->_Parent =
;
_Pnode
->_Parent =
->_Parent;
if
(
==
->_Parent)
{
->_Parent =
_Pnode
;
}
else
if
(
==
->_Parent->_Right)
{
->_Parent->_Right =
_Pnode
;
}
else
{
->_Parent->_Left =
_Pnode
;
}
_Pnode
->_Right =
;
->_Parent =
_Pnode
;
}
(
)
{
#if _ITERATOR_DEBUG_LEVEL == 2
_STL_VERIFY(_Where._Getcont() == this
&& !_Where._Ptr->_Isnil, "map/set erase iterator outside range");
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
do
{
if
(
.
()
this
&& !
.
->_Isnil) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
565
,
0
,
"%s"
,
"map/set erase iterator outside range"
)) || (__debugbreak(),
0
)); ::
(
L"\"map/set erase iterator outside range\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
565
,
0
); }
while
(
false
); } ; }
while
(
false
);
=
.
;
;
;
;
=
_Erasednode
;
if
(
_Pnode
->_Left->_Isnil)
{
_Fixnode
=
_Pnode
->_Right;
}
else
if
(
_Pnode
->_Right->_Isnil)
{
_Fixnode
=
_Pnode
->_Left;
}
else
{
_Pnode
=
.
;
_Fixnode
=
_Pnode
->_Right;
}
if
(
_Pnode
==
_Erasednode
)
{
_Fixnodeparent
=
_Erasednode
->_Parent;
if
(!
_Fixnode
->_Isnil)
_Fixnode
->_Parent =
_Fixnodeparent
;
if
(
() ==
_Erasednode
)
{
() =
_Fixnode
;
}
else
if
(
_Fixnodeparent
->_Left ==
_Erasednode
)
{
_Fixnodeparent
->_Left =
_Fixnode
;
}
else
{
_Fixnodeparent
->_Right =
_Fixnode
;
}
if
(
() ==
_Erasednode
)
{
() =
_Fixnode
->_Isnil
?
_Fixnodeparent
:
(
_Fixnode
);
}
if
(
() ==
_Erasednode
)
{
() =
_Fixnode
->_Isnil
?
_Fixnodeparent
:
(
_Fixnode
);
}
}
else
{
_Erasednode
->_Left->_Parent =
_Pnode
;
_Pnode
->_Left =
_Erasednode
->_Left;
if
(
_Pnode
==
_Erasednode
->_Right)
{
_Fixnodeparent
=
_Pnode
;
}
else
{
_Fixnodeparent
=
_Pnode
->_Parent;
if
(!
_Fixnode
->_Isnil)
{
_Fixnode
->_Parent =
_Fixnodeparent
;
}
_Fixnodeparent
->_Left =
_Fixnode
;
_Pnode
->_Right =
_Erasednode
->_Right;
_Erasednode
->_Right->_Parent =
_Pnode
;
}
if
(
() ==
_Erasednode
)
{
() =
_Pnode
;
}
else
if
(
_Erasednode
->_Parent->_Left ==
_Erasednode
)
{
_Erasednode
->_Parent->_Left =
_Pnode
;
}
else
{
_Erasednode
->_Parent->_Right =
_Pnode
;
}
_Pnode
->_Parent =
_Erasednode
->_Parent;
_STD swap(_Pnode->_Color, _Erasednode->_Color); // recolor it
::
std
::
(
_Pnode
->_Color,
_Erasednode
->_Color);
}
if
(
_Erasednode
->_Color ==
this
->
)
{
for
(;
_Fixnode
!=
()
&&
_Fixnode
->_Color ==
this
->
;
_Fixnodeparent
=
_Fixnode
->_Parent)
if
(
_Fixnode
==
_Fixnodeparent
->_Left)
{
_Pnode
=
_Fixnodeparent
->_Right;
if
(
_Pnode
->_Color ==
this
->
)
{
_Pnode
->_Color =
this
->
;
_Fixnodeparent
->_Color =
this
->
;
(
_Fixnodeparent
);
_Pnode
=
_Fixnodeparent
->_Right;
}
if
(
_Pnode
->_Isnil)
_Fixnode
=
_Fixnodeparent
;
else
if
(
_Pnode
->_Left->_Color ==
this
->
&&
_Pnode
->_Right->_Color ==
this
->
)
{
_Pnode
->_Color =
this
->
;
_Fixnode
=
_Fixnodeparent
;
}
else
{
if
(
_Pnode
->_Right->_Color ==
this
->
)
{
_Pnode
->_Left->_Color =
this
->
;
_Pnode
->_Color =
this
->
;
(
_Pnode
);
_Pnode
=
_Fixnodeparent
->_Right;
}
_Pnode
->_Color =
_Fixnodeparent
->_Color;
_Fixnodeparent
->_Color =
this
->
;
_Pnode
->_Right->_Color =
this
->
;
(
_Fixnodeparent
);
break
;
}
}
else
{
_Pnode
=
_Fixnodeparent
->_Left;
if
(
_Pnode
->_Color ==
this
->
)
{
_Pnode
->_Color =
this
->
;
_Fixnodeparent
->_Color =
this
->
;
(
_Fixnodeparent
);
_Pnode
=
_Fixnodeparent
->_Left;
}
if
(
_Pnode
->_Isnil)
_Fixnode
=
_Fixnodeparent
;
else
if
(
_Pnode
->_Right->_Color ==
this
->
&&
_Pnode
->_Left->_Color ==
this
->
)
{
_Pnode
->_Color =
this
->
;
_Fixnode
=
_Fixnodeparent
;
}
else
{
if
(
_Pnode
->_Left->_Color ==
this
->
)
{
_Pnode
->_Right->_Color =
this
->
;
_Pnode
->_Color =
this
->
;
(
_Pnode
);
_Pnode
=
_Fixnodeparent
->_Left;
}
_Pnode
->_Color =
_Fixnodeparent
->_Color;
_Fixnodeparent
->_Color =
this
->
;
_Pnode
->_Left->_Color =
this
->
;
(
_Fixnodeparent
);
break
;
}
}
_Fixnode
->_Color =
this
->
;
}
if
(
0
<
)
--
;
return
(
_Erasednode
);
}
;
;
};
template
<
class
>
class
{
public
:
using
=
typename
::allocator_type;
using
=
typename
::key_compare;
using
=
<
typename
::value_type,
>;
using
=
typename
::
;
using
=
typename
::
;
using
=
<
,
>;
using
=
<
>;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
&;
using
=
const
&;
using
=
<
<
>>;
using
=
<
<
>>;
using
=
<
<
>>;
using
_Unchecked_const_iterator
=
_Tree_unchecked_const_iterator
<
<
>>;
enum
{
,
};
(
const
&
)
: _Mypair(
_One_then_variadic_args_t
(),
,
_Zero_then_variadic_args_t
())
{
();
}
template
<
class
,
class
=
<!
<
<
<
>>,
>>>
(
const
&
,
&&
)
: _Mypair(
_One_then_variadic_args_t
(),
,
_One_then_variadic_args_t
(),
_STD forward<_Any_alloc>(_Al))
{
();
}
#if _ITERATOR_DEBUG_LEVEL == 0
void _Construct()
{ // construct head node
_Get_data()._Myhead = _Buyheadnode();
}
~_Tree_comp_alloc() noexcept
{ // destroy head node
_Freeheadnode(_Get_data()._Myhead);
}
void _Alloc_proxy()
{ // do nothing
}
void _Free_proxy()
{ // do nothing
}
#else /* _ITERATOR_DEBUG_LEVEL == 0 */
void
()
{
auto
&
=
();
_My_data
.
=
();
();
(
_My_data
.
);
}
()
noexcept
{
(
().
);
();
}
void
()
{
(
());
() =
(
_Proxy_allocator
.
(
1
));
::
(
_Proxy_allocator
,
(),
());
_Myproxy()->_Mycont = _STD addressof(_Get_data());
}
void
()
{
(
());
();
::
(
_Proxy_allocator
,
());
(
_Proxy_allocator
,
());
() =
nullptr
;
}
**
()
const
{
return
(
().
());
}
* &
()
noexcept
{
return
(
().
);
}
*
const
&
()
const
noexcept
{
return
(
().
);
}
#endif /* _ITERATOR_DEBUG_LEVEL == 0 */
void
(
const
&
)
{
const
bool
=
::
propagate_on_container_copy_assignment
::
&&
() !=
;
if
(
_Reload
)
{
();
(
().
);
}
(
(),
);
if
(
_Reload
)
{
().
=
();
();
}
}
void
(
&
)
{
const
bool
=
::
propagate_on_container_move_assignment
::
&&
() !=
;
if
(
_Reload
)
{
();
(
().
);
}
(
(),
);
if
(
_Reload
)
{
().
=
();
();
}
}
void
()
{
().
();
}
void
(
&
)
{
().
(
.
());
}
()
{
&
=
();
=
_Al
.
(
1
);
_Alnode_traits::construct(_Al, _STD addressof(_Pnode->_Left), _Pnode);
::
(
_Al
, ::
std
::
(
_Pnode
->
),
_Pnode
);
_Alnode_traits::construct(_Al, _STD addressof(_Pnode->_Parent), _Pnode);
::
(
_Al
, ::
std
::
(
_Pnode
->
),
_Pnode
);
_Alnode_traits::construct(_Al, _STD addressof(_Pnode->_Right), _Pnode);
::
(
_Al
, ::
std
::
(
_Pnode
->
),
_Pnode
);
_Al
.
(
_Pnode
,
1
);
_Pnode
->
=
;
_Pnode
->
=
true
;
return
(
_Pnode
);
}
void
(
)
{
::
(
(),
);
}
()
{
&
=
();
=
_Al
.
(
1
);
auto
&
=
();
_Alnode_traits::construct(_Al, _STD addressof(_Pnode->_Left), _My_data._Myhead);
::
(
_Al
, ::
std
::
(
_Pnode
->
),
_My_data
.
);
_Alnode_traits::construct(_Al, _STD addressof(_Pnode->_Parent), _My_data._Myhead);
::
(
_Al
, ::
std
::
(
_Pnode
->
),
_My_data
.
);
_Alnode_traits::construct(_Al, _STD addressof(_Pnode->_Right), _My_data._Myhead);
::
(
_Al
, ::
std
::
(
_Pnode
->
),
_My_data
.
);
_Al
.
(
_Pnode
,
1
);
return
(
_Pnode
);
}
void
(
)
{
::
(
(),
);
}
template
<
class
...
>
(
&&...
)
{
=
();
_Pnode
->
=
;
_Pnode
->
=
false
;
::
(
(),
_STD addressof(_Pnode->_Myval), _STD forward<_Valty>(_Val)...);
::
std
::
(
_Pnode
->
), ::
std
::
<
>(
)...);
(
_Pnode
);
return
(
_Pnode
);
}
&
()
noexcept
{
return
(
.
());
}
const
&
()
const
noexcept
{
return
(
.
());
}
&
()
noexcept
{
return
(
.
().
());
}
const
&
()
const
noexcept
{
return
(
.
().
());
}
<
>&
()
noexcept
{
return
(
.
().
());
}
const
<
>&
()
const
noexcept
{
return
(
.
().
());
}
private
:
<
,
<
,
<
>>>
;
};
template
<
class
>
class
:
public
<
>
{
public
:
using
=
<
>;
using
=
typename
::key_type;
using
=
typename
::value_compare;
enum
{
=
::_Multi};
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
typename
::
;
using
=
&;
using
=
const
&;
using
=
<
<
,
>,
typename
::
,
typename
::
>;
using
=
typename
::
;
using
=
<
<
,
>,
typename
::
_Unchecked_const_iterator
,
typename
::
>;
using
_Unchecked_const_iterator
=
typename
::
_Unchecked_const_iterator
;
using reverse_iterator = _STD reverse_iterator<iterator>;
using const_reverse_iterator = _STD reverse_iterator<const_iterator>;
using
=
<
,
bool
>;
using
=
<
,
>;
using
=
<
,
>;
using
=
<
typename
::
>;
struct
{
};
struct
{
};
(
const
&
)
:
(
)
{
}
(
const
&
,
const
&
)
:
(
,
)
{
}
template
<
class
>
(
const
&
,
&&
)
: _Mybase(_Right.key_comp(), _STD forward<_Any_alloc>(_Al))
{
(
,
());
();
}
(
&&
)
: _Mybase(_Right.key_comp(), _STD move(_Right._Getal()))
{
_Assign_rv(_STD move(_Right), true_type());
}
(
&&
,
const
&
)
:
(
.
(),
)
{
_Assign_rv(_STD move(_Right), false_type());
}
&
(
&&
)
{
if (this != _STD addressof(_Right))
{
();
this
->
(
.
());
this
->
() =
.
();
_Assign_rv(_STD move(_Right), bool_constant<_Always_equal_after_move<_Alnode>>{});
}
return
(*
this
);
}
void
(
&&
,
)
{
this
->
(
);
(
this
->
(),
.
());
auto
&
=
this
->
();
auto
&
=
.
();
(
_My_data
.
,
_Right_data
.
);
_STD swap(_My_data._Mysize, _Right_data._Mysize);
::
std
::
(
_My_data
.
,
_Right_data
.
);
}
void
(
&&
,
)
{
if
(
this
->
()
.
())
{
_Assign_rv(_STD move(_Right), true_type());
}
else
{
(
,
());
}
}
template
<
class
...
>
(
&&...
)
{
_Nodeptr _Newnode = this->_Buynode(_STD forward<_Valty>(_Val)...);
=
this
->
(::
std
::
<
>(
)...);
return
(
(
false
,
_Newnode
->
,
_Newnode
));
}
template
<
class
...
>
(
,
&&...
)
{
_Nodeptr _Newnode = this->_Buynode(_STD forward<_Valty>(_Val)...);
=
this
->
(::
std
::
<
>(
)...);
return
(
(
,
_Newnode
->
,
_Newnode
));
}
()
noexcept
{
();
}
&
(
const
&
)
{
if (this != _STD addressof(_Right))
{
();
this
->
(
.
());
this
->
() =
.
();
(
,
());
}
return
(*
this
);
}
_NODISCARD iterator begin() noexcept
{
auto
&
=
this
->
();
return (iterator(_My_data._Lmost(), _STD addressof(_My_data)));
return
(
(
_My_data
.
(), ::
std
::
(
_My_data
)));
}
_NODISCARD const_iterator begin() const noexcept
{
auto
&
=
this
->
();
return (const_iterator(_My_data._Lmost(), _STD addressof(_My_data)));
return
(
(
_My_data
.
(), ::
std
::
(
_My_data
)));
}
_NODISCARD iterator end() noexcept
{
auto
&
=
this
->
();
return (iterator(_My_data._Myhead, _STD addressof(_My_data)));
return
(
(
_My_data
.
, ::
std
::
(
_My_data
)));
}
_NODISCARD const_iterator end() const noexcept
{
auto
&
=
this
->
();
return (const_iterator(_My_data._Myhead, _STD addressof(_My_data)));
return
(
(
_My_data
.
, ::
std
::
(
_My_data
)));
}
()
noexcept
{
return
(
(
this
->
().
(),
nullptr
));
}
_Unchecked_const_iterator
()
const
noexcept
{
return
(
_Unchecked_const_iterator
(
this
->
().
(),
nullptr
));
}
()
noexcept
{
return
(
(
this
->
().
,
nullptr
));
}
_Unchecked_const_iterator
()
const
noexcept
{
return
(
_Unchecked_const_iterator
(
this
->
().
,
nullptr
));
}
_NODISCARD reverse_iterator rbegin() noexcept
{
return
(
(
()));
}
_NODISCARD const_reverse_iterator rbegin() const noexcept
{
return
(
(
()));
}
_NODISCARD reverse_iterator rend() noexcept
{
return
(
(
()));
}
_NODISCARD const_reverse_iterator rend() const noexcept
{
return
(
(
()));
}
_NODISCARD const_iterator cbegin() const noexcept
{
return
(
());
}
_NODISCARD const_iterator cend() const noexcept
{
return
(
());
}
_NODISCARD const_reverse_iterator crbegin() const noexcept
{
return
(
());
}
_NODISCARD const_reverse_iterator crend() const noexcept
{
return
(
());
}
_NODISCARD size_type size() const noexcept
{
return
(
this
->
().
);
}
_NODISCARD size_type max_size() const noexcept
{
return
(
::
(
this
->
()));
}
_NODISCARD bool empty() const noexcept
{
return
(
()
0
);
}
_NODISCARD allocator_type get_allocator() const noexcept
{
return
(
static_cast
<
>(
this
->
()));
}
_NODISCARD key_compare key_comp() const
{
return
(
this
->
());
}
_NODISCARD value_compare value_comp() const
{
return
(
(
()));
}
template
<
bool
=
,
<!
,
int
> =
0
>
(
const
&
)
{
return
(
(
false
,
,
()));
}
template
<
bool
=
,
<
,
int
> =
0
>
(
const
&
)
{
return
(
(
false
,
,
()).
);
}
template
<
bool
=
,
<!
,
int
> =
0
>
(
&&
)
{
return (_Insert_nohint(false, _STD move(_Val), _Not_a_node_tag()));
return
(
(
false
, ::
std
::
(
),
()));
}
template
<
bool
=
,
<
,
int
> =
0
>
(
&&
)
{
return (_Insert_nohint(false, _STD move(_Val), _Not_a_node_tag()).first);
return
(
(
false
, ::
std
::
(
),
()).
);
}
(
,
const
&
)
{
return
(
(
,
,
()));
}
(
,
&&
)
{
return (_Insert_hint(_Where, _STD move(_Val), _Not_a_node_tag()));
return
(
(
, ::
std
::
(
),
()));
}
template
<
class
>
void
(
,
)
{
(
,
);
auto
=
(
);
const
auto
=
(
);
for
(;
_UFirst
!=
_ULast
; ++
_UFirst
)
{
(
(), *
_UFirst
);
}
}
void
(
<
>
)
{
(
.
(),
.
());
}
template
<
class
=
,
class
=
<!
<
,
>>>
(
)
{
return
(
(
{
}));
}
(
)
{
auto
&
=
this
->
();
#if _ITERATOR_DEBUG_LEVEL == 2
_STL_VERIFY(_Where._Getcont() == _STD addressof(_My_data)
&& !_Where._Ptr->_Isnil, "map/set erase iterator outside range");
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
do
{
if
(
.
()
::
std
::
(
_My_data
) && !
.
->
) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
1366
,
0
,
"%s"
,
"map/set erase iterator outside range"
)) || (__debugbreak(),
0
)); ::
(
L"\"map/set erase iterator outside range\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
1366
,
0
); }
while
(
false
); } ; }
while
(
false
);
=
;
_Successor
;
=
_My_data
.
(
);
#if _ITERATOR_DEBUG_LEVEL == 2
(
_Erasednode
);
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
&
=
this
->
();
_Alnode_traits::destroy(_Al, _STD addressof(_Erasednode->_Myval)); // delete erased node
::
(
_Al
, ::
std
::
(
_Erasednode
->
));
::
(
_Al
,
_Erasednode
);
return (iterator(_Successor._Ptr, _STD addressof(_My_data))); // return successor iterator
return
(
(
_Successor
.
, ::
std
::
(
_My_data
)));
}
(
,
)
{
if
(
() &&
==
())
{
();
return
(
());
}
else
{
while
(
)
(
);
return (iterator(_First._Ptr, _STD addressof(this->_Get_data())));
return
(
(
.
, ::
std
::
(
this
->
())));
}
}
(
const
&
)
{
=
(
);
const auto _Num = static_cast<size_type>(_STD distance(_Where.first, _Where.second));
const
auto
=
static_cast
<
>(::
std
::
(
_Where
.
,
_Where
.
));
(
_Where
.
,
_Where
.
);
return
(
_Num
);
}
void
()
noexcept
{
#if _ITERATOR_DEBUG_LEVEL == 2
this
->
(
nullptr
);
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
auto
&
=
this
->
();
auto
=
_My_data
.
;
(
_My_data
.
());
_My_data
.
() =
_Head
;
_My_data
.
() =
_Head
;
_My_data
.
() =
_Head
;
_My_data
.
=
0
;
}
_NODISCARD iterator find(const key_type& _Keyval)
{
=
(
);
return
(
_Where
()
|| _DEBUG_LT_PRED(this->_Getcomp(),
_Keyval, this->_Key(_Where._Ptr))
||
(
this
->
(),
,
this
->
(
_Where
.
))
?
() :
_Where
);
}
_NODISCARD const_iterator find(const key_type& _Keyval) const
{
=
(
);
return
(
_Where
()
|| _DEBUG_LT_PRED(this->_Getcomp(),
_Keyval, this->_Key(_Where._Ptr))
||
(
this
->
(),
,
this
->
(
_Where
.
))
?
() :
_Where
);
}
template
<
class
,
class
=
,
class
=
typename
::is_transparent>
_NODISCARD iterator find(const _Other& _Keyval)
{
=
(
);
return
(
_Where
()
|| _DEBUG_LT_PRED(this->_Getcomp(),
_Keyval, this->_Key(_Where._Ptr))
||
(
this
->
(),
,
this
->
(
_Where
.
))
?
() :
_Where
);
}
template
<
class
,
class
=
,
class
=
typename
::is_transparent>
_NODISCARD const_iterator find(const _Other& _Keyval) const
{
=
(
);
return
(
_Where
()
|| _DEBUG_LT_PRED(this->_Getcomp(),
_Keyval, this->_Key(_Where._Ptr))
||
(
this
->
(),
,
this
->
(
_Where
.
))
?
() :
_Where
);
}
_NODISCARD size_type count(const key_type& _Keyval) const
{
=
(
);
return (static_cast<size_type>(_STD distance(_Ans.first, _Ans.second)));
return
(
static_cast
<
>(::
std
::
(
_Ans
.
,
_Ans
.
)));
}
template
<
class
,
class
=
,
class
=
typename
::is_transparent>
_NODISCARD size_type count(const _Other& _Keyval) const
{
=
(
);
return (static_cast<size_type>(_STD distance(_Ans.first, _Ans.second)));
return
(
static_cast
<
>(::
std
::
(
_Ans
.
,
_Ans
.
)));
}
_NODISCARD iterator lower_bound(const key_type& _Keyval)
{
return (iterator(_Lbound(_Keyval), _STD addressof(this->_Get_data())));
return
(
(
(
), ::
std
::
(
this
->
())));
}
_NODISCARD const_iterator lower_bound(const key_type& _Keyval) const
{
return (const_iterator(_Lbound(_Keyval), _STD addressof(this->_Get_data())));
return
(
(
(
), ::
std
::
(
this
->
())));
}
template
<
class
,
class
=
,
class
=
typename
::is_transparent>
_NODISCARD iterator lower_bound(const _Other& _Keyval)
{
return (iterator(_Lbound(_Keyval), _STD addressof(this->_Get_data())));
return
(
(
(
), ::
std
::
(
this
->
())));
}
template
<
class
,
class
=
,
class
=
typename
::is_transparent>
_NODISCARD const_iterator lower_bound(const _Other& _Keyval) const
{
return (const_iterator(_Lbound(_Keyval), _STD addressof(this->_Get_data())));
return
(
(
(
), ::
std
::
(
this
->
())));
}
_NODISCARD iterator upper_bound(const key_type& _Keyval)
{
return (iterator(_Ubound(_Keyval), _STD addressof(this->_Get_data())));
return
(
(
(
), ::
std
::
(
this
->
())));
}
_NODISCARD const_iterator upper_bound(const key_type& _Keyval) const
{
return (const_iterator(_Ubound(_Keyval), _STD addressof(this->_Get_data())));
return
(
(
(
), ::
std
::
(
this
->
())));
}
template
<
class
,
class
=
,
class
=
typename
::is_transparent>
_NODISCARD iterator upper_bound(const _Other& _Keyval)
{
return (iterator(_Ubound(_Keyval), _STD addressof(this->_Get_data())));
return
(
(
(
), ::
std
::
(
this
->
())));
}
template
<
class
,
class
=
,
class
=
typename
::is_transparent>
_NODISCARD const_iterator upper_bound(const _Other& _Keyval) const
{
return (const_iterator(_Ubound(_Keyval), _STD addressof(this->_Get_data())));
return
(
(
(
), ::
std
::
(
this
->
())));
}
_NODISCARD _Pairii equal_range(const key_type& _Keyval)
{
return
(
(
));
}
_NODISCARD _Paircc equal_range(const key_type& _Keyval) const
{
return
(
(
));
}
template
<
class
,
class
=
,
class
=
typename
::is_transparent>
_NODISCARD _Pairii equal_range(const _Other& _Keyval)
{
return
(
(
));
}
template
<
class
,
class
=
,
class
=
typename
::is_transparent>
_NODISCARD _Paircc equal_range(const _Other& _Keyval) const
{
return
(
(
));
}
void swap(_Tree& _Right) _NOEXCEPT_COND(_Is_nothrow_swappable<key_compare>::value) // strengthened
{
if (this != _STD addressof(_Right))
{
(
this
->
(),
.
());
(
this
->
(),
.
());
this
->
(
);
auto
&
=
this
->
();
auto
&
=
.
();
(
_My_data
.
,
_Right_data
.
);
_STD swap(_My_data._Mysize, _Right_data._Mysize);
::
std
::
(
_My_data
.
,
_Right_data
.
);
}
}
protected
:
template
<
class
>
(
,
&&)
{
return
(
);
}
template
<
class
>
(
,
&&
)
{
return (this->_Buynode(_STD forward<_Valty>(_Val)));
return
(
this
->
(::
std
::
<
>(
)));
}
void
(
)
{
&
=
this
->
();
_Alnode_traits::destroy(_Al, _STD addressof(_Newnode->_Myval));
::
(
_Al
,
);
}
void
(
)
{
}
template
<
class
,
class
>
(
,
&&
,
)
{
;
bool
=
false
;
auto
&
=
this
->
();
#if _ITERATOR_DEBUG_LEVEL == 2
_STL_VERIFY(_Where._Getcont() == _STD addressof(_My_data), "map/set insert iterator outside range");
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
do
{
if
(
.
()
::
std
::
(
_My_data
)) { }
else
{
do
{ (
void
) ((
1
(
2
,
"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
1606
,
0
,
"%s"
,
"map/set insert iterator outside range"
)) || (__debugbreak(),
0
)); ::
(
L"\"map/set insert iterator outside range\""
, __LPREFIX( __FUNCTION__),
L"c:\\program files (x86)\\microsoft visual studio\\2017\\professional\\vc\\tools\\msvc\\14.16.27023\\include\\xtree"
,
1606
,
0
); }
while
(
false
); } ; }
while
(
false
);
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#pragma warning(disable:
4127
)
if
(
()
0
)
{
return
(
(
true
,
_My_data
.
,
_STD forward<_Valty>(_Val), _Newnode)); // empty tree
}
else
if
(
this
->
)
{
if
(
())
{
if (!_DEBUG_LT_PRED(this->_Getcomp(),
this->_Key(_Where._Ptr), this->_Kfn(_Val)))
if
(!
(
this
->
(),
this
->
(
.
),
this
->
(
)))
return
(
(
true
,
.
,
_STD forward<_Valty>(_Val), _Newnode));
_Leftish
=
true
;
}
else
if
(
())
{
if (!_DEBUG_LT_PRED(this->_Getcomp(),
this->_Kfn(_Val), this->_Key(_My_data._Rmost())))
if
(!
(
this
->
(),
this
->
(
),
this
->
(
_My_data
.
())))
return
(
(
false
,
_My_data
.
(),
_STD forward<_Valty>(_Val), _Newnode));
}
else if (!_DEBUG_LT_PRED(this->_Getcomp(),
this->_Key(_Where._Ptr), this->_Kfn(_Val))
else
if
(!
(
this
->
(),
this
->
(
.
),
this
->
(
))
&& !_DEBUG_LT_PRED(this->_Getcomp(),
this->_Kfn(_Val),
this->_Key((--(_Next = _Where))._Ptr)))
&& !
(
this
->
(),
this
->
(
),
this
->
((
(
_Next
)).
)))
{
if
(
_Next
.
->
->
)
return
(
(
false
,
_Next
.
,
_STD forward<_Valty>(_Val), _Newnode));
else
return
(
(
true
,
.
,
_STD forward<_Valty>(_Val), _Newnode));
}
else if (!_DEBUG_LT_PRED(this->_Getcomp(),
this->_Kfn(_Val), this->_Key(_Where._Ptr))
else
if
(!
(
this
->
(),
this
->
(
),
this
->
(
.
))
&& (
(
_Next
)
()
|| !_DEBUG_LT_PRED(this->_Getcomp(),
this->_Key(_Next._Ptr), this->_Kfn(_Val))))
|| !
(
this
->
(),
this
->
(
_Next
.
),
this
->
(
))))
{
if
(
.
->
->
)
return
(
(
false
,
.
,
_STD forward<_Valty>(_Val), _Newnode));
else
return
(
(
true
,
_Next
.
,
_STD forward<_Valty>(_Val), _Newnode));
}
else
{
_Leftish
=
true
;
}
}
else
{
if
(
())
{
if (_DEBUG_LT_PRED(this->_Getcomp(),
this->_Kfn(_Val), this->_Key(_Where._Ptr)))
if
(
(
this
->
(),
this
->
(
),
this
->
(
.
)))
{
return
(
(
true
,
.
,
_STD forward<_Valty>(_Val), _Newnode));
}
}
else
if
(
())
{
if (_DEBUG_LT_PRED(this->_Getcomp(),
this->_Key(_My_data._Rmost()), this->_Kfn(_Val)))
if
(
(
this
->
(),
this
->
(
_My_data
.
()),
this
->
(
)))
{
return
(
(
false
,
_My_data
.
(),
_STD forward<_Valty>(_Val), _Newnode));
}
}
else if (_DEBUG_LT_PRED(this->_Getcomp(),
this->_Kfn(_Val), this->_Key(_Where._Ptr))
else
if
(
(
this
->
(),
this
->
(
),
this
->
(
.
))
&& _DEBUG_LT_PRED(this->_Getcomp(),
this->_Key((--(_Next = _Where))._Ptr),
this->_Kfn(_Val)))
&&
(
this
->
(),
this
->
((
(
_Next
)).
),
this
->
(
)))
{
if
(
_Next
.
->
->
)
{
return
(
(
false
,
_Next
.
,
_STD forward<_Valty>(_Val), _Newnode));
}
else
{
return
(
(
true
,
.
,
_STD forward<_Valty>(_Val), _Newnode));
}
}
else if (_DEBUG_LT_PRED(this->_Getcomp(),
this->_Key(_Where._Ptr), this->_Kfn(_Val))
else
if
(
(
this
->
(),
this
->
(
.
),
this
->
(
))
&& (
(
_Next
)
()
|| _DEBUG_LT_PRED(this->_Getcomp(),
this->_Kfn(_Val), this->_Key(_Next._Ptr))))
||
(
this
->
(),
this
->
(
),
this
->
(
_Next
.
))))
{
if
(
.
->
->
)
{
return
(
(
false
,
.
,
_STD forward<_Valty>(_Val), _Newnode));
}
else
{
return
(
(
true
,
_Next
.
,
_STD forward<_Valty>(_Val), _Newnode));
}
}
}
#pragma warning(pop)
(
);
return
(
(
_Leftish
,
_STD forward<_Valty>(_Val), _Newnode).first);
}
template
<
class
,
class
>
(
bool
,
&&
,
)
{
auto
&
=
this
->
();
=
_My_data
.
;
=
_Wherenode
->
;
bool
=
true
;
while
(!
_Trynode
->
)
{
_Wherenode
=
_Trynode
;
if
(
)
{
_Addleft = !_DEBUG_LT_PRED(this->_Getcomp(),
this->_Key(_Trynode),
this->_Kfn(_Val)); // favor left end
_Addleft
= !
(
this
->
(),
this
->
(
_Trynode
),
this
->
(
));
}
else
{
_Addleft = _DEBUG_LT_PRED(this->_Getcomp(),
this->_Kfn(_Val),
this->_Key(_Trynode)); // favor right end
_Addleft
=
(
this
->
(),
this
->
(
),
this
->
(
_Trynode
));
}
_Trynode
=
_Addleft
?
_Trynode
->
:
_Trynode
->
;
}
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#pragma warning(disable:
4127
)
if
(
this
->
)
{
return
(
(
(
_Addleft
,
_Wherenode
,
_STD forward<_Valty>(_Val), _Newnode), true));
}
else
{
iterator _Where = iterator(_Wherenode, _STD addressof(_My_data));
=
(
_Wherenode
, ::
std
::
(
_My_data
));
if
(!
_Addleft
)
{
}
else
if
(
_Where
())
{
return
(
(
(
true
,
_Wherenode
,
_STD forward<_Valty>(_Val), _Newnode), true));
}
else
{
_Where
;
}
if (_DEBUG_LT_PRED(this->_Getcomp(),
this->_Key(_Where._Ptr),
this->_Kfn(_Val)))
if
(
(
this
->
(),
this
->
(
_Where
.
),
this
->
(
)))
{
return
(
(
(
_Addleft
,
_Wherenode
,
_STD forward<_Valty>(_Val), _Newnode), true));
}
else
{
(
);
return
(
(
_Where
,
false
));
}
}
#pragma warning(pop)
(
);
}
template
<
class
,
class
>
(
bool
,
,
&&
,
)
{
auto
&
=
this
->
();
if
(
() -
1
<=
_My_data
.
)
{
(
);
(
"map/set<T> too long"
);
}
_Nodeptr _Newnode = _Buy_if_not_node(_Node, _STD forward<_Valty>(_Val));
++
_My_data
.
;
_Newnode
->
=
;
if
(
_My_data
.
)
{
_My_data
.
() =
_Newnode
;
_My_data
.
() =
_Newnode
;
_My_data
.
() =
_Newnode
;
}
else
if
(
)
{
->
=
_Newnode
;
if
(
_My_data
.
())
{
_My_data
.
() =
_Newnode
;
}
}
else
{
->
=
_Newnode
;
if
(
_My_data
.
())
{
_My_data
.
() =
_Newnode
;
}
}
for
(
=
_Newnode
;
_Pnode
->
->
this
->
; )
{
if
(
_Pnode
->
_Pnode
->
->
->
)
{
=
_Pnode
->
->
->
;
if
(
->
this
->
)
{
_Pnode
->
->
=
this
->
;
->
=
this
->
;
_Pnode
->
->
->
=
this
->
;
_Pnode
=
_Pnode
->
->
;
}
else
{
if
(
_Pnode
_Pnode
->
->
)
{
_Pnode
=
_Pnode
->
;
_My_data
.
(
_Pnode
);
}
_Pnode
->
->
=
this
->
;
_Pnode
->
->
->
=
this
->
;
_My_data
.
(
_Pnode
->
->
);
}
}
else
{
=
_Pnode
->
->
->
;
if
(
->
this
->
)
{
_Pnode
->
->
=
this
->
;
->
=
this
->
;
_Pnode
->
->
->
=
this
->
;
_Pnode
=
_Pnode
->
->
;
}
else
{
if
(
_Pnode
_Pnode
->
->
)
{
_Pnode
=
_Pnode
->
;
_My_data
.
(
_Pnode
);
}
_Pnode
->
->
=
this
->
;
_Pnode
->
->
->
=
this
->
;
_My_data
.
(
_Pnode
->
->
);
}
}
}
_My_data
.
()->
=
this
->
;
return (iterator(_Newnode, _STD addressof(_My_data)));
return
(
(
_Newnode
, ::
std
::
(
_My_data
)));
}
template
<
class
>
void
(
const
&
,
)
{
auto
&
=
this
->
();
_My_data
.
() =
(
.
().
(),
_My_data
.
,
);
_My_data
.
=
.
();
if
(!
_My_data
.
()->
)
{
_My_data
.
() =
::
(
_My_data
.
());
_My_data
.
() =
::
(
_My_data
.
());
}
else
{
_My_data
.
() =
_My_data
.
;
_My_data
.
() =
_My_data
.
;
}
}
template
<
class
,
class
>
(
&
,
,
)
{
return
(
this
->
(
));
}
template
<
class
>
(
&
,
,
)
{
return (this->_Buynode(_STD move(_Val)));
return
(
this
->
(::
std
::
(
)));
}
template
<
class
>
(
&
,
,
)
{
return
(
this
->
(
_STD move(const_cast<key_type&>(_Val.first)),
::
std
::
(
const_cast
<
&>(
.first)),
_STD move(_Val.second)));
}
template
<
class
>
(
,
,
)
{
=
this
->
().
;
if
(!
->
)
{
typename
<
,
>::
;
=
(
->
,
,
_Is_set
);
_Pnode
->
=
;
_Pnode
->
=
->
;
if
(
_Newroot
->
)
_Newroot
=
_Pnode
;
_Pnode
->
=
(
->
,
_Pnode
,
);
_Pnode
->
=
(
->
,
_Pnode
,
);
(
_Newroot
);
}
return
(
_Newroot
);
}
template
<
class
>
(
const
&
)
const
{
auto
&
=
this
->
();
=
_My_data
.
();
=
_My_data
.
;
=
_My_data
.
;
while
(!
_Pnode
->
)
{
if (_DEBUG_LT_PRED(this->_Getcomp(), this->_Key(_Pnode), _Keyval))
if
(
(
this
->
(),
this
->
(
_Pnode
),
))
{
_Pnode
=
_Pnode
->
;
}
else
{
if
(
_Hinode
->
&& _DEBUG_LT_PRED(this->_Getcomp(), _Keyval,
this->_Key(_Pnode)))
&&
(
this
->
(),
,
this
->
(
_Pnode
)))
{
_Hinode
=
_Pnode
;
}
_Lonode
=
_Pnode
;
_Pnode
=
_Pnode
->
;
}
}
_Pnode
=
_Hinode
->
?
_My_data
.
() :
_Hinode
->
;
while
(!
_Pnode
->
)
{
if (_DEBUG_LT_PRED(this->_Getcomp(), _Keyval, this->_Key(_Pnode)))
if
(
(
this
->
(),
,
this
->
(
_Pnode
)))
{
_Hinode
=
_Pnode
;
_Pnode
=
_Pnode
->
;
}
else
{
_Pnode
=
_Pnode
->
;
}
}
const_iterator _First = const_iterator(_Lonode, _STD addressof(_My_data));
=
(
_Lonode
, ::
std
::
(
_My_data
));
const_iterator _Last = const_iterator(_Hinode, _STD addressof(_My_data));
=
(
_Hinode
, ::
std
::
(
_My_data
));
return
(
(
_First
,
_Last
));
}
template
<
class
>
(
const
&
)
{
(
static_cast
<
const
*>(
this
)->
(
));
const auto _My_addr = _STD addressof(this->_Get_data());
const
auto
= ::
std
::
(
this
->
());
=
(
_Ans
.
.
,
_My_addr
);
=
(
_Ans
.
.
,
_My_addr
);
return
(
(
_First
,
_Last
));
}
void
(
)
{
for
(
=
; !
_Pnode
->
;
=
_Pnode
)
{
(
_Pnode
->
);
_Pnode
=
_Pnode
->
;
&
=
this
->
();
_Alnode_traits::destroy(_Al, _STD addressof(_Rootnode->_Myval));
::
(
_Al
,
);
}
}
bool
(
const
&
,
const
&
)
const
{
return (_DEBUG_LT_PRED(this->_Getcomp(), _Left, _Right));
}
template
<
class
,
class
>
bool
(
const
&
,
const
&
)
const
{
return
(
this
->
()(
,
));
}
template
<
class
>
(
const
&
)
const
{
=
this
->
().
;
=
_Wherenode
->
;
while
(!
_Pnode
->
)
{
if
(
(
this
->
(
_Pnode
),
))
{
_Pnode
=
_Pnode
->
;
}
else
{
_Wherenode
=
_Pnode
;
_Pnode
=
_Pnode
->
;
}
}
return
(
_Wherenode
);
}
template
<
class
>
(
const
&
)
const
{
auto
&
=
this
->
();
=
_My_data
.
();
=
_My_data
.
;
while
(!
_Pnode
->
)
{
if
(
(
,
this
->
(
_Pnode
)))
{
_Wherenode
=
_Pnode
;
_Pnode
=
_Pnode
->
;
}
else
{
_Pnode
=
_Pnode
->
;
}
}
return
(
_Wherenode
);
}
#if _ITERATOR_DEBUG_LEVEL == 2
void
(
)
{
_Lockit _Lock(_LOCK_DEBUG);
**
= (
**)
this
->
();
if
(
_Pnext
!=
nullptr
)
{
while
(*
_Pnext
!=
nullptr
)
{
if
((*
_Pnext
)->
this
->
().
|| (
!=
nullptr
&& (*
_Pnext
)->
!=
))
{
_Pnext
= (
**)(*
_Pnext
)->
();
}
else
{
(*
_Pnext
)->
();
*
_Pnext
= *(
**)(*
_Pnext
)->
();
}
}
}
}
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
void
()
{
(
(),
());
}
const
&
(
const
&
)
const
{
return
(
::_Kfn(
));
}
const
&
(
)
const
{
return
(
this
->
(
->
));
}
#if _HAS_CXX17
public:
using node_type = typename _Traits::node_type;
node_type extract(const const_iterator _Where)
{ // extract the node denoted by _Where
const auto _Ptr = this->_Get_data()._Extract(_Where);
#if _ITERATOR_DEBUG_LEVEL == 2
_Orphan_ptr(_Ptr);
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
return (node_type::_Make(_Ptr, this->_Getal()));
}
node_type extract(const key_type& _Keyval)
{ // extract the first node whose key matches _Keyval
const const_iterator _Where = find(_Keyval);
if (_Where == end())
{
return (node_type{});
}
return (extract(_Where));
}
auto insert(node_type&& _Handle)
{ // insert the node (if any) held in _Handle
#if 1 /* TRANSITION, if constexpr */
return (_Insert_node(bool_constant<_Multi>{}, _STD move(_Handle)));
#else /* TRANSITION, if constexpr */
if (_Handle.empty())
{
if constexpr (_Multi)
{
return (end());
}
else
{
return (_Insert_return_type<iterator, node_type>{end(), false, {}});
}
}
_Check_node_allocator(_Handle);
const auto _Result = _Insert_nohint(
false, _Handle._Getptr()->_Myval, _STD addressof(_Handle));
if constexpr (_Multi)
{
return (_Result.first);
}
else
{
return _Insert_return_type<iterator, node_type>{
_Result.first, _Result.second, _STD move(_Handle)};
}
#endif /* TRANSITION, if constexpr */
}
iterator insert(const const_iterator _Hint, node_type&& _Handle)
{ // insert the node held in _Handle (if any), with hint
if (_Handle.empty())
{
return (end());
}
_Check_node_allocator(_Handle);
return (_Insert_hint(_Hint, _Handle._Getptr()->_Myval, _STD addressof(_Handle)));
}
template<class>
friend class _Tree;
template<class _Other_traits>
void merge(_Tree<_Other_traits>& _That)
{ // transfer all nodes from _That into *this
static_assert(is_same_v<_Nodeptr, typename _Tree<_Other_traits>::_Nodeptr>,
"merge() requires an argument with a compatible node type.");
static_assert(is_same_v<allocator_type, typename _Tree<_Other_traits>::allocator_type>,
"merge() requires an argument with the same allocator type.");
#if 1 /* TRANSITION, if constexpr */
if (_Check_self(_STD addressof(_That)))
{
return;
}
#else /* TRANSITION, if constexpr */
if constexpr (is_same_v<_Tree, _Tree<_Other_traits>>)
{
if (this == _STD addressof(_That))
{
return;
}
}
#endif /* TRANSITION, if constexpr */
#if _ITERATOR_DEBUG_LEVEL == 2
_STL_VERIFY(this->_Getal() == _That._Getal(), "allocator incompatible for merge");
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
_Node_merge_wrapper<_Other_traits> _Wrapper{_That, {}};
auto _First = _That.begin();
const auto _Last = _That.end();
while (_First != _Last)
{
_Wrapper._Where = _First;
++_First;
const auto _Result = _Insert_nohint(false, *_Wrapper._Where, _STD addressof(_Wrapper));
if (_Result.second)
{ // Reparent iterators for the merged node.
_Reparent_ptr(_Wrapper._Where._Ptr, _That);
}
}
}
protected:
_Nodeptr _Buy_if_not_node(node_type * const _Node_handle, _Any_tag)
{ // Extract node from node handle
const auto _Ptr = _Node_handle->_Release();
const auto _Head = this->_Get_data()._Myhead;
_Ptr->_Left = _Head;
_Ptr->_Right = _Head;
return (_Ptr);
}
void _Destroy_if_node(node_type *)
{ // Handle retains ownership of node
}
template<class _Other_traits>
struct _Node_merge_wrapper
{
_Tree<_Other_traits>& _That;
typename _Tree<_Other_traits>::iterator _Where;
};
template<class _Other_traits>
auto _Buy_if_not_node(_Node_merge_wrapper<_Other_traits> * const _Wrapper, _Any_tag)
{ // transition the denoted node into this container
const auto _Ptr = _Wrapper->_That._Get_data()._Extract(_Wrapper->_Where);
const auto _Head = this->_Get_data()._Myhead;
_Ptr->_Left = _Head;
_Ptr->_Right = _Head;
return (_Ptr);
}
template<class _Other_traits>
void _Destroy_if_node(_Node_merge_wrapper<_Other_traits> *)
{ // source container retains ownership of node
}
template<class _Other_traits>
void _Reparent_ptr(const _Nodeptr _Ptr, _Tree<_Other_traits>& _Old_parent)
{ // steal iterators with specified node pointer from _Old_parent
(void)_Ptr; (void)_Old_parent;
#if _ITERATOR_DEBUG_LEVEL == 2
_Lockit _Lock(_LOCK_DEBUG);
auto _Pnext = reinterpret_cast<const_iterator **>(_Old_parent._Getpfirst());
_STL_VERIFY(_Pnext, "source container corrupted");
if (_Ptr == nullptr || _Ptr == _Old_parent._Get_data()._Myhead)
{
return;
}
const auto _My_saved_first = this->_Getpfirst();
const auto _My_saved_proxy = this->_Myproxy();
while (*_Pnext)
{
const auto _Next = reinterpret_cast<const_iterator **>((*_Pnext)->_Getpnext());
if ((*_Pnext)->_Ptr == _Ptr)
{ // reparent the iterator
const_iterator * const _Iter = *_Pnext;
*_Pnext = *_Next;
_Iter->_Myproxy = _My_saved_proxy;
_Iter->_Mynextiter = *_My_saved_first;
*_My_saved_first = _Iter;
}
else
{ // skip the iterator
_Pnext = _Next;
}
}
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
}
void _Check_node_allocator(node_type& _Handle) const
{ // ensure that _Handle and *this have compatible allocators
(void)_Handle;
#if _ITERATOR_DEBUG_LEVEL == 2
_STL_VERIFY(this->_Getal() == _Handle._Getal(), "node handle allocator incompatible for insert");
#endif /* _ITERATOR_DEBUG_LEVEL == 2 */
}
#if 1 /* TRANSITION, if constexpr */
private:
auto _Insert_node(true_type, node_type&& _Handle)
{ // try to insert _Handle, multi(set|map) case
if (_Handle.empty())
{
return (end());
}
_Check_node_allocator(_Handle);
const auto _Result = _Insert_nohint(
false, _Handle._Getptr()->_Myval, _STD addressof(_Handle));
return (_Result.first);
}
auto _Insert_node(false_type, node_type&& _Handle)
{ // try to insert _Handle, (set|map) case
if (_Handle.empty())
{
return (_Insert_return_type<iterator, node_type>{end(), false, {}});
}
_Check_node_allocator(_Handle);
const auto _Result = _Insert_nohint(
false, _Handle._Getptr()->_Myval, _STD addressof(_Handle));
return _Insert_return_type<iterator, node_type>{
_Result.first, _Result.second, _STD move(_Handle)};
}
bool _Check_self(const _Tree * const _That) const
{ // determine if argument points to *this, same-type case
return (this == _That);
}
bool _Check_self(void *) const
{ // determine if argument points to *this, different-type case
return (false);
}
#endif /* TRANSITION, if constexpr */
#endif /* _HAS_CXX17 */
};
template
<
class
>
_NODISCARD inline bool operator==(const _Tree<_Traits>& _Left, const _Tree<_Traits>& _Right)
inline
bool
(
const
<
>&
,
const
<
>&
)
{
return
(
.
()
.
()
&& _STD equal(_Left.begin(), _Left.end(), _Right.begin()));
&& ::
std
::
(
.
(),
.
(),
.
()));
}
template
<
class
>
_NODISCARD inline bool operator!=(const _Tree<_Traits>& _Left, const _Tree<_Traits>& _Right)
inline
bool
(
const
<
>&
,
const
<
>&
)
{
return
(!(
));
}
template
<
class
>
_NODISCARD inline bool operator<(const _Tree<_Traits>& _Left, const _Tree<_Traits>& _Right)
inline
bool
(
const
<
>&
,
const
<
>&
)
{
return (_STD lexicographical_compare(_Left.begin(), _Left.end(),
return
(::
std
::
(
.
(),
.
(),
.
(),
.
()));
}
template
<
class
>
_NODISCARD inline bool operator>(const _Tree<_Traits>& _Left, const _Tree<_Traits>& _Right)
inline
bool
(
const
<
>&
,
const
<
>&
)
{
return
(
);
}
template
<
class
>
_NODISCARD inline bool operator<=(const _Tree<_Traits>& _Left, const _Tree<_Traits>& _Right)
inline
bool
(
const
<
>&
,
const
<
>&
)
{
return
(!(
));
}
template
<
class
>
_NODISCARD inline bool operator>=(const _Tree<_Traits>& _Left, const _Tree<_Traits>& _Right)
inline
bool
(
const
<
>&
,
const
<
>&
)
{
return
(!(
));
}
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _XTREE_ */
#pragma pack(pop)