예제 #1
0
        public Acess ValidTrade(Acess acess = null)
        {
            var r = new Acess();

            foreach (var item in Fila.ToArray())
            {
                r = FilaControle.Where(x => x.Page == item).LastOrDefault();

                if (r.R == 1)
                {
                    r.SetR(0);
                }
                else
                {
                    if (Table.Where(x => x.Page == r.Page).Select(x => x.Count).FirstOrDefault() >= K)
                    {
                        if (r.M == 1)
                        {
                            r.SetM(0);
                            Fila.Add(Fila.FirstOrDefault());
                            Fila.RemoveAt(0);
                        }
                        else
                        {
                            return(r);
                        }
                    }
                }
            }

            return(ValidTrade(r));
        }
        public void AddNewPage(string page)
        {
            if (Memory.Contains("0"))
            {
                FilaControle.Add(page);
            }
            else
            {
                Fila.Add(page);
            }

            ResetBitR();

            var updated = NewPage(() =>
            {
                OldValue               = SecondChance();
                TradingPostion         = Memory.IndexOf(OldValue);
                Memory[TradingPostion] = NewValue;
            },
                                  page);

            if (updated)
            {
                FilaControle.RemoveAt(0);
                FilaControle.Add(page);
            }

            R.Value.Add(1);
            R.Reset++;
        }
 public void AddNewPage(string page)
 {
     NewPage(() =>
     {
         OldValue               = Fila.FirstOrDefault();
         TradingPostion         = Memory.IndexOf(OldValue);
         Memory[TradingPostion] = NewValue;
         Fila.Add(NewValue);
         Fila.RemoveAt(0);
     },
             page);
 }
예제 #4
0
        public void Add(int piano)
        {
            //_pool.WaitOne();
            lock (x)
            {
                if (!Fila.Contains(piano))
                {
                    Fila.Add(piano);
                }
            }

            //_pool.Release(1);
        }
예제 #5
0
        public void AddNewPage(Acess acess)
        {
            var t  = new Acess();
            var rp = FilaControle.Where(x => x.Page == acess.Page).ToList();

            if (rp.Count != 0)
            {
                if (rp.LastOrDefault().M == 1)
                {
                    acess.MovM();
                }
            }

            FilaControle.Add(acess);


            NewPage(() =>
            {
                t                      = ValidTrade();
                OldValue               = t.Page;
                TradingPostion         = Memory.IndexOf(OldValue);
                Memory[TradingPostion] = NewValue;
                Fila.Add(NewValue);
            },
                    acess.Page);

            foreach (var x in Table.ToArray())
            {
                if (x.Page == t.Page)
                {
                    x.Reset();
                }
            }

            foreach (var item in Table.ToArray())
            {
                if (acess.Page == item.Page)
                {
                    item.Reset();
                }

                if (Memory.Contains(item.Page))
                {
                    item.Update();
                }
            }



            ResetBitR();
        }
예제 #6
0
 public void PushFirst(int piano)
 {
     //_pool.WaitOne();
     lock (x)
     {
         if (!Fila.Contains(piano))
         {
             List <int> n = new List <int>();
             n.Add(piano);
             foreach (int i in Fila)
             {
                 n.Add(i);
             }
             Fila.Clear();
             foreach (int i in n)
             {
                 Fila.Add(i);
             }
         }
     }
     //_pool.Release(1);
 }