FMath/FMArray.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2006 Feeling Software Inc.
00003     MIT License: http://www.opensource.org/licenses/mit-license.php
00004 */
00005 
00020 #ifndef _FM_ARRAY_H_
00021 #define _FM_ARRAY_H_
00022 
00023 template <class T>
00024 class FCOLLADA_EXPORT vector : public std::vector<T>
00025 {
00026 public:
00028     vector() : std::vector<T>() {}
00029 
00032     vector(size_t size) : std::vector<T>(size) {}
00033 
00037     vector(size_t size, const T& defaultValue) : std::vector<T>(size, defaultValue) {}
00038 
00041     vector(const std::vector& copy) : std::vector<T>(copy) {}
00042 
00046     vector(const T* values, size_t count) : std::vector<T>()
00047     {
00048         resize(count);
00049         memcpy(&at(0), values, count * sizeof(T));
00050     }
00051 
00056     template <typename _T>
00057     inline iterator find(const _T& value) { return std::find(begin(), end(), value); }
00058     template <typename _T>
00059     inline const_iterator find(const _T& value) const { return std::find(begin(), end(), value); } 
00063     inline void erase(iterator it) { std::vector<T>::erase(it); }
00064 
00067     inline void erase(iterator first, iterator last) { std::vector<T>::erase(first, last); }
00068 
00072     inline bool erase(const T& value) { iterator it = find(value); if (it != end()) { erase(it); return true; } return false; }
00073 
00076     inline void erase(size_t index) { erase(begin() + index); }
00077 
00083     inline bool release(const T& value) { iterator it = find(value); if (it != end()) { erase(it); delete value; return true; } return false; }
00084 
00087     inline bool contains(const T& value) const { const_iterator it = find(value); return it != end(); }
00088 };
00089 
00095 template <typename T>
00096 inline bool IsEquivalent(const vector<T>& dl, const T* cl, size_t count)
00097 {
00098     if (dl.size() != count) return false;
00099     bool equivalent = true;
00100     for (size_t i = 0; i < count && equivalent; ++i) equivalent = IsEquivalent(dl.at(i), cl[i]);
00101     return equivalent;
00102 }
00103 
00104 #endif // _FM_ARRAY_H_

Generated on Fri May 12 16:44:39 2006 for FCollada by  doxygen 1.4.6-NO