public void Init() { totest = new ArrayDict <string, int>(); totest.Add("a", 1); totest.Add("b", 2); //test Add totest.Add("c", 3); Assert.AreEqual(2, totest.Get("b")); //test Get Assert.AreEqual(1, totest.Get("a")); //test Size Assert.AreEqual(3, totest.Size()); //test IsEmpty Assert.AreEqual(false, totest.IsEmpty()); //test Remove Assert.AreEqual(3, totest.Get("c")); totest.Remove("b"); Assert.AreEqual(2, totest.Size()); Assert.AreEqual(3, totest.Get("c")); //test Modify totest.Modify("a", 33); Assert.AreEqual(33, totest.Get("a")); //test ToString Assert.AreEqual("[ a:33, c:3 ]", totest.ToString()); }
public void Init() { e = new VarExpr("g"); dict = new ArrayDict <string, int>(); dict.Add("g", 44); dict.Add("h", 22); Assert.AreEqual(44, e.Eval(dict, heap)); Assert.AreEqual("g", e.ToString()); }
public void Init() { e = new ConstExpr(33); dict = new ArrayDict <string, int>(); dict.Add("g", 44); dict.Add("h", 22); Assert.AreEqual(33, e.Eval(dict, heap)); Assert.AreEqual("33", e.ToString()); }
public void Init() { e = new ArithExpr(new ConstExpr(3), "+", new ConstExpr(4)); dict = new ArrayDict <string, int>(); dict.Add("g", 44); dict.Add("h", 22); Assert.AreEqual(7, e.Eval(dict, heap)); Assert.AreEqual("3 + 4", e.ToString()); }
protected virtual void FillSelectedObjects() { _needFillSelected = false; if (m_currentCreatedRopes == null) { m_currentCreatedRopes = new List <Rope2D>(); } else { m_currentCreatedRopes.Clear(); } if (m_selectedObjects == null) { m_selectedObjects = new ArrayDict <int, GameObject>(); } if (m_windowInformation.PickSelectedObjects) { List <Transform> v_transforms = new List <Transform>(Selection.transforms); for (int i = 0; i < m_selectedObjects.Count; i++) { GameObject v_object = m_selectedObjects[i] != null ? m_selectedObjects[i].Value : null; if (v_object != null && !v_transforms.Contains(v_object.transform)) { m_selectedObjects[i] = null; } } m_selectedObjects.RemoveNulls(); m_selectedObjects.RemovePairsWithNullValues(); foreach (Transform v_transform in v_transforms) { if (v_transform != null) { Rope2D v_rope = v_transform.GetComponent <Rope2D>(); if (v_rope == null) { Camera v_camera = v_transform.GetNonMarkedComponentInChildren <Camera>(); if (v_camera == null && !m_selectedObjects.ContainsValue(v_transform.gameObject)) { m_selectedObjects.Add(0, v_transform.gameObject); } } else { m_currentCreatedRopes.AddChecking(v_rope); } } } RecreateList(true); } }
public static ArrayDict <System.Reflection.Assembly, System.Type[]> GetAssemblyTypesDict(bool p_forceRefresh = false) { if (_assemblyTypesDict == null || p_forceRefresh) { _assemblyTypesDict = new ArrayDict <System.Reflection.Assembly, System.Type[]>(); System.Reflection.Assembly[] v_assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); foreach (System.Reflection.Assembly v_assembly in v_assemblies) { if (v_assembly != null) { #if UNITY_WINRT && !UNITY_EDITOR && !UNITY_WP8 List <System.Type> v_typesList = new List <System.Type>(); foreach (var v_typeInfo in v_assembly.DefinedTypes) { v_typesList.Add(v_typeInfo.GetType()); } System.Type[] v_types = v_typesList.ToArray(); #else System.Type[] v_types = v_assembly.GetTypes(); #endif _assemblyTypesDict.Add(v_assembly, v_types); } } } return(_assemblyTypesDict); }
protected void FillSelectedWithList(IList p_list, bool p_reapplySelection, bool p_acceptNulls = false) { m_selectedObjects = new ArrayDict <int, GameObject>(); List <Object> v_selectedObject = new List <Object>(); if (p_list != null) { for (int i = 0; i < p_list.Count; i++) { KVPair <int, GameObject> v_object = p_list[i] as KVPair <int, GameObject>; if (v_object != null) { if ((v_object.Value != null || p_acceptNulls)) { v_selectedObject.Add(v_object.Value); } m_selectedObjects.Add(v_object); } } foreach (Rope2D v_rope in m_currentCreatedRopes) { if (v_rope != null && v_rope.gameObject != null) { v_selectedObject.Add(v_rope.gameObject); } } if (p_reapplySelection) { Selection.objects = v_selectedObject.ToArray(); } } }
public virtual void RegisterCallback(AudioSerWebReturnTypeEnum p_returnType, FunctionAndParams p_function) { if (p_function != null && (p_function.DelegatePointer != null || (p_function.Target != null && !string.IsNullOrEmpty(p_function.StringFunctionName)))) { ReturnTypePerCallbackDict.Add(p_returnType, p_function); } }
public void Init() { IList <int> ot = new ArrayList <int>(); IDict <string, int> symtbl = new ArrayDict <string, int>(); IDict <int, int> heap = new ArrayDict <int, int>(); IStack <IStmt> stk = new ArrayStack <IStmt>(); IStmt stmt = new PrintStmt(new ArithExpr(new ConstExpr(3), "+", new ConstExpr(4))); ot.Add(11); ot.Add(12); symtbl.Add("bb", 11); symtbl.Add("bc", 12); stk.Push(stmt); prg = new ProgState(ot, symtbl, stk, heap); Assert.AreEqual("[ print( 3 + 4 ) ]", prg.ToStrExe()); Assert.AreEqual("[ 11, 12 ]", prg.ToStrOut()); Assert.AreEqual("[ bb:11, bc:12 ]", prg.ToStrSym()); }
public ProgState execute(ProgState prg) { IStack <IStmt> stk = new ArrayStack <IStmt>(); stk.Push(stm); IDict <string, int> dict = new ArrayDict <string, int>(); int i = 0; List <string> keys = new List <string>(prg.GetSym.GetKeys()); int j = prg.GetSym.Size(); while (i < j) { dict.Add(keys.ElementAt(i), prg.GetSym.Get(keys.ElementAt(i))); i++; } com.IList <int> outer = prg.GetOut; IDict <int, int> heap = prg.GetHeap; ProgState prgg = new ProgState(outer, dict, stk, heap); return(prgg); }