Beispiel #1
0
        private void InitializeCollections()
        {
            batteries = new SecureSortedSet <uint, Battery>();

            BatteriesWithNoDrones = new SecureSortedSet <uint, Battery>((x, y) => (x.Charge <= y.Charge) ? -1 : 1)
            {
                MemberCondition = (obj) => batteries.Contains(obj) && !obj.HasDrone()
            };
            drones = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (obj) => obj is Drone
            };
            DronesWithNoJobs = new SecureSortedSet <uint, Drone>
            {
                MemberCondition = (drone) => drones.Contains(drone) && drone.GetJob() == null
            };
            incompleteJobs = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (item) => item is Job && ((Job)item).Status != JobStatus.Complete
            };
            completedJobs = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (item) => item is Job
            };
        }
 public void GetMaxAndGetMinGetsMaximumAndMinimumOfValueWhenReSortedWithComparer()
 {
     testSet.Add(1, "a");
     testSet.Add(2, "b");
     testSet.Add(3, "c");
     testSet.Add(4, "d");
     testSet.ReSort((x, y) => StringComparer.Ordinal.Compare(x, y));
     Assert.AreEqual("d", testSet.GetMax(false));
     Assert.AreEqual("a", testSet.GetMin(false));
     testSet.Clear();
     testSet = new SecureSortedSet <int, string>();
 }
Beispiel #3
0
 public RetiredDroneData(Drone drone)
 {
     isDroneCollision = false;
     UID           = drone.UID;
     job           = drone.GetJob().UID;
     hub           = drone.GetHub()?.Name;
     completedJobs = drone.JobHistory;
     drone.StopCoroutine(drone.GetBattery().ChargeBattery());
     batteryCharge     = drone.GetBattery().Charge;
     waypoint          = drone.Waypoint;
     destroyedTime     = TimeKeeper.Chronos.Get();
     collisionLocation = drone.transform.position;
     packageWorth      = job == 0 ? 0 : -drone.GetJob().Loss;
     otherDrone        = "Retired";
 }
        public void FindWillRetrieveTheFirstValueThatMathcesPredicateBasedOnOrderOfInsertion()
        {
            var testSet2 = new SecureSortedSet <int, float>();

            testSet2.Add(1, 33f);
            testSet2.Add(2, 54f);
            testSet2.Add(3, 55f);
            testSet2.Add(4, 15f);

            Assert.AreEqual(33f, testSet2.Find((x) => x < 50));
            Assert.AreEqual(54f, testSet2.Find((x) => x > 50));

            testSet2.Remove((int)1);

            Assert.AreEqual(15f, testSet2.Find((x) => x < 50));
        }
Beispiel #5
0
 public RetiredDroneData(Drone drone, Collider other)
 {
     UID           = drone.UID;
     job           = drone.GetJob().UID;
     hub           = drone.GetHub()?.Name;
     completedJobs = drone.JobHistory;
     drone.StopCoroutine(drone.GetBattery().ChargeBattery());
     batteryCharge = drone.GetBattery().Charge;
     if (other.CompareTag("Drone"))
     {
         var collidee = other.GetComponent <Drone>();
         isDroneCollision = true;
         otherDrone       = collidee.Name;
         otherUID         = collidee.UID;
     }
     waypoint          = drone.Waypoint;
     destroyedTime     = TimeKeeper.Chronos.Get();
     collisionLocation = drone.transform.position;
     packageWorth      = job == 0 ? 0 : -drone.GetJob().Loss;
 }
Beispiel #6
0
 public RetiredDroneData(SRetiredDrone data)
 {
     UID = data.uid;
     isDroneCollision = data.isDroneCollision;
     hub               = data.hub;
     packageWorth      = data.packageworth;
     destroyedTime     = new TimeKeeper.Chronos(data.destroyed);
     collisionLocation = data.location;
     waypoint          = data.waypoint;
     otherUID          = data.otherUID;
     otherDrone        = data.otherDroneName;
     batteryCharge     = data.charge;
     job               = data.assignedJob;
     completedJobs     = new SecureSortedSet <uint, IDataSource>((x, y) => (((Job)x).CompletedOn >= ((Job)y).CompletedOn) ? -1 : 1)
     {
         MemberCondition = (IDataSource obj) => { return(obj is Job); }
     };
     foreach (uint j in data.completedJobs)
     {
         completedJobs.Add(j, AllCompleteJobs[j]);
     }
 }
Beispiel #7
0
        private void InitializeCollections()
        {
            deploymentQueue = new Queue <Drone>();
            batteries       = new SecureSortedSet <uint, Battery>();

            freeBatteries = new SecureSortedSet <uint, Battery>((x, y) => (x.Charge <= y.Charge) ? -1 : 1)
            {
                MemberCondition = (Battery obj) => { return(batteries.Contains(obj) && obj.GetDrone() == null); }
            };
            chargingBatteries = new SecureSortedSet <uint, Battery>((x, y) => (x.Charge <= y.Charge) ? -1 : 1)
            {
                MemberCondition = (Battery obj) => { return(batteries.Contains(obj)); }
            };
            drones = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (obj) => { return(obj is Drone); }
            };
            freeDrones = new SecureSortedSet <uint, Drone>
            {
                MemberCondition = (drone) => { return(drones.Contains(drone) && drone.GetJob() == null); }
            };
        }
        public void GetMaxOrGetMinOnlyReSortsWhenArgIsTrue()
        {
            var testSet2 = new SecureSortedSet <int, float[]>((float[] x, float[] y) => Sum(x) <= Sum(y) ? -1 : 1);

            float[] b = { 0.4f, 0.4f, 0.4f };
            float[] d = { 1.4f, 1.4f, 1.4f };
            testSet2.Add(1, new float[] { 0.1f, 0.1f, 0.1f });
            testSet2.Add(2, b);
            testSet2.Add(3, new float[] { 0.8f, 0.8f, 0.8f });
            testSet2.Add(4, d);

            Assert.AreSame(d, testSet2.GetMax(false));
            b[0] = 20;
            Assert.AreSame(b, testSet2.GetMax(true));
            testSet2.Add(2, b);
            b[0] = 0.01f;
            b[1] = 0.02f;
            b[2] = 0.02f;
            Assert.AreSame(b, testSet2.GetMin(true));
            testSet2.Add(2, b);
            b[0] = 200;
            Assert.AreSame(b, testSet2.GetMin(false));
        }
Beispiel #9
0
        private void InitializeCollections()
        {
            retiredDrones = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (item) => item is RetiredDrone
            };

            drones = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (item) => item is Drone
            };

            hubs = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (item) => item is Hub
            };

            noFlyZones = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (item) => item is NoFlyZone
            };

            incompleteJobs = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (item) => item is Job && ((Job)item).Status != JobStatus.Complete
            };

            completeJobs = new SecureSortedSet <uint, IDataSource>
            {
                MemberCondition = (item) => item is Job
            };

            batteries = new SecureSortedSet <uint, Battery>();

            jobs = new SecureSortedSet <uint, Job>();
        }