protected override void Awake() { base.Awake(); tagHeapManager_ = new HeapManager <TagText>(); tagHeapManager_.Initialize(1, TagTextPrefab); tree_ = GetComponent <Tree>(); tree_.Initialize(this, new ActionManagerProxy(actionManager_), heapManager_, tagHeapManager_); tree_.OnEdited += this.OnEdited; tree_.OnDoneChanged += this.OnDoneChanged; }
internal ProcessContext(Process process) { _apiSetMap = new ApiSetMap(); _moduleCache = new ConcurrentDictionary <string, Module>(StringComparer.OrdinalIgnoreCase); _symbolHandler = new SymbolHandler(process.GetArchitecture()); Architecture = process.GetArchitecture(); HeapManager = new HeapManager(this, process); Process = process; }
static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); var heapManager = new HeapManager(n); for (int i = 0; i < n; i++) { int aItem = Convert.ToInt32(Console.ReadLine()); heapManager.Add(aItem); var median = heapManager.GetMedian(); Console.WriteLine(median.ToString("F01")); } }
void Initialize() { tagTextHeapManager_ = new HeapManager <TagText>(); tagTextHeapManager_.Initialize(3, TagTextPrefab); rect_ = GetComponent <RectTransform>(); }
static void TestSimulationHeap() { List <HeapType> testMetadata = new List <HeapType>() { new HeapType("Unit", new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("HitPoints", "short"), new KeyValuePair <string, string>("TestArray", "int*"), new KeyValuePair <string, string>("TestPtrArray", "Building**"), new KeyValuePair <string, string>("TestPtr", "Building*"), }), new HeapType("Building", new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("HitPoints", "short"), new KeyValuePair <string, string>("BuildStatus", "short"), }), }; IHeapManagerInternals heapMgr = new HeapManager(testMetadata); IHeapType unitType = heapMgr.GetHeapType("Unit"); int UNIT_HP_IDX = unitType.GetFieldIdx("HitPoints"); short UNIT_HP_TID = unitType.GetFieldTypeID("HitPoints"); int UNIT_TESTARRAY_IDX = unitType.GetFieldIdx("TestArray"); short UNIT_TESTARRAY_TID = unitType.GetFieldTypeID("TestArray"); int UNIT_TESTPTRARRAY_IDX = unitType.GetFieldIdx("TestPtrArray"); short UNIT_TESTPTRARRAY_TID = unitType.GetFieldTypeID("TestPtrArray"); int UNIT_TESTPTR_IDX = unitType.GetFieldIdx("TestPtr"); short UNIT_TESTPTR_TID = unitType.GetFieldTypeID("TestPtr"); IHeapType buildingType = heapMgr.GetHeapType("Building"); int BUILDING_HP_IDX = buildingType.GetFieldIdx("HitPoints"); short BUILDING_HP_TID = buildingType.GetFieldTypeID("HitPoints"); int BUILDING_BUILDSTATUS_IDX = buildingType.GetFieldIdx("BuildStatus"); short BUILDING_BUILDSTATUS_TID = buildingType.GetFieldTypeID("BuildStatus"); Stopwatch watch = new Stopwatch(); watch.Start(); for (int j = 0; j < 100000; j++) { IHeapConnector unit = heapMgr.New(unitType.ID); IHeapConnector building0 = heapMgr.New(buildingType.ID); IHeapConnector building1 = heapMgr.New(buildingType.ID); ((IValueWrite <short>)building0.AccessField(BUILDING_HP_IDX)).Write(100); ((IValueWrite <short>)building0.AccessField(BUILDING_BUILDSTATUS_IDX)).Write(50); ((IValueWrite <short>)building1.AccessField(BUILDING_HP_IDX)).Write(50); ((IValueWrite <short>)building1.AccessField(BUILDING_BUILDSTATUS_IDX)).Write(100); ((IValueWrite <short>)unit.AccessField(UNIT_HP_IDX)).Write(88); unit.AccessField(UNIT_TESTPTR_IDX).PointTo(building0); unit.AccessField(UNIT_TESTARRAY_IDX).PointTo(heapMgr.NewArray(heapMgr.GetHeapType("int").ID, 5)); for (int i = 0; i < 5; ++i) { ((IValueWrite <int>)unit.AccessField(UNIT_TESTARRAY_IDX).Dereference().AccessArrayItem(i)).Write(i); } unit.AccessField(UNIT_TESTPTRARRAY_IDX).PointTo(heapMgr.NewArray(heapMgr.GetHeapType("Building*").ID, 5)); unit.AccessField(UNIT_TESTPTRARRAY_IDX).Dereference().AccessArrayItem(0).PointTo(building0); unit.AccessField(UNIT_TESTPTRARRAY_IDX).Dereference().AccessArrayItem(1).PointTo(building1); unit.AccessField(UNIT_TESTARRAY_IDX).Dereference().DeleteArray(); unit.AccessField(UNIT_TESTPTRARRAY_IDX).Dereference().DeleteArray(); unit.Delete(); building0.Delete(); building1.Delete(); } watch.Stop(); // TODO: test heap saving/loading }
public static bool StressTest() { HeapManager heapMgr = new HeapManager(testMetadata); heapMgr.CreateHeap(); GetIDs(heapMgr); Stopwatch watch = new Stopwatch(); watch.Start(); IHeapConnector prevObj = null; IHeapConnector[] allObjects = new IHeapConnector[100]; for (int i = 0; i < 100; i++) { IHeapConnector currObj = CreateTestObj(heapMgr); allObjects[i] = currObj; if (prevObj != null) { prevObj.AccessField(TESTTYPE_NEXT_IDX).PointTo(currObj); } prevObj = currObj; } //byte[] savedHeap = heapMgr.UnloadHeap(new List<IHeapConnector>() { allObjects[0] }); //List<IHeapConnector> savedRefs = heapMgr.LoadHeap(savedHeap); //if (savedRefs.Count != 1) { throw new Exception("Load error!"); } //IHeapConnector curr = savedRefs[0]; //int objIdx = 0; //do //{ // allObjects[objIdx] = curr; // objIdx++; // CheckTestObj(curr); // curr = curr.AccessField(TESTTYPE_NEXT_IDX).Dereference(); //} while (curr != null); for (int i = 0; i < 50; i++) { DeleteTestObj(allObjects[2 * i + 1]); allObjects[2 * i].AccessField(TESTTYPE_NEXT_IDX).PointTo(i < 49 ? allObjects[2 * i + 2] : null); } for (int i = 0; i < 50; i++) { DeleteTestObj(allObjects[2 * i]); } watch.Stop(); FieldInfo freeSectionsHeadFI = typeof(HeapManager).GetField("freeSectionsHead", BindingFlags.NonPublic | BindingFlags.Instance); HeapSection freeSectionsHead = (HeapSection)freeSectionsHeadFI.GetValue(heapMgr); return(freeSectionsHead.Address == 4 && freeSectionsHead.Length == -1 && freeSectionsHead.Next == null && freeSectionsHead.Prev == null); }