示例#1
0
    /********** Helper Functions *********/
    //

    private void RemoveFromStack(int id)
    {
        TupleItem temp = dictItems[id];

        --temp.count;
        dictItems[id] = temp;
    }     // end : RemoveFromStack
示例#2
0
    }     // end : AddToStack

    /* AddNewStack()
     *  Adds a new stack for id in dictionary.
     *  The id must not exist, yet.
     *  throws System.ArgumentException
     */
    private void AddNewStack(Item item)
    {
        TupleItem newTuple = new TupleItem();

        newTuple.count = 1;
        newTuple.data  = item;

        dictItems.Add(item.ID, newTuple);
    }     // end : AddNewStack
示例#3
0
    }     // end : RemoveFromStack

    /* AddToStack()
     *  Increments the count for entry with id.
     *  The id must exist in dictItem.
     *  throws KeyNotFoundException
     */
    private bool AddToStack(int id)
    {
        TupleItem temp = dictItems[id];

        if (temp.count >= stackSize)
        {
            return(false);
        }

        temp.count++;
        dictItems[id] = temp;
        return(true);
    }     // end : AddToStack
示例#4
0
 public bool Equals(TupleItem other, bool attributeCheck = true) => other.Type == Type;
示例#5
0
        private static void Main(string[] args)
        {
            var context = new StorageDbContext();

            var scanners = new Scanner[]
            {
                new Scanner {
                    Id = 1, Name = "Scanner1"
                },
                new Scanner {
                    Id = 2, Name = "LG"
                },
                new Scanner {
                    Id = 3, Name = "GT"
                },
                new Scanner {
                    Id = 4, Name = "RM"
                },
                new Scanner {
                    Id = 5, Name = "MT"
                },
                new Scanner {
                    Id = 6, Name = "IY"
                },
                new Scanner {
                    Id = 7, Name = "PR"
                },
                new Scanner {
                    Id = 8, Name = "WI"
                },
                new Scanner {
                    Id = 9, Name = "QP"
                },
                new Scanner {
                    Id = 10, Name = "CB"
                }
            };

            context.Scanners.AddOrUpdate(a => a.Id, scanners);
            context.SaveChanges();

            foreach (var scanner in scanners)
            {
                var tuples = new DataTuple[]
                {
                    new DataTuple  {
                        ScannerId = scanner.Id, Date = DateTime.Now.AddDays(1)
                    },
                    new DataTuple  {
                        ScannerId = scanner.Id, Date = DateTime.Now.AddDays(2)
                    },
                    new DataTuple  {
                        ScannerId = scanner.Id, Date = DateTime.Now.AddDays(3)
                    },
                };
                context.Tuples.AddRange(tuples);
                context.SaveChanges();

                foreach (var tuple in tuples)
                {
                    var items = new TupleItem[1800];
                    for (var i = 0; i < items.Length; i++)
                    {
                        items[i] = new TupleItem
                        {
                            TupleId  = tuple.Id,
                            Name     = "Tuple#" + i,
                            Distance = i,
                            XAxis    = i,
                            YAxis    = i
                        };
                    }

                    context.Items.AddRange(items);
                    context.SaveChanges();
                }
            }
        }