예제 #1
0
        public void RemoveTest1()
        {
            var bag = new HashBag <int> {
                3, 5, 1, 4, 6, 2
            };

            Assert.Equal(6, bag.Count);
            Assert.True(bag.Remove(1));
            Assert.Equal(5, bag.Count);
            Assert.False(bag.Remove(10));
            Assert.Equal(5, bag.Count);
        }
예제 #2
0
파일: JobQueue.cs 프로젝트: younne0915/C5
 public Job ExecuteOne()
 {
     if (!_jobQueue.IsEmpty)
     {
         var job = _jobQueue.DeleteMin();
         _userJobs.Remove(job._ip);
         _jobs.Remove(job._rid);
         Console.WriteLine($"Executed {job}");
         return(job);
     }
     else
     {
         return(null);
     }
 }
예제 #3
0
 public Job ExecuteOne()
 {
     if (!jobQueue.IsEmpty)
     {
         Job job = jobQueue.DeleteMin();
         userJobs.Remove(job.ip);
         jobs.Remove(job.rid);
         Console.WriteLine("Executed {0}", job);
         return(job);
     }
     else
     {
         return(null);
     }
 }
예제 #4
0
 public void Remove()
 {
     hashbag.Add(4);
     hashbag.Add(4);
     hashbag.Add(5);
     hashbag.Add(4);
     hashbag.Add(6);
     Assert.IsFalse(hashbag.Remove(2));
     Assert.IsTrue(hashbag.Remove(4));
     Assert.IsTrue(IC.seteq(hashbag, 4, 4, 5, 6));
     hashbag.Add(7);
     hashbag.Add(21);
     hashbag.Add(37);
     hashbag.Add(53);
     hashbag.Add(69);
     hashbag.Add(53);
     hashbag.Add(85);
     Assert.IsTrue(hashbag.Remove(5));
     Assert.IsTrue(IC.seteq(hashbag, 4, 4, 6, 7, 21, 37, 53, 53, 69, 85));
     Assert.IsFalse(hashbag.Remove(165));
     Assert.IsTrue(hashbag.Check());
     Assert.IsTrue(IC.seteq(hashbag, 4, 4, 6, 7, 21, 37, 53, 53, 69, 85));
     Assert.IsTrue(hashbag.Remove(53));
     Assert.IsTrue(IC.seteq(hashbag, 4, 4, 6, 7, 21, 37, 53, 69, 85));
     Assert.IsTrue(hashbag.Remove(37));
     Assert.IsTrue(IC.seteq(hashbag, 4, 4, 6, 7, 21, 53, 69, 85));
     Assert.IsTrue(hashbag.Remove(85));
     Assert.IsTrue(IC.seteq(hashbag, 4, 4, 6, 7, 21, 53, 69));
 }
예제 #5
0
        public void RemoveTest2()
        {
            var bag = new HashBag <int> {
                3, 5, 1, 1, 4, 6, 2, 2, 2
            };

            Assert.Equal(9, bag.Count);

            Assert.Equal(2, bag.Remove(1, 2));
            Assert.Equal(7, bag.Count);

            Assert.Equal(0, bag.Remove(10, 3));
            Assert.Equal(7, bag.Count);

            Assert.Equal(2, bag.Remove(2, 2));
            Assert.Equal(5, bag.Count);

            Assert.Equal(1, bag.Remove(5, 1));
            Assert.Equal(4, bag.Count);

            Assert.Equal(1, bag.Remove(2, 5));
            Assert.Equal(3, bag.Count);
        }