diff --git a/TinySTL/TinySTL.vcxproj b/TinySTL/TinySTL.vcxproj index 3000608..cfb06b4 100644 --- a/TinySTL/TinySTL.vcxproj +++ b/TinySTL/TinySTL.vcxproj @@ -77,6 +77,7 @@ + @@ -84,6 +85,7 @@ + diff --git a/TinySTL/TinySTL.vcxproj.filters b/TinySTL/TinySTL.vcxproj.filters index c6fe811..12aff99 100644 --- a/TinySTL/TinySTL.vcxproj.filters +++ b/TinySTL/TinySTL.vcxproj.filters @@ -13,11 +13,17 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {092c2875-2b56-404b-977e-a9b4aa67c134} + 源文件 + + 头文件\Profiler + @@ -44,5 +50,8 @@ 头文件 + + 头文件\Profiler + \ No newline at end of file diff --git a/TinySTL/UninitializedFunctions.h b/TinySTL/UninitializedFunctions.h index 4c8149c..c23b834 100644 --- a/TinySTL/UninitializedFunctions.h +++ b/TinySTL/UninitializedFunctions.h @@ -69,22 +69,22 @@ namespace TinySTL{ ForwardIterator _uninitialized_n_fill_aux(ForwardIterator first, Size n, const T& x, _true_type); template - ForwardIterator _uninitialized_n_fill_aux(ForwardIterator first, + ForwardIterator _uninitialized_fill_n_aux(ForwardIterator first, Size n, const T& x, _false_type); template inline ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x){ typedef typename _type_traits::is_POD_type isPODType; - return _uninitialized_n_fill_aux(first, n, x, isPODType()); + return _uninitialized_fill_n_aux(first, n, x, isPODType()); } template - ForwardIterator _uninitialized_n_fill_aux(ForwardIterator first, + ForwardIterator _uninitialized_fill_n_aux(ForwardIterator first, Size n, const T& x, _true_type){ return fill_n(first, n, x); } template - ForwardIterator _uninitialized_n_fill_aux(ForwardIterator first, + ForwardIterator _uninitialized_fill_n_aux(ForwardIterator first, Size n, const T& x, _false_type){ int i = 0; for (; i != n; ++i){ diff --git a/TinySTL/Vector.h b/TinySTL/Vector.h index aa1eb59..5c305fb 100644 --- a/TinySTL/Vector.h +++ b/TinySTL/Vector.h @@ -162,7 +162,7 @@ namespace TinySTL{ template void allocateAndCopy(InputIterator first, InputIterator last){ start_ = dataAllocator::allocate(last - first); - finish_ = uninitialized_copy(first, last, start_); + finish_ = TinySTL::uninitialized_copy(first, last, start_); endOfStorage_ = finish_; } @@ -171,13 +171,13 @@ namespace TinySTL{ allocateAndCopy(first, last); } template - void vector_aux(Integer n, Integer value, std::true_type){ + void vector_aux(Integer n, const value_type& value, std::true_type){ allocateAndFillN(n, value); } template void insert_aux(iterator position, InputIterator first, InputIterator last, std::false_type); template - void insert_aux(iterator position, Integer n, Integer value, std::true_type); + void insert_aux(iterator position, Integer n, const value_type& value, std::true_type); template void reallocateAndCopy(iterator position, InputIterator first, InputIterator last); void reallocateAndFillN(iterator position, const size_type& n, const value_type& val); @@ -247,9 +247,9 @@ namespace TinySTL{ T *newStart = dataAllocator::allocate(newCapacity); T *newEndOfStorage = newStart + newCapacity; - T *newFinish = uninitialized_copy(begin(), position, newStart); - newFinish = uninitialized_copy(first, last, newFinish); - newFinish = uninitialized_copy(position, end(), newFinish); + T *newFinish = TinySTL::uninitialized_copy(begin(), position, newStart); + newFinish = TinySTL::uninitialized_copy(first, last, newFinish); + newFinish = TinySTL::uninitialized_copy(position, end(), newFinish); destroyAndDeallocateAll(); start_ = newStart; @@ -262,9 +262,9 @@ namespace TinySTL{ T *newStart = dataAllocator::allocate(newCapacity); T *newEndOfStorage = newStart + newCapacity; - T *newFinish = uninitialized_copy(begin(), position, newStart); - newFinish = uninitialized_fill_n(newFinish, n, val); - newFinish = uninitialized_copy(position, end(), newFinish); + T *newFinish = TinySTL::uninitialized_copy(begin(), position, newStart); + newFinish = TinySTL::uninitialized_fill_n(newFinish, n, val); + newFinish = TinySTL::uninitialized_copy(position, end(), newFinish); destroyAndDeallocateAll(); start_ = newStart; @@ -285,7 +285,7 @@ namespace TinySTL{ for (; tempPtr - position >= 0; --tempPtr){//move the [position, finish_) back *(tempPtr + locationNeed) = *tempPtr; } - uninitialized_copy(first, last, position); + TinySTL::uninitialized_copy(first, last, position); finish_ += locationNeed; }else{ reallocateAndCopy(position, first, last); @@ -293,7 +293,7 @@ namespace TinySTL{ } template template - void vector::insert_aux(iterator position, Integer n, Integer value, std::true_type){ + void vector::insert_aux(iterator position, Integer n, const value_type& value, std::true_type){ assert(n != 0); difference_type locationLeft = endOfStorage_ - finish_; // the size of left storage difference_type locationNeed = n; @@ -303,7 +303,7 @@ namespace TinySTL{ for (; tempPtr - position >= 0; --tempPtr){//move the [position, finish_) back *(tempPtr + locationNeed) = *tempPtr; } - uninitialized_fill_n(position, n, value); + TinySTL::uninitialized_fill_n(position, n, value); finish_ += locationNeed; } else{ @@ -317,7 +317,7 @@ namespace TinySTL{ } template void vector::insert(iterator position, const size_type& n, const value_type& val){ - insert_aux(position, n, val, typename std::is_integral::type()); + insert_aux(position, n, val, typename std::is_integral::type()); } template typename vector::iterator vector::insert(iterator position, const value_type& val){ diff --git a/TinySTL/main.cpp b/TinySTL/main.cpp index fbb7869..f1c8d65 100644 --- a/TinySTL/main.cpp +++ b/TinySTL/main.cpp @@ -15,16 +15,16 @@ using namespace TinySTL::Profiler; int main(){ - int array[100000] = { 1 }; - std::vector vec; - //TinySTL::vector vec; + //std::vector vec; + //TinySTL::vector vec; + TinySTL::vector vec; ProfilerInstance::start(); int i = 0; - for (; i != 10000000; ++i){ - //vec.insert(vec.end(), array, array + 1); + for (; i != 10000; ++i){ + //vec.push_back(std::string("zouxiaohang")); vec.push_back(i); } - //vec.insert(vec.end(), array, array + 100000); + //for (auto i : vec){ cout << i << endl; } ProfilerInstance::finish(); ProfilerInstance::dumpDuringTime(); system("pause");