]> granicus.if.org Git - re2c/commitdiff
- Use set instead of list which is the better option & definitively faster
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 25 Oct 2005 20:05:59 +0000 (20:05 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 25 Oct 2005 20:05:59 +0000 (20:05 +0000)
globals.h

index 23365503c40f8eff1478ac81abc8be3f028a0f31..65fc51da3fc5c585a9cff24fc6894989a0defe7f 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -3,28 +3,26 @@
 #define        _globals_h
 
 #include "basics.h"
-#include <list>
+#include <set>
 #include <algorithm>
 
 template<typename _Ty>
-class label_list: protected std::list<_Ty>
+class label_list: protected std::set<_Ty>
 {
 public:
        label_list()
-               : std::list<_Ty>()
+               : std::set<_Ty>()
        {
        }
        
        void append(const _Ty &val)
        {
-               push_back(val);
-               std::list<_Ty>::sort();
-               std::list<_Ty>::unique();
+               std::set<_Ty>::insert(val);
        }
        
        bool contains(const _Ty &val)
        {
-               return std::find(std::list<_Ty>::begin(), std::list<_Ty>::end(), val) != std::list<_Ty>::end();
+               return find(val) != std::set<_Ty>::end();
        }
 };