public bool RemoveItem(UIItem uiItem) { if (!m_allocateList.Any(item => item.Key == uiItem.Name)) { LogModule.ErrorLog("Cannot remove item: {0} cause not exist.", uiItem); return(false); } UIItemList.Remove(uiItem); if (m_toRemoveList.Contains(uiItem)) { m_toRemoveList.Remove(uiItem); } for (int i = 0; i < m_allocateList.Count; i++) { if (m_allocateList[i].Key == uiItem.Name) { m_allocateList[i] = new Allocate() { Key = "", Flag = false }; } } return(true); }
public Pool(int size, int initialAllocation, Predicate <T> validateFunc, Allocate allocateFunc) { if (size < 1) { throw new ArgumentException("size must be greater than zero"); } if (initialAllocation < 0 || initialAllocation > size) { throw new ArgumentException("initialAllocation must be non-negative and cannot be larger than size"); } items = new T[size]; validate = validateFunc ?? throw new ArgumentNullException("validateFunc"); InvalidCount = size; allocate = allocateFunc ?? ConstructorAllocate; if (allocate == ConstructorAllocate) { constructor = typeof(T).GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { }, null); if (constructor == null) { throw new InvalidOperationException("No allocateFunc was provided and " + typeof(T) + " does not have a parameterless constructor."); } } AllocationSize = initialAllocation; for (int i = 0; i < initialAllocation; i++) { T obj = allocate(); items[i] = obj ?? throw new InvalidOperationException("The pool's allocate method returned a null object reference."); } }
public ActionResult changePublishState() { Allocate allo = new Allocate(); allo.changePublishState(); return(RedirectToAction("Index")); }
public Pool(int initialSize, Predicate <T> validateFunc, Allocate allocateFunc) { ResizeAmount = DefaultResizeAmount; if (initialSize < 0) { throw new ArgumentOutOfRangeException("initialSize must be non-negative"); } if (validateFunc == null) { throw new ArgumentNullException("validateFunc is null"); } if (initialSize == 0) { initialSize = ResizeAmount; } _items = new T[initialSize]; _validate = validateFunc; AvailableCount = _items.Length; //NOTE: _allocate is no longer assigned a default ConstructorInfo via reflection. This is because on .net CF, reflection for //obtaining private constructors is not allowed. Thus, all pooled objects need to have a public parameterless constructor. //Pro: pool resizing is much faster. //Con: user may accidentally directly instantiate objects via constructor. _allocate = allocateFunc ?? null; ObjectPoolMonitor.Register(this); }
public ActionResult Delete() { Allocate allo = new Allocate(); allo.deleteAllocation(); return(RedirectToAction("Index")); }
public MIPS Visitor(Allocate instance, IFunctionCil function, GenerateToCil cil) { var type = instance.Y as ITypeCil; var modifyHeapPointer = new string[] { $"addi $t1, $t1, {(type.Attributes.Count+2) * 4}", $"sw $t1, heapPointer" //Correr el heapPointer }; var lines = new List <string>() { $"la $t0, heap", //Cargar la direccion del heap $"lw $t1, heapPointer", //Cargar la direccion del heapPointer $"add $t0, $t0, $t1", //Obtener la direccion a escribir $"move $v0, $t0", //Guardarlo para devolverlo $"la $t2, type_{type.Name}_name", //Escribir el nombre $"sw $t2, ($t0)", //Salvarlo $"add $t0, $t0, 4", $"li $t2, {type.Attributes.Count}", //Escribir la cantidad de bytes de los argumentos $"sw $t2, ($t0)" //Salvarlo }; lines.AddRange(modifyHeapPointer); lines.AddRange(Utils.LoadFromRegister(instance.X, function, "v0")); return(new MIPS() { Functions = lines }); }
public ActionResult clearStudentData() { Allocate allo = new Allocate(); allo.clearStudentData(); return(RedirectToAction("Index")); }
public async Task <IActionResult> PutAllocate(int id, Allocate allocate) { if (id != allocate.AllId) { return(BadRequest()); } _context.Entry(allocate).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AllocateExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Index() { Allocate allo = new Allocate(); List <Student> stuList = new List <Student>(); stuList = allo.getStudents(); return(View(stuList)); }
public void Visit(Allocate line) { Code.Add($"# Begin Allocate"); Code.Add($"li $v0, 9"); Code.Add($"li $a0, {4*line.Size}"); Code.Add($"syscall"); Code.Add($"sw $v0, {-4*line.Variable}($sp)"); Code.Add($"# End Allocate"); }
public JsonResult getAllocation(int semester, int studentId) { int lecturerId = -1; if (Session["account"] != null) { if (Session["account"].Equals("lecturer")) { lecturerId = Convert.ToInt32(Session["userId"]); } } return(Json(Allocate.getAllocation(semester, studentId, lecturerId), JsonRequestBehavior.AllowGet)); }
public static void Main(string [] args) { List <IRTuple> irstream = new List <IRTuple>(); irstream.Add(new IRTuple(IrOp.LABEL, "F$1")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "T", "R2")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "A", "R0")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "B", "R1")); irstream.Add(new IRTupleOneOpImm <int>(IrOp.STORE, "C", 0)); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "D", "A")); irstream.Add(new IRTuple(IrOp.LABEL, "L$1")); irstream.Add(new IRTupleTwoOp(IrOp.ADD, "C", "C", "B")); irstream.Add(new IRTupleOneOpImm <int>(IrOp.STORE, "T$1", 1)); irstream.Add(new IRTupleTwoOp(IrOp.SUB, "D", "D", "T$1")); irstream.Add(new IRTupleOneOpImm <int>(IrOp.STORE, "T$2", 0)); irstream.Add(new IRTupleTwoOp(IrOp.LTE, "T$3", "D", "T$2")); irstream.Add(new IRTupleOneOpIdent(IrOp.JMPF, "L$1", "T$3")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "R0", "C")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "R2", "T")); IRGraph graph = new IRGraph(irstream); List <string> livein; List <List <string> > liveouts; graph.ComputeLiveness(out livein, out liveouts); Dictionary <string, string> registerAllocation = Allocate.run(liveouts, livein); List <IRTuple> irstream_out = new List <IRTuple>(); foreach (IRTuple irt in irstream) { IRTuple translated = irt.TranslateNames(registerAllocation); irstream_out.Add(translated); } Console.WriteLine(); foreach (var kvp in registerAllocation) { Console.WriteLine("{0} : {1}", kvp.Key, kvp.Value); } Console.WriteLine(); foreach (IRTuple irt in irstream_out) { irt.Print(); Console.WriteLine(); } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Allocate = await _context.Allocate_1.FirstOrDefaultAsync(m => m.AllocateID == id); if (Allocate == null) { return(NotFound()); } return(Page()); }
private void button1_Click_2(object sender, EventArgs e) //OK2 { Drawing(ArrayOfHoles, ArrayOfgaps, true); Allocate.Show(); label_NameOfProcess.Show(); label_SizeOfProcess.Show(); textbox_NameOfProcess.Show(); textbox_SizeOfProcess.Show(); First_Fit.Show(); Best_Fit.Show(); Worst_Fit.Show(); label_Deallocate.Show(); textBox_Deallocate.Show(); Deallocate.Show(); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Allocate = await _context.Allocate_1.FindAsync(id); if (Allocate != null) { _context.Allocate_1.Remove(Allocate); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public ActionResult OnPostAllocateTransaction([FromBody] Allocate allocate) { DataSet dstresult = new DataSet(); DataTable dtsdebit = allocate.dtDebit; DataTable dtscredit = allocate.dtCredit; dtsdebit.Columns.Add("IsCredit"); dtsdebit.Columns.Add("AllocateBy"); dtsdebit.Columns.Add("AllocateDate"); dtscredit.Columns.Add("IsCredit"); dtscredit.Columns.Add("AllocateBy"); dtscredit.Columns.Add("AllocateDate"); foreach (DataRow d in dtsdebit.Rows) { d["IsCredit"] = false; d["AllocateBy"] = HttpContext.Session.GetString("Usernames").ToString(); d["AllocateDate"] = DateTime.Now; } foreach (DataRow d in dtscredit.Rows) { d["IsCredit"] = true; d["AllocateBy"] = HttpContext.Session.GetString("Usernames").ToString(); d["AllocateDate"] = DateTime.Now; } dtsdebit.AcceptChanges(); dtscredit.AcceptChanges(); int val = _transactionRepository.SaveAllocatetrans(dtscredit); int vals = _transactionRepository.SaveAllocatetrans(dtsdebit); DataTable dtsval = allocate.dtDebit; dstresult = _transactionRepository.AllocateTransaction(allocate.reconileID, HttpContext.Session.GetString("UserEmail")); return(new JsonResult(dstresult)); }
/// <summary> /// Creates a new pool with a specific starting size. /// </summary> /// <param name="initialSize">The initial size of the pool.</param> /// <param name="validateFunc">A predicate used to determine if a given object is still valid.</param> /// <param name="allocateFunc">A function used to allocate an instance for the pool.</param> public Pool(int initialSize, Predicate <T> validateFunc, Allocate allocateFunc) { // validate some parameters if (initialSize < 0) { throw new ArgumentException("initialSize must be non-negative"); } if (validateFunc == null) { throw new ArgumentNullException("validateFunc"); } if (initialSize == 0) { initialSize = 10; } _items = new T[initialSize]; _validate = validateFunc; InvalidCount = _items.Length; // default to using a parameterless constructor if no allocateFunc was given _allocate = allocateFunc ?? ConstructorAllocate; // if we are using the ConstructorAllocate method, make sure we have a valid parameterless constructor if (_allocate != ConstructorAllocate) { } else { // we want to find any parameterless constructor, public or not _constructor = typeof(T).GetConstructor( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { }, null); if (_constructor == null) { throw new InvalidOperationException(typeof(T) + " does not have a parameterless constructor."); } } }
/// <summary> /// /// </summary> /// <param name="uiItem"></param> /// <returns>depth to add ui item</returns> public int AddItem(UIItem uiItem, int allocateNum) { if (m_allocateList.Any(item => item.Key == uiItem.Name)) { LogModule.ErrorLog("Cannot add item: {0} cause same key exist.", uiItem); return(-1); } if (RemainingDepth < allocateNum) { LogModule.ErrorLog("Cannot add item: {0} cause {1} RemainingDepth < {2} AllocateDepth", uiItem.Name, RemainingDepth, allocateNum); return(-1); } if (m_allocateList.Skip(m_configDepthLength - allocateNum).Any(item => item.Flag)) { RearrangeDepth(); if (m_allocateList.Skip(m_configDepthLength - allocateNum).Any(item => item.Flag)) { LogModule.ErrorLog("Cannot add item: {0} cause no remaining depth", uiItem); return(-1); } } UIItemList.Add(uiItem); int newItemIndex = m_allocateList.FindLastIndex(item => item.Flag) + 1; for (int i = newItemIndex; i < newItemIndex + allocateNum; i++) { m_allocateList[i] = new Allocate() { Key = uiItem.Name, Flag = true }; } return(newItemIndex + m_Config.StartDepth); }
public void readStudent() { st_lst = pat.connect(); pt_list = pat.getPatList(); MySqlCommand command = new MySqlCommand(); con.Open(); command = con.CreateCommand(); command.CommandText = "SELECT* from allocations"; reader = command.ExecuteReader(); Allocate al = null; while (reader.Read()) { al = new Allocate(); al.AID = reader.GetInt32(0); al.AUOB = reader.GetInt32(1); al_list.Add(al); } reader.Close(); con.Close(); }
public static void Main(string [] args) { List <IRTuple> irstream = new List <IRTuple>(); irstream.Add(new IRTuple(IrOp.LABEL, "F$1")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "T", "R3")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "A", "R1")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "B", "R2")); irstream.Add(new IRTupleOneOpImm <int>(IrOp.STORE, "C", 0)); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "D", "A")); irstream.Add(new IRTuple(IrOp.LABEL, "Label")); irstream.Add(new IRTupleTwoOp(IrOp.ADD, "C", "C", "B")); irstream.Add(new IRTupleOneOpImm <int>(IrOp.STORE, "T$1", 1)); irstream.Add(new IRTupleTwoOp(IrOp.SUB, "D", "D", "T$1")); irstream.Add(new IRTupleOneOpImm <int>(IrOp.STORE, "T$2", 0)); irstream.Add(new IRTupleTwoOp(IrOp.LTE, "T$3", "D", "T$2")); irstream.Add(new IRTupleOneOpIdent(IrOp.JMPF, "Label", "T$3")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "R1", "C")); irstream.Add(new IRTupleOneOpIdent(IrOp.STORE, "R3", "T")); Allocate.run(irstream); }
public Pool(Predicate <T> validateFunc, Allocate allocateFunc) : this(0, validateFunc, allocateFunc) { }
public void saveWeight(string prefWeight, string yearWeight, string stuWeight) { Allocate.saveWeight(Int32.Parse(prefWeight), Int32.Parse(yearWeight), Int32.Parse(stuWeight)); }
public JsonResult getStudentsForMultiselectList(int classId) { return(Json(Allocate.getStudentsForMultiselectList(classId), JsonRequestBehavior.AllowGet)); }
public void saveStudentsForMultiselectList(IEnumerable <string> selected_students, string classId) { Allocate.saveStudentsForMultiselectList(selected_students, Int32.Parse(classId)); }
public ActionResult AllocateProducts(Allocate allocatedStuff, [Bind(Include = "Id,OfficeId,ProductId,ProductCount,ManufacturerId,VendorId,IsSplit,LastEditDateTime,LastEditUser")] Allocation allocation, AllocationLot allocationLot, Lot lots, AllocationOffice allocationOffices, OrderProduct orderProducts) { string user = HDUtilities.UserInformation.GetCurrentUserName(); var ordProdsArray = db.OrderProducts.Where(r => r.LastEditUser == user && r.Order.Submitted != true).ToArray(); var ordProdIdsList = db.OrderProducts.Where(r => r.LastEditUser == user && r.Order.Submitted != true).Select(r => r.ProductId).ToList(); var productlist = db.Products.Where(x => ordProdIdsList.Any(d => d == x.Id)).ToList(); bool successful = false; var offices = dbOffice.DDB_HDC_OFFICEINFO.ToList(); Allocation allocationList = new Allocation(); for (int y = 0; y < allocatedStuff.RSCDB.Length; y++) { var office = allocatedStuff.RSCDB[y]; allocationList.AllocationOffices.Add(new AllocationOffice() { AllocationId = allocation.Id, OfficeId = office, LastEditDateTime = DateTime.Now, LastEditUser = user }); } for (int x = 0; x < ordProdsArray.Length; x++) { int ProductCount = ordProdsArray[x].Quantity; decimal totalOrdered = ProductCount; int splitCount = 1; if (allocatedStuff.IsSplit == true) { splitCount = allocatedStuff.RSCDB.Count(); } allocationList.LastEditUser = user; allocationList.LastEditDateTime = DateTime.Now; while (ProductCount > 0) { var product = productlist.Where(r => r.Id == ordProdsArray[x].ProductId && r.Lots.Any(d => d.Quantity != 0)).FirstOrDefault(); Lot lot = product.Lots.Where(r => r.Quantity != 0).OrderBy(d => d.Price).FirstOrDefault(); allocationList.AllocationLots.Add(new AllocationLot() { AllocationId = allocation.Id, Quantity = (ProductCount > lot.Quantity ? lot.Quantity : ProductCount), LotId = lot.Id, LastEditDateTime = DateTime.Now, LastEditUser = user }); var price = lot.Price; if (ProductCount < lot.Quantity) { lot.Quantity -= ProductCount; ProductCount = 0; } else { ProductCount -= lot.Quantity; lot.Quantity = 0; } } var order = db.OrderProducts.Find(ordProdsArray[x].Id); db.OrderProducts.Remove(order); } db.Allocations.Add(allocationList); db.SaveChanges(); successful = true; return(Json(new { Result = successful }, JsonRequestBehavior.AllowGet)); }
public JsonResult getStudentInfo(int studentId) { return(Json(Allocate.getStudentInfo(studentId), JsonRequestBehavior.AllowGet)); }
void temp3() { Console.Write("Thread 3 started"); Allocate a = new Allocate(); new Thread(new ThreadStart(a.startTread(this))); }
public JsonResult getWeight() { return(Json(Allocate.getWeight(), JsonRequestBehavior.AllowGet)); }
public JsonResult getPublishState() { return(Json(Allocate.getPublishState(), JsonRequestBehavior.AllowGet)); }
public static void Main() { //test 1 List <List <string> > input = new List <List <string> >(); input.Add(new List <string>() { "T", "R1", "R2", "T" }); input.Add(new List <string>() { "A", "R2", "A", "T" }); input.Add(new List <string>() { "B", "A", "B", "T" }); input.Add(new List <string>() { "C", "A", "B", "C", "T" }); input.Add(new List <string>() { "D", "B", "C", "D", "T" }); input.Add(new List <string>() { "C", "B", "C", "D", "T" }); input.Add(new List <string>() { "D", "B", "C", "D", "T" }); input.Add(new List <string>() { "D", "B", "C", "D", "T" }); input.Add(new List <string>() { "R1", "R1", "T" }); input.Add(new List <string>() { "R3", "R1", "R3" }); List <string> livein = new List <string>() { "R0", "R1", "R2" }; Dictionary <string, string> results = Allocate.run(input, livein); Console.WriteLine(); foreach (var kvp in results) { Console.WriteLine("{0} : {1}", kvp.Key, kvp.Value); } Console.WriteLine("-----------------"); //test 2 input = new List <List <string> >(); input.Add(new List <string>() { "A", "B", "D" }); input.Add(new List <string>() { "B", "A", "C", "D", "E" }); input.Add(new List <string>() { "C", "E", "B", "F" }); input.Add(new List <string>() { "D", "A", "B", "E", "F" }); input.Add(new List <string>() { "E", "B", "E", "D", "F" }); input.Add(new List <string>() { "F", "C", "D", "E" }); livein = new List <string>(); results = Allocate.run(input, livein); Console.WriteLine(); foreach (var kvp in results) { Console.WriteLine("{0} : {1}", kvp.Key, kvp.Value); } Console.WriteLine(); }