提交 4c322450 编写于 作者: 邹晓航

添加容器迭代器的类型萃取

上级 db81d84b
......@@ -2,6 +2,7 @@
#define _AVL_TREE_H_
#include "Allocator.h"
#include "Iterator.h"
#include "Stack.h"
#include "String.h"
......@@ -83,12 +84,13 @@ namespace TinySTL{
namespace Detail{
//class of avl tree iterator
template<class T>//T = node
class avl_iter{
class avl_iter :
public iterator<forward_iterator_tag, typename avl_tree<typename T::value_type>::value_type>{
private:
template<class T>
friend class avl_tree;
private:
typedef typename avl_tree<typename T::value_type>::value_type value_type;
//typedef typename avl_tree<typename T::value_type>::value_type value_type;
typedef typename avl_tree<typename T::value_type>::const_reference const_reference;
typedef typename const T::value_type *const_pointer;
typedef const avl_tree<typename T::value_type> * cntrPtr;
......
......@@ -2,6 +2,7 @@
#define _BINARY_SEARCH_TREE_H_
#include "Allocator.h"
#include "Iterator.h"
#include "Queue.h"
#include "Stack.h"
#include "String.h"
......@@ -80,12 +81,13 @@ namespace TinySTL{
namespace Detail{
//class of bst iterator
template<class T>//T = node
class bst_iter{
class bst_iter :
public iterator<forward_iterator_tag, typename ::TinySTL::binary_search_tree<typename T::value_type>::value_type>{
private:
template<class T>
friend class ::TinySTL::binary_search_tree;
private:
typedef typename ::TinySTL::binary_search_tree<typename T::value_type>::value_type value_type;
//typedef typename ::TinySTL::binary_search_tree<typename T::value_type>::value_type value_type;
typedef typename ::TinySTL::binary_search_tree<typename T::value_type>::const_reference const_reference;
typedef typename const T::value_type *const_pointer;
typedef const ::TinySTL::binary_search_tree<typename T::value_type> * cntrPtr;
......
......@@ -27,7 +27,7 @@ namespace TinySTL{
};
//the class of list iterator
template<class T>
struct listIterator :public bidirectional_iterator<T, ptrdiff_t>{
struct listIterator :public iterator<bidirectional_iterator_tag, T>{
template<class T>
friend class list;
public:
......
......@@ -54,7 +54,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
......@@ -69,7 +69,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
......@@ -84,6 +84,7 @@
<ClCompile Include="main.cpp" />
<ClCompile Include="Profiler\Profiler.cpp" />
<ClCompile Include="Test\AlgorithmTest.cpp" />
<ClCompile Include="Test\AVLTreeTest.cpp" />
<ClCompile Include="Test\BinarySearchTreeTest.cpp" />
<ClCompile Include="Test\BitmapTest.cpp" />
<ClCompile Include="Test\CircularBufferTest.cpp" />
......@@ -95,6 +96,7 @@
<ClCompile Include="Test\StackTest.cpp" />
<ClCompile Include="Test\StringTest.cpp" />
<ClCompile Include="Test\SuffixArrayTest.cpp" />
<ClCompile Include="Test\Unordered_setTest.cpp" />
<ClCompile Include="Test\VectorTest.cpp" />
</ItemGroup>
<ItemGroup>
......@@ -107,11 +109,13 @@
<ClInclude Include="CircularBuffer.h" />
<ClInclude Include="Construct.h" />
<ClInclude Include="Deque.h" />
<ClInclude Include="Detail\AVLTree.impl.h" />
<ClInclude Include="Detail\BinarySearchTree.impl.h" />
<ClInclude Include="Detail\Bitmap.impl.h" />
<ClInclude Include="Detail\CircularBuffer.impl.h" />
<ClInclude Include="Detail\Deque.impl.h" />
<ClInclude Include="Detail\List.impl.h" />
<ClInclude Include="Detail\Unordered_set.impl.h" />
<ClInclude Include="Detail\Vector.impl.h" />
<ClInclude Include="Functional.h" />
<ClInclude Include="Iterator.h" />
......@@ -123,6 +127,7 @@
<ClInclude Include="String.h" />
<ClInclude Include="SuffixArray.h" />
<ClInclude Include="Test\AlgorithmTest.h" />
<ClInclude Include="Test\AVLTreeTest.h" />
<ClInclude Include="Test\BinarySearchTreeTest.h" />
<ClInclude Include="Test\BitmapTest.h" />
<ClInclude Include="Test\CircularBufferTest.h" />
......@@ -135,9 +140,11 @@
<ClInclude Include="Test\StringTest.h" />
<ClInclude Include="Test\SuffixArrayTest.h" />
<ClInclude Include="Test\TestUtil.h" />
<ClInclude Include="Test\Unordered_setTest.h" />
<ClInclude Include="Test\VectorTest.h" />
<ClInclude Include="TypeTraits.h" />
<ClInclude Include="UninitializedFunctions.h" />
<ClInclude Include="Unordered_set.h" />
<ClInclude Include="Utility.h" />
<ClInclude Include="Vector.h" />
</ItemGroup>
......
......@@ -78,6 +78,12 @@
<ClCompile Include="Test\BinarySearchTreeTest.cpp">
<Filter>Test</Filter>
</ClCompile>
<ClCompile Include="Test\AVLTreeTest.cpp">
<Filter>Test</Filter>
</ClCompile>
<ClCompile Include="Test\Unordered_setTest.cpp">
<Filter>Test</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="TypeTraits.h">
......@@ -206,6 +212,21 @@
<ClInclude Include="Detail\BinarySearchTree.impl.h">
<Filter>Detail</Filter>
</ClInclude>
<ClInclude Include="Test\AVLTreeTest.h">
<Filter>Test</Filter>
</ClInclude>
<ClInclude Include="Detail\AVLTree.impl.h">
<Filter>Detail</Filter>
</ClInclude>
<ClInclude Include="Unordered_set.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Detail\Unordered_set.impl.h">
<Filter>Detail</Filter>
</ClInclude>
<ClInclude Include="Test\Unordered_setTest.h">
<Filter>Test</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\README.md" />
......
......@@ -4,6 +4,7 @@
#include "Allocator.h"
#include "Algorithm.h"
#include "Functional.h"
#include "Iterator.h"
#include "List.h"
#include "Vector.h"
......@@ -13,7 +14,7 @@ namespace TinySTL{
namespace Detail{
template<class Key, class ListIterator, class Hash = std::hash<Key>,
class KeyEqual = TinySTL::equal_to<Key>, class Allocator = TinySTL::allocator < Key >>
class ust_iterator{
class ust_iterator : public iterator<forward_iterator_tag, Key>{
private:
template<class Key, class Hash, class KeyEqual, class Allocator>
friend class Unordered_set;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册