Skip to content

Commit

Permalink
Re #7879. Remove VectorHelper::iteratorToArray methods.
Browse files Browse the repository at this point in the history
Replaced in the one remaining place it was used with standard STL
constructs. Not sure why they weren't used in the first place.
  • Loading branch information
RussellTaylor committed Sep 12, 2013
1 parent 1184fe2 commit d3d758d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 41 deletions.
39 changes: 1 addition & 38 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/VectorHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,44 +131,7 @@ namespace VectorHelper
return out;
}

//-------------------------------------------------------------------------------------
/** Generic method to convert an iterator to an array of type T.
* Data type is converted at the same type.
* @param begin :: iterator at the beginning of the data
* @param end :: iterator at the end of the data
* @param dims_array :: array to hold size of dimensions
* @return :: a pointer to an array of type T.
*/
template< typename T, typename _ForwardIterator >
T * iteratorToArray(_ForwardIterator begin, _ForwardIterator end, int * dims_array)
{
// Create the output array
int num = static_cast<int>(std::distance(begin, end));
dims_array[0] = num;
T * out = new T[num];
std::copy(begin, end, out);
return out;
}

/** Generic method to convert an iterator to an array of type T.
* Data type is converted at the same type.
* @param begin :: iterator at the beginning of the data
* @param end :: iterator at the end of the data
* @param dims_array :: array to hold size of dimensions
* @return :: a pointer to an array of type T.
*/
template< typename T, typename _ForwardIterator >
T * iteratorToArray(_ForwardIterator begin, _ForwardIterator end, size_t * dims_array)
{
// Create the output array
size_t num = std::distance(begin, end);
dims_array[0] = num;
T * out = new T[num];
std::copy(begin, end, out);
return out;
}

//! Functor used for computing the sum of the square values of a vector, using the accumulate algorithm
/// Functor used for computing the sum of the square values of a vector, using the accumulate algorithm
template <class T> struct SumGaussError: public std::binary_function<T,T,T>
{
SumGaussError(){}
Expand Down
5 changes: 2 additions & 3 deletions Code/Mantid/Framework/Nexus/src/NexusFileIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,8 @@ using namespace DataObjects;
// Write out the detector IDs
if (!dets.empty())
{
detid_t * detectorIDs = VectorHelper::iteratorToArray<detid_t>(dets.begin(), dets.end(), dims_array);
NXwritedata("detector_IDs", NX_INT64, 1, dims_array, (void*)(detectorIDs), false );
delete [] detectorIDs;
std::vector<detid_t> detectorIDs(dets.begin(),dets.end());
NXwritedata("detector_IDs", NX_INT64, 1, dims_array, (void*)(detectorIDs.data()), false );
}

std::string eventType("UNKNOWN");
Expand Down

0 comments on commit d3d758d

Please sign in to comment.