Exemplo n.º 1
0
 public static bool remove(LuaMap map, object key)
 {
     if (key != null)
     {
         return(map.map.Remove(key));
     }
     return(false);
 }
Exemplo n.º 2
0
        public static LuaMap merge(LuaMap map1, LuaMap map2, Func <object, object, LuaResult> func)
        {
            Dictionary <object, object> map = new Dictionary <object, object>(map1.map);

            foreach (KeyValuePair <object, object> entry in map2.map)
            {
                if (func != null)
                {
                    object value;
                    if (map.TryGetValue(entry.Key, out value))
                    {
                        LuaResult res = func(value, entry.Value);
                        map[entry.Key] = res[0];
                        continue;
                    }
                }
                map[entry.Key] = entry.Value;
            }
            return(new LuaMap(map));
        }
Exemplo n.º 3
0
        public static LuaMap diff(LuaMap map1, LuaMap map2)
        {
            Dictionary <object, object> map = new Dictionary <object, object>(map1.map.Count + map2.map.Count);

            foreach (KeyValuePair <object, object> entry in map1.map)
            {
                if (!map2.map.ContainsKey(entry.Key))
                {
                    map[entry.Key] = entry.Value;
                }
            }

            foreach (KeyValuePair <object, object> entry in map2.map)
            {
                if (!map1.map.ContainsKey(entry.Key))
                {
                    map[entry.Key] = entry.Value;
                }
            }
            return(new LuaMap(map));
        }
Exemplo n.º 4
0
        public static LuaMap diff(LuaMap map1, LuaMap map2)
        {
            Dictionary<object, object> map = new Dictionary<object, object>(map1.map.Count + map2.map.Count);

            foreach (KeyValuePair<object, object> entry in map1.map)
            {
                if (!map2.map.ContainsKey(entry.Key))
                {
                    map[entry.Key] = entry.Value;
                }
            }

            foreach (KeyValuePair<object, object> entry in map2.map)
            {
                if (!map1.map.ContainsKey(entry.Key))
                {
                    map[entry.Key] = entry.Value;
                }
            }
            return new LuaMap(map);
        }
Exemplo n.º 5
0
 public static LuaMap clone(LuaMap map)
 {
     return(new LuaMap(new Dictionary <object, object>(map.map)));
 }
Exemplo n.º 6
0
 public static int size(LuaMap map)
 {
     return(map.map.Count);
 }
Exemplo n.º 7
0
        public static Func <object> values(LuaMap map)
        {
            LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());

            return(new Func <object>(iter.NextValue));
        }
Exemplo n.º 8
0
        public static Func <object[]> pairs(LuaMap map)
        {
            LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());

            return(new Func <object[]>(iter.NextPair));
        }
Exemplo n.º 9
0
 public static LuaMap merge(LuaMap map1, LuaMap map2, Func<object, object, LuaResult> func)
 {
     Dictionary<object, object> map = new Dictionary<object, object>(map1.map);
     foreach (KeyValuePair<object, object> entry in map2.map)
     {
         if (func != null)
         {
             object value;
             if (map.TryGetValue(entry.Key, out value))
             {
                 LuaResult res = func(value, entry.Value);
                 map[entry.Key] = res[0];
                 continue;
             }
         }
         map[entry.Key] = entry.Value;
     }
     return new LuaMap(map);
 }
Exemplo n.º 10
0
 public static Func<object> keys(LuaMap map)
 {
     LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());
     return new Func<object>(iter.NextKey);
 }
Exemplo n.º 11
0
 public static LuaMap clone(LuaMap map)
 {
     return new LuaMap(new Dictionary<object,object>(map.map));
 }
Exemplo n.º 12
0
 public static int size(LuaMap map)
 {
     return map.map.Count;
 }
Exemplo n.º 13
0
 public static bool remove(LuaMap map, object key)
 {
     if (key != null)
     {
         return map.map.Remove(key);
     }
     return false;
 }
Exemplo n.º 14
0
 public static Func<object[]> pairs(LuaMap map)
 {
     LuaMapIterator iter = new LuaMapIterator(map.map.GetEnumerator());
     return new Func<object[]>(iter.NextPair);
 }