From 3af17fab9a593e402b17db54ae44dead77ef3fd8 Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 4 Jul 2008 00:31:54 +0000 Subject: [PATCH] added initializer and passed the init value as const reference --- vcg/container/simple_temporary_data.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vcg/container/simple_temporary_data.h b/vcg/container/simple_temporary_data.h index fdc435ac..18ec0c9d 100644 --- a/vcg/container/simple_temporary_data.h +++ b/vcg/container/simple_temporary_data.h @@ -73,15 +73,17 @@ STL_CONT& c; std::vector data; SimpleTempData(STL_CONT &_c):c(_c){data.reserve(c.capacity());data.resize(c.size());}; -SimpleTempData(STL_CONT &_c,ATTR_TYPE val):c(_c){ +SimpleTempData(STL_CONT &_c, const ATTR_TYPE &val):c(_c){ data.reserve(c.capacity());data.resize(c.size()); - typename std::vector::iterator i; - for(i = data.begin(); i!= data.end(); ++i) - *i = val; + Init(val); }; ~SimpleTempData(){data.clear();} +void Init(const ATTR_TYPE &val) +{ + std::fill(data.begin(),data.end(),val); +} // access to data ATTR_TYPE & operator[](const typename STL_CONT::value_type & v){return data[&v-&*c.begin()];} ATTR_TYPE & operator[](const typename STL_CONT::value_type * v){return data[v-&*c.begin()];}