1 #ifndef __NV50_UNORDERED_SET_H__ 2 #define __NV50_UNORDERED_SET_H__ 3 4 #if (__cplusplus >= 201103L) || defined(ANDROID) 5 #include <unordered_set> 6 #else 7 #include <tr1/unordered_set> 8 #endif 9 10 namespace nv50_ir { 11 12 #if __cplusplus >= 201103L 13 using std::unordered_set; 14 #elif !defined(ANDROID) 15 using std::tr1::unordered_set; 16 #else // Android release before lollipop 17 using std::isfinite; 18 typedef std::tr1::unordered_set<void *> voidptr_unordered_set; 19 20 template <typename V> 21 class unordered_set : public voidptr_unordered_set { 22 public: 23 typedef voidptr_unordered_set _base; 24 typedef _base::iterator _biterator; 25 typedef _base::const_iterator const_biterator; 26 27 class iterator : public _biterator { 28 public: 29 iterator(const _biterator & i) : _biterator(i) {} 30 V operator*() const { return reinterpret_cast<V>(*_biterator(*this)); } 31 }; 32 class const_iterator : public const_biterator { 33 public: 34 const_iterator(const iterator & i) : const_biterator(i) {} 35 const_iterator(const const_biterator & i) : const_biterator(i) {} 36 const V operator*() const { return reinterpret_cast<const V>(*const_biterator(*this)); } 37 }; 38 39 iterator begin() { return _base::begin(); } 40 iterator end() { return _base::end(); } 41 const_iterator begin() const { return _base::begin(); } 42 const_iterator end() const { return _base::end(); } 43 }; 44 #endif 45 46 } // namespace nv50_ir 47 48 #endif // __NV50_UNORDERED_SET_H__ 49