Пример #1
0
        static int _m_BinarySearch(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                System.Collections.Generic.List <string> gen_to_be_invoked = (System.Collections.Generic.List <string>)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING))
                {
                    string _item = LuaAPI.lua_tostring(L, 2);

                    int gen_ret = gen_to_be_invoked.BinarySearch(_item);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <System.Collections.Generic.IComparer <string> >(L, 3))
                {
                    string _item = LuaAPI.lua_tostring(L, 2);
                    System.Collections.Generic.IComparer <string> _comparer = (System.Collections.Generic.IComparer <string>)translator.GetObject(L, 3, typeof(System.Collections.Generic.IComparer <string>));

                    int gen_ret = gen_to_be_invoked.BinarySearch(_item, _comparer);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TSTRING) && translator.Assignable <System.Collections.Generic.IComparer <string> >(L, 5))
                {
                    int    _index = LuaAPI.xlua_tointeger(L, 2);
                    int    _count = LuaAPI.xlua_tointeger(L, 3);
                    string _item  = LuaAPI.lua_tostring(L, 4);
                    System.Collections.Generic.IComparer <string> _comparer = (System.Collections.Generic.IComparer <string>)translator.GetObject(L, 5, typeof(System.Collections.Generic.IComparer <string>));

                    int gen_ret = gen_to_be_invoked.BinarySearch(_index, _count, _item, _comparer);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to System.Collections.Generic.List<string>.BinarySearch!"));
        }
        static int _m_BinarySearch(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                System.Collections.Generic.List <int> __cl_gen_to_be_invoked = (System.Collections.Generic.List <int>)translator.FastGetCSObj(L, 1);


                int __gen_param_count = LuaAPI.lua_gettop(L);

                if (__gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2))
                {
                    int item = LuaAPI.xlua_tointeger(L, 2);

                    int __cl_gen_ret = __cl_gen_to_be_invoked.BinarySearch(item);
                    LuaAPI.xlua_pushinteger(L, __cl_gen_ret);



                    return(1);
                }
                if (__gen_param_count == 3 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && translator.Assignable <System.Collections.Generic.IComparer <int> >(L, 3))
                {
                    int item = LuaAPI.xlua_tointeger(L, 2);
                    System.Collections.Generic.IComparer <int> comparer = (System.Collections.Generic.IComparer <int>)translator.GetObject(L, 3, typeof(System.Collections.Generic.IComparer <int>));

                    int __cl_gen_ret = __cl_gen_to_be_invoked.BinarySearch(item, comparer);
                    LuaAPI.xlua_pushinteger(L, __cl_gen_ret);



                    return(1);
                }
                if (__gen_param_count == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4) && translator.Assignable <System.Collections.Generic.IComparer <int> >(L, 5))
                {
                    int index = LuaAPI.xlua_tointeger(L, 2);
                    int count = LuaAPI.xlua_tointeger(L, 3);
                    int item  = LuaAPI.xlua_tointeger(L, 4);
                    System.Collections.Generic.IComparer <int> comparer = (System.Collections.Generic.IComparer <int>)translator.GetObject(L, 5, typeof(System.Collections.Generic.IComparer <int>));

                    int __cl_gen_ret = __cl_gen_to_be_invoked.BinarySearch(index, count, item, comparer);
                    LuaAPI.xlua_pushinteger(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to System.Collections.Generic.List<int>.BinarySearch!"));
        }
Пример #3
0
 static public int BinarySearch(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             System.Collections.Generic.List <WWWRequest> self = (System.Collections.Generic.List <WWWRequest>)checkSelf(l);
             WWWRequest a1;
             checkType(l, 2, out a1);
             var ret = self.BinarySearch(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 3)
         {
             System.Collections.Generic.List <WWWRequest> self = (System.Collections.Generic.List <WWWRequest>)checkSelf(l);
             WWWRequest a1;
             checkType(l, 2, out a1);
             System.Collections.Generic.IComparer <WWWRequest> a2;
             checkType(l, 3, out a2);
             var ret = self.BinarySearch(a1, a2);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (argc == 5)
         {
             System.Collections.Generic.List <WWWRequest> self = (System.Collections.Generic.List <WWWRequest>)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             WWWRequest a3;
             checkType(l, 4, out a3);
             System.Collections.Generic.IComparer <WWWRequest> a4;
             checkType(l, 5, out a4);
             var ret = self.BinarySearch(a1, a2, a3, a4);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function BinarySearch to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #4
0
 public int ReisenBinarySearch(Reise r)
 {
     return(dieReisen.BinarySearch(r));
 }
Пример #5
0
 public override bool IsReservedWord(string word)
 {
     return(reservedsWords.BinarySearch(word) >= 0);
 }
Пример #6
0
 public int BinarySearch(T item)
 {
     return(list.BinarySearch(item));
 }
Пример #7
0
    static void slist(string filename)
    {
        System.Collections.Generic.List <string> slist = new System.Collections.Generic.List <string>();
        System.Random r = new System.Random();
        System.Collections.Generic.List <string> lines = new System.Collections.Generic.List <string>();
        long ts, tt;

        {
            System.IO.FileStream   fs = new System.IO.FileStream(filename, System.IO.FileMode.Open);
            System.IO.StreamReader sr = new System.IO.StreamReader(fs);
            string line;

            ts = System.DateTime.Now.Ticks;
            while ((line = sr.ReadLine()) != null)
            {
                slist.Add(line); lines.Add(line);
            }
            tt = System.DateTime.Now.Ticks - ts;
            { System.Console.WriteLine(new System.TimeSpan(tt)); }

            sr.Close();
            sr.Dispose();
        }

        slist.Sort();
        long total = System.GC.GetTotalMemory(false);

        System.Console.WriteLine("used memory: {0}", total);

        tt = 0;
        for (int i = 0; i < 500; ++i)
        {
            int idx = r.Next(lines.Count);

            ts = System.DateTime.Now.Ticks;
            slist.Remove(lines[idx]);
            tt += System.DateTime.Now.Ticks - ts;
        }
        {
            System.Console.WriteLine("slist total R: {0}", new System.TimeSpan(tt));
            System.Console.WriteLine("slist avg R: {0}", new System.TimeSpan((tt / 500)));
        }

        tt = 0;
        for (int i = 0; i < 500; ++i)
        {
            int idx = r.Next(lines.Count);

            ts = System.DateTime.Now.Ticks;
            int slist_idx = slist.BinarySearch(lines[idx]);

            if (slist_idx < 0)
            {
                slist_idx = ~slist_idx;
            }
            slist.Insert(slist_idx, lines[idx]);
            tt += System.DateTime.Now.Ticks - ts;
        }
        {
            System.Console.WriteLine("slist total I: {0}", new System.TimeSpan(tt));
            System.Console.WriteLine("slist avg I: {0}", new System.TimeSpan((tt / 500)));
        }

        r     = null;
        slist = null;
        lines = null;
        System.GC.Collect();
    }