Inheritance: ScriptableObject
Exemplo n.º 1
0
        /// <summary>
        /// Creates a new genetic min max no depot vrp router.
        /// </summary>
        /// <param name="max"></param>
        /// <param name="delivery_time"></param>
        /// <param name="population"></param>
        /// <param name="stagnation"></param>
        /// <param name="elitism_percentage"></param>
        /// <param name="cross_percentage"></param>
        /// <param name="mutation_percentage"></param>
        /// <param name="probabilities"></param>
        public RouterGeneticSimple(
            Second max, Second delivery_time, int population, int stagnation,
            double elitism_percentage, double cross_percentage, double mutation_percentage,
            List <double> probabilities)
            : base(max, delivery_time)
        {
            _population = population;
            _stagnation = stagnation;

            _elitism_percentage  = elitism_percentage;
            _cross_percentage    = cross_percentage;
            _mutation_percentage = mutation_percentage;
            _probabilities       = probabilities;
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            First myFirst = new First();
            myFirst.Print();

            Second mySecond = new Second();
            mySecond.Print();

            Thrid myThrid = new Thrid();
            myThrid.Print();

            Fourth myFourth = new Fourth();
            myFourth.Print();
        }
Exemplo n.º 3
0
        //=

        private void button14_Click(object sender, EventArgs e)

        {
            Dot = 0;
            if (operation != "Sq")

            {
                if (Second == null)
                {
                    Second = Convert.ToDouble(textBox2.Text);
                }
                if (((First == null) || (First == 0)) && (Second != null))
                {
                    textBox3.Text = Second.ToString();
                    First         = Second;
                    Second        = null;
                }
                else if ((First != null) && ((Second != null) || (Second != 0)) && (operation != ""))

                {
                    First = myClass.Logicl_work((double)First, (double)Second, operation);

                    textBox3.Text = First.ToString();

                    operation = operation_2 = "";

                    Second = null;
                }
            }

            else

            {
                First = Convert.ToDouble(textBox2.Text);

                if (First != 0)

                {
                    First = myClass.Logicl_work((double)First, 0, operation);

                    textBox3.Text = First.ToString();

                    operation = operation_2 = "";

                    Second = null;
                }
            }

            textBox2.Text = "0";
        }
Exemplo n.º 4
0
        internal override IList <IEnumerable <TResult> > GetEnumerables(QueryOptions options)
        {
            var first  = Parent.GetEnumerables(options);
            var second = Second.GetEnumerables(options);

            if (first.Count != second.Count)
            {
                throw new InvalidOperationException("Internal size mismatch");
            }

            return(first
                   .Select((f, i) => GetEnumerable(f, second[i]))
                   .ToList());
        }
Exemplo n.º 5
0
        public override bool Equals(object obj)
        {
            if (obj is Tuple4 <TFirst, TSecond, TThree, TFour> )
            {
                var other = (Tuple4 <TFirst, TSecond, TThree, TFour>)obj;

                return(First.Equals(other.First) &&
                       Second.Equals(other.Second) &&
                       Three.Equals(other.Three) &&
                       Four.Equals(other.Four));
            }

            return(base.Equals(obj));
        }
Exemplo n.º 6
0
        static void Main()
        {
            Console.OutputEncoding = Encoding.Unicode;
            Console.InputEncoding  = Encoding.Unicode;
            First f = new First();

            f.Output();
            Second s = new Second();

            s.Output();
            Third t = new Third();

            t.Output();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            //Second Task
            Second s        = new Second();
            String coef1str = s.coef[1] >= 0 ? " + " + s.coef[1] : " - " + (-s.coef[1]);

            Console.WriteLine("(" + s.coef[0] + coef1str + "x)/(1 + " + s.coef[2] + "x)");
            //Third task
            Third t = new Third();

            Console.WriteLine(t.quadCoef[0] + " + " + t.quadCoef[1] + "x + " + t.quadCoef[2] + "x^2");
            Console.WriteLine(t.linearCoef[0] + "x + " + t.linearCoef[1]);
            Console.ReadKey();
        }
        public List <Scroll> ConvertToList()
        {
            List <Scroll> list = new List <Scroll>();

            list.AddRange(First.Where(_ => _.Number > 0).ToList());
            list.AddRange(Second.Where(_ => _.Number > 0).ToList());
            list.AddRange(Third.Where(_ => _.Number > 0).ToList());
            list.AddRange(Fourth.Where(_ => _.Number > 0).ToList());
            list.AddRange(Fifth.Where(_ => _.Number > 0).ToList());
            list.AddRange(Sixth.Where(_ => _.Number > 0).ToList());
            list.AddRange(Seventh.Where(_ => _.Number > 0).ToList());
            list.AddRange(Eigth.Where(_ => _.Number > 0).ToList());
            list.AddRange(Ninth.Where(_ => _.Number > 0).ToList());
            return(list);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a new route tracker animator.
        /// </summary>
        /// <param name="mapView">The mapview.</param>
        /// <param name="routeTracker">The tracker tracking the route.</param>
        /// <param name="restartAfterTouch">The time in second to wait before resuming tracking after the mapview is touched.</param>
        /// <param name="defaultZoom">The default zoom.</param>
        public RouteTrackerAnimator(IMapView mapView, RouteTracker routeTracker, Second restartAfterTouch, float defaultZoom)
        {
            this.MinZoom     = 18;
            this.MaxZoom     = 30;
            this.DefaultZoom = defaultZoom;

            _mapView         = mapView;
            _animator        = new MapViewAnimator(mapView);
            _routeTracker    = routeTracker;
            _minimumTrackGap = new TimeSpan(0, 0, 0, 0, 500).Ticks;

            this.RestartAfterTouch = restartAfterTouch;

            _mapView.MapTouched += MapViewMapTouched;
        }
Exemplo n.º 10
0
        /// <inheritdoc />
        protected override void Execute(Context context)
        {
            var dateTime = InputDateTime.Get(context);

            DateAsDT.Set(context, new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0));
            TimeAsDT.Set(context, new DateTime(1, 1, 1, dateTime.Hour, dateTime.Minute, dateTime.Second));
            Day.Set(context, dateTime.Day);
            Month.Set(context, dateTime.Month);
            Year.Set(context, dateTime.Year);
            YearAsString.Set(context, dateTime.Year.ToString());
            Hour.Set(context, dateTime.Hour);
            Minute.Set(context, dateTime.Minute);
            Second.Set(context, dateTime.Second);
            Kind.Set(context, dateTime.Kind.ToString());
        }
Exemplo n.º 11
0
        /// <summary>
        /// Compares the value of this instance to a specified <see cref="LocalDateTime"/> value and returns an integer
        /// that indicates whether this instance is earlier than, the same as, or later than the specified
        /// DateTime value.
        /// </summary>
        /// <param name="other">The object to compare to the current instance.</param>
        /// <returns>A signed number indicating the relative values of this instance and the value parameter.</returns>
        public int CompareTo(LocalDateTime other)
        {
            if (ReferenceEquals(this, other))
            {
                return(0);
            }
            if (other is null)
            {
                return(1);
            }
            var yearComparison = Year.CompareTo(other.Year);

            if (yearComparison != 0)
            {
                return(yearComparison);
            }
            var monthComparison = Month.CompareTo(other.Month);

            if (monthComparison != 0)
            {
                return(monthComparison);
            }
            var dayComparison = Day.CompareTo(other.Day);

            if (dayComparison != 0)
            {
                return(dayComparison);
            }
            var hourComparison = Hour.CompareTo(other.Hour);

            if (hourComparison != 0)
            {
                return(hourComparison);
            }
            var minuteComparison = Minute.CompareTo(other.Minute);

            if (minuteComparison != 0)
            {
                return(minuteComparison);
            }
            var secondComparison = Second.CompareTo(other.Second);

            if (secondComparison != 0)
            {
                return(secondComparison);
            }
            return(Nanosecond.CompareTo(other.Nanosecond));
        }
Exemplo n.º 12
0
        public void TestUpdateMultipleAccess()
        {
            First inst = new First();

            inst.Id   = 56;
            inst.Name = "testMultiple";

            //  Second[] second = inst.GetSecond();

            //insert
            Second ss = new Second();

            ss.Age      = 99;
            ss.Quantity = 890;

            //update
            Second s1 = new Second();

            s1.Id       = 909;
            s1.Quantity = 90;
            s1.Age      = 90;
            s1.FirstId  = 56;



            Second s2 = new Second();

            s2.Id       = 112;
            s2.Quantity = 11;
            s2.Age      = 11;
            s2.FirstId  = 56;

            inst.AttachTableMetadata(s1);
            inst.AttachTableMetadata(s2);

            //delete
            inst.RemoveTableMetadata(s2);

            List <ExecutionQuery> list = SqlGenerator.GenerateMultipleUpdateQueries(DatabaseServer.Access, inst);

            foreach (ExecutionQuery var in list)
            {
                Console.WriteLine(var.Query);
            }


            Assert.IsTrue(list.Count > 0);
        }
Exemplo n.º 13
0
 private void timer_Tick(object sender, EventArgs e)
 {
     second++;
     if (lblCamera.Visible == true)
     {
         lblCamera.Visible = false;
     }
     else
     {
         lblCamera.Visible = true;
     }
     Second++;
     if (Second == 61)
     {
         Second = 0;
         Minute++;
         if (Minute < 10)
         {
             lblMinute.Text = "0" + Minute.ToString();
         }
         else
         {
             lblMinute.Text = Minute.ToString();
         }
         if (Minute == 61)
         {
             Second = 0;
             Minute = 0;
             Hour++;
             if (Hour < 9)
             {
                 lblHour.Text = "0" + Hour.ToString();
             }
             else
             {
                 lblHour.Text = Hour.ToString();
             }
         }
     }
     if (Second < 10)
     {
         lblSecond.Text = "0" + Second.ToString();
     }
     else
     {
         lblSecond.Text = Second.ToString();
     }
 }
Exemplo n.º 14
0
        private List <KeyValuePair <string, string[]> > Primaries()
        {
            string[] value = new string[2] {
                "number", First.ToString()
            };
            List <KeyValuePair <string, string[]> > Data = new List <KeyValuePair <string, string[]> >
            {
                new KeyValuePair <string, string[]>("currency_id_first", value)
            };

            value = new string[2] {
                "number", Second.ToString()
            };
            Data.Add(new KeyValuePair <string, string[]>("currency_id_second", value));
            return(Data);
        }
Exemplo n.º 15
0
 public void chi()
 {
     if (!info)
     {
         CHInfo.gameObject.SetActive(true);
         First.SetActive(true);
         Second.SetActive(true);
         Third.SetActive(true);
         info = true;
     }
     else
     {
         CHInfo.gameObject.SetActive(false);
         info = false;
     }
 }
Exemplo n.º 16
0
 private void Start()
 {
     First.ClearTime();
     Second.ClearTime();
     if (_options.SecondStartsGame)
     {
         _switch = _switch.Swap();
         First.StopMoving();
         Second.StartMoving();
     }
     else
     {
         First.StartMoving();
         Second.StopMoving();
     }
 }
Exemplo n.º 17
0
        internal override IList <IEnumerable <TResult> > GetEnumerables(QueryOptions options)
        {
            var first  = Parent.GetEnumerables(options);
            var second = Second.GetEnumerables(options);

            if (first.Count != second.Count)
            {
                throw new InvalidOperationException("Internal size mismatch");
            }

            var store = new ConcurrentDictionary <TKey, Tuple <VSlot <TFirst>, VSlot <TSecond> > > (comparer);

            return(first
                   .Select((f, i) => GetEnumerable(f, second[i], store, firstKeySelector, secondKeySelector, resultSelector))
                   .ToList());
        }
Exemplo n.º 18
0
 private PeriodicSchedule(
     Month month,
     Week week,
     Day day,
     WeekDay weekDay,
     Hour hour,
     Minute minute,
     Second second,
     Duration minimumGap,
     [NotNull] CalendarSystem calendarSystem,
     [NotNull] DateTimeZone dateTimeZone,
     ScheduleOptions options,
     [CanBeNull] string name)
     : base(
         name,
         CreateFunction(
             month,
             week,
             day,
             weekDay,
             hour,
             minute,
             second,
             minimumGap,
             calendarSystem,
             dateTimeZone),
         options)
 {
     if (calendarSystem == null)
     {
         throw new ArgumentNullException("calendarSystem");
     }
     if (dateTimeZone == null)
     {
         throw new ArgumentNullException("dateTimeZone");
     }
     Month          = month;
     Week           = week;
     Day            = day;
     WeekDay        = weekDay;
     Hour           = hour;
     Minute         = minute;
     Second         = second;
     MinimumGap     = minimumGap;
     CalendarSystem = calendarSystem;
     DateTimeZone   = dateTimeZone;
 }
Exemplo n.º 19
0
 public override void Update(GameTime gametime)
 {
     Frog.Position.X = MathHelper.Clamp(Frog.Position.X, Frog.Width() / 2, Game1.ScreenWidth - Frog.Width() / 2);
     Frog.Position.Y = MathHelper.Clamp(Frog.Position.Y, Frog.Height() / 2, Game1.ScreenHeight - Frog.Height() / 2);
     if (Keyboard.GetState().IsKeyDown(Keys.Escape))
     {
         PublicMember.CurrentScreen = PublicMember.ChangeScreen(Screens.MenuScreen);
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Left))
     {
         Frog.Direction   = SpriteEffects.None;
         Frog.Position.X -= 6;
     }
     if (Keyboard.GetState().IsKeyDown(Keys.Right))
     {
         Frog.Direction   = SpriteEffects.FlipHorizontally;
         Frog.Position.X += 6;
     }
     if (Keyboard.GetState().IsKeyDown(Keys.D))
     {
         Bear.Direction = SpriteEffects.FlipHorizontally;
     }
     if (gametime.TotalGameTime.TotalMilliseconds >= TimeForSecond + 1000)
     {
         TimeForSecond = gametime.TotalGameTime.TotalMilliseconds;
         Second second = new Second();
         second.Initialize(SecondTexture, new Vector2()
         {
             X = Game1.ran.Next(0, Game1.ScreenWidth - 10),
             Y = 0
         });
         Seconds.Add(second);
     }
     if (Seconds.Count > 0)
     {
         for (int i = Seconds.Count - 1; i >= 0; i--)
         {
             Seconds[i].Position.Y += 3;
             if (Seconds[i].Position.Y >= Game1.ScreenHeight - Seconds[i].Height() / 2 || Seconds[i].Rectangle.Intersects(Frog.Rectangle))
             {
                 Seconds.Remove(Seconds[i]);
             }
         }
     }
     base.Update(gametime);
 }
Exemplo n.º 20
0
 public string ToString(string format)
 {
     format = format.Replace("yyyy", Year.ToString("0000"));
     format = format.Replace("yy", Year.ToString("00"));
     format = format.Replace("y", Year.ToString());
     format = format.Replace("MM", Month.ToString("00"));
     format = format.Replace("M", Month.ToString());
     format = format.Replace("dd", Day.ToString("00"));
     format = format.Replace("d", Day.ToString());
     format = format.Replace("HH", Hour.ToString("00"));
     format = format.Replace("H", Hour.ToString());
     format = format.Replace("mm", Minute.ToString("00"));
     format = format.Replace("m", Minute.ToString());
     format = format.Replace("ss", Second.ToString("00"));
     format = format.Replace("s", Second.ToString());
     return(format);
 }
Exemplo n.º 21
0
            public void FrequencyUnits()
            {
                RPM        rpm             = (RPM)7200;
                Hertz      frequency       = (Hertz)rpm;
                Radian_Sec angularvelocity = (Radian_Sec)frequency;

                rpm = (RPM)angularvelocity;

                Assert.AreEqual((Hertz)120.0, frequency, "RPM-to-Hetrz conversion failed");
                Assert.AreEqual((Radian_Sec)(240.0 * Math.PI), angularvelocity, "Hertz-to-Radian_Sec conversion failed");
                Assert.AreEqual((RPM)7200.0, rpm, "Radian_Sec-to-RPM conversion failed");

                Second duration    = (Second)1.0;
                Cycles revolutions = frequency * duration;

                Assert.AreEqual((Cycles)120.0, revolutions, "revolutions = frequency * duration conversion failed");
            }
Exemplo n.º 22
0
        /// <summary>
        /// 时角转换
        /// 如 -112233.444444
        /// </summary>
        /// <returns></returns>
        public string ToHms_sString()
        {
            var degs     = this.Degrees;
            var hourDeci = Degrees / 15.0;
            var hour     = (int)(hourDeci);
            //var minuteDec = (hourDeci - hour) * 60.0;
            //var minute = (int)minuteDec;
            //var second = (hourDeci - minute / 60.0) * 3600.0;

            StringBuilder sb = new StringBuilder();

            sb.Append(IsPlus ? "" : "-");
            sb.Append(hour.ToString("00"));
            sb.Append(Minute.ToString("00"));
            sb.Append(Second.ToString("00.00####"));
            return(sb.ToString());
        }
Exemplo n.º 23
0
 private void switchEq(object state)
 {
     if (Terminal == null || Terminal.Enable == false && !Terminal.TurnOffing)
     {
         return;
     }
     if (Primary.Overload)
     {
         Primary.TurnOff();
         Second.TurnOn();
     }
     else if (Second.Overload)
     {
         Second.TurnOff();
         Primary.TurnOn();
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// Initialize's a game
        /// </summary>
        public void InitializeGame()
        {
            CurrentGameHistory = new GameHistory();

            FirstUser  = Game.Players[0].Bot;
            SecondUser = Game.Players[1].Bot;

            First  = Platform.Chatbots.Where(x => x.User.Id == FirstUser.Id).ToList()[0];
            Second = Platform.Chatbots.Where(x => x.User.Id == SecondUser.Id).ToList()[0];

            // Initialize bots
            Second.InitializeUserBot(First.BotEngine);
            First.InitializeUserBot(Second.BotEngine);
            First.IsInGame  = true;
            Second.IsInGame = true;
            Platform.LogEvent("Game " + Game.Id.ToString() + " Initialized ", ConsoleColor.DarkCyan);
        }
Exemplo n.º 25
0
 // Update is called once per frame
 void Update()
 {
     for (int i = 0; i < wm.weapons.Length; i++)
     {
         if (wm.weapons[i].activeInHierarchy)   // Get Current Weapon
         {
             CurrentWeapon = wm.weapons[i];
             WeaponScript  = CurrentWeapon.GetComponent <Weapons>();
         }
     }
     Minutes         = (int)((Time.time - levelStartTime) / 60);
     Second          = (int)((Time.time - levelStartTime) % 60);
     TimeText.text   = Minutes.ToString("00") + ":" + Second.ToString("00");
     HealthText.text = "<color=#800000ff>+</color>" + PlayerScript.PlayerHealth;
     MagAmmo.text    = WeaponScript.currentBullets + "";
     totalAmmo.text  = WeaponScript.BulletsLeft + "";
 }
Exemplo n.º 26
0
        public override Node Evaluate(Env env)
        {
            var a = First.Evaluate(env);
            var b = Second.Evaluate(env);

            if (a is Number && b is Color)
            {
                if (Operator == "*" || Operator == "+")
                {
                    var temp = b;
                    b = a;
                    a = temp;
                }
                else
                {
                    throw new ParsingException("Can't substract or divide a color from a number", Location);
                }
            }

            try
            {
                var operable = a as IOperable;
                if (operable != null)
                {
                    return(operable.Operate(this, b).ReducedFrom <Node>(this));
                }

                if (Operator == "+" && (a is Quoted || a is TextNode) && (b is Quoted || b is TextNode)) // Runge
                {
                    //Quoted qa = a as Quoted;
                    //Quoted qb = b as Quoted;
                    return(new Quoted(a.ToCSS(env) + Operator + b.ToCSS(env), (a is Quoted) ? (a as Quoted).Escaped: false));
                }

                throw new ParsingException(string.Format("Cannot apply operator {0} to the left hand side: {1}", Operator, a.ToCSS(env)), Location);
            }
            catch (DivideByZeroException e)
            {
                throw new ParsingException(e, Location);
            }
            catch (InvalidOperationException e)
            {
                throw new ParsingException(e, Location);
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Calculate metrics for a given turn.
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="result"></param>
        /// <param name="point"></param>
        private void CalculatePointMetrics(Vehicle vehicle, Dictionary <string, double> result, AggregatedPoint point)
        {
            if (point.Angle != null)
            {
                if (AggregatedHelper.IsTurn(point.Angle.Direction))
                {
                    // no calculations for distance.

                    // update the time.
                    Second second = 0;
                    // ESTIMATE THE INCREASE IN TIME.
                    // TODO: ASSUMED DRIVING ON THE RIGHT; UPDATE TO MAKE CONFIGURABLE.
                    switch (point.Angle.Direction)
                    {
                    case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.Left:
                    case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.SharpLeft:
                    case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.SlightlyLeft:
                        second = 25;
                        break;

                    case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.Right:
                    case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.SharpRight:
                    case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.SlightlyRight:
                        second = 5;
                        break;

                    case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.TurnBack:
                        second = 30;
                        break;
                    }
                    result[TIME_KEY] = result[TIME_KEY] + second.Value;
                }
                else
                {
                    if (point.ArcsNotTaken != null && point.ArcsNotTaken.Count > 0)
                    { // very simple estimate.
                        Second second = 0;

                        second = 5;

                        result[TIME_KEY] = result[TIME_KEY] + second.Value;
                    }
                }
            }
        }
Exemplo n.º 28
0
        public IValue ReduceDivisorIntegerComponent(Integer sharedComponent)
        {
            Integer first     = First.DivisorIntegerComponent;
            Integer firstPart = first.CommonFactors(sharedComponent);
            Integer remainder = (sharedComponent / firstPart).ToInteger();

            if (firstPart == 1)
            {
                return(new Product(First, Second.ReduceDivisorIntegerComponent(remainder)).Simple());
            }

            if (remainder == 1)
            {
                return(new Product(First.ReduceDivisorIntegerComponent(firstPart), Second).Simple());
            }

            return(new Product(First.ReduceDivisorIntegerComponent(firstPart), Second.ReduceDivisorIntegerComponent(remainder)).Simple());
        }
Exemplo n.º 29
0
        public static IEnumerable <int> Seconds(this Second second)
        {
            // Cast to an integer
            ulong s = (ulong)second;

            // Check bits
            List <int> valid = new List <int>();

            for (int i = 0; i < 60; i++)
            {
                ulong bit = (ulong)1 << i;
                if ((s & bit) == bit)
                {
                    valid.Add(i);
                }
            }
            return(valid);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Balances the binary trees within the expression.
        /// </summary>
        /// <returns>The balanced expression.</returns>
        public IExpression Balance()
        {
            if (_balanced)
            {
                return(this);
            }

            if (!BalanceOps.TryGetValue(Operator, out CompoundOperator inverseOp))
            {
                return(new CompoundExpression(Operator, First.Balance(), Second.Balance(), true));
            }

            List <IExpression> chain = new List <IExpression>();

            GetChainedValues(this, chain);

            return(Rebuild(chain, Operator, inverseOp));
        }
Exemplo n.º 31
0
 public void ch3()
 {
     CHInfo.gameObject.SetActive(false);
     First.SetActive(true);
     Second.SetActive(true);
     if (!bool3)
     {
         Third.SetActive(false);
         bool3 = true;
         bool2 = false;
         bool1 = false;
     }
     else
     {
         bool3 = false;
         Third.SetActive(true);
     }
 }
Exemplo n.º 32
0
Arquivo: c.cs Projeto: kevinarpe/kx
 object r()
 {
     int i = 0, n, t = (sbyte)b[j++]; if (t < 0) switch (t)
         {
             case -1: return rb();
             case -4: return b[j++];
             case -5: return rh();
             case -6: return ri();
             case -7: return rj();
             case -8: return re();
             case -9: return rf();
             case -10: return rc();
             case -11: return rs();
             case -12: return rp();
             case -13: return rm();
             case -14: return rd();
             case -15: return rz();
             case -16: return rn();
             case -17: return ru();
             case -18: return rv();
             case -19: return rt();
         }
     if (t > 99) { if (t == 101 && b[j++] == 0)return null; throw new KException("func"); } if (t == 99) return new Dict(r(), r()); j++; if (t == 98) return new Flip((Dict)r()); n = ri(); switch (t)
     {
         case 0: object[] L = new object[n]; for (; i < n; i++) L[i] = r(); return L;
         case 1: bool[] B = new bool[n]; for (; i < n; i++) B[i] = rb(); return B;
         case 4: byte[] G = new byte[n]; for (; i < n; i++) G[i] = b[j++]; return G;
         case 5: short[] H = new short[n]; for (; i < n; i++) H[i] = rh(); return H;
         case 6: int[] I = new int[n]; for (; i < n; i++) I[i] = ri(); return I;
         case 7: long[] J = new long[n]; for (; i < n; i++) J[i] = rj(); return J;
         case 8: float[] E = new float[n]; for (; i < n; i++) E[i] = re(); return E;
         case 9: double[] F = new double[n]; for (; i < n; i++) F[i] = rf(); return F;
         case 10: char[] C = e.GetChars(b, j, n); j += n; return C;
         case 11: String[] S = new String[n]; for (; i < n; i++) S[i] = rs(); return S;
         case 12: DateTime[] P = new DateTime[n]; for (; i < n; i++) P[i] = rp(); return P;
         case 13: Month[] M = new Month[n]; for (; i < n; i++) M[i] = rm(); return M;
         case 14: Date[] D = new Date[n]; for (; i < n; i++) D[i] = rd(); return D;
         case 15: DateTime[] Z = new DateTime[n]; for (; i < n; i++) Z[i] = rz(); return Z;
         case 16: KTimespan[] N = new KTimespan[n]; for (; i < n; i++) N[i] = rn(); return N;
         case 17: Minute[] U = new Minute[n]; for (; i < n; i++) U[i] = ru(); return U;
         case 18: Second[] V = new Second[n]; for (; i < n; i++) V[i] = rv(); return V;
         case 19: TimeSpan[] T = new TimeSpan[n]; for (; i < n; i++) T[i] = rt(); return T;
     } return null;
 }
Exemplo n.º 33
0
        /// <summary>
        /// Get's the next valid second after the current .
        /// </summary>
        /// <param name="dateTime">The date time (fractions of a second are removed).</param>
        /// <param name="month">The month.</param>
        /// <param name="week">The week.</param>
        /// <param name="day">The day.</param>
        /// <param name="weekDay">The week day.</param>
        /// <param name="hour">The hour.</param>
        /// <param name="minute">The minute.</param>
        /// <param name="second">The second.</param>
        /// <param name="calendar">The calendar.</param>
        /// <param name="calendarWeekRule">The calendar week rule.</param>
        /// <param name="firstDayOfWeek">The first day of week.</param>
        /// <param name="inclusive">if set to <c>true</c> can return the time specified, otherwise, starts at the next second..</param>
        /// <returns>
        /// The next valid date (or <see cref="DateTime.MaxValue"/> if none).
        /// </returns>
        public static DateTime NextValid(
                this DateTime dateTime,
                Month month = Month.Every,
                Week week = Week.Every,
                Day day = Day.Every,
                WeekDay weekDay = WeekDay.Every,
                Hour hour = Hour.Zeroth,
                Minute minute = Minute.Zeroth,
                Second second = Second.Zeroth,
                Calendar calendar = null,
                CalendarWeekRule calendarWeekRule = CalendarWeekRule.FirstFourDayWeek,
                DayOfWeek firstDayOfWeek = DayOfWeek.Sunday,
                bool inclusive = false)
        {
            // Never case, if any are set to never, we'll never get a valid date.
            if ((month == Month.Never) || (week == Week.Never) ||
                (day == Day.Never) || (weekDay == WeekDay.Never) || (hour == Hour.Never) ||
                (minute == Minute.Never) ||
                (second == Second.Never))
                return DateTime.MaxValue;

            if (calendar == null)
                calendar = CultureInfo.CurrentCulture.Calendar;

            // Set the time to this second (or the next one if not inclusive), remove fractions of a second.
            dateTime = new DateTime(
                    dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
            if (!inclusive)
                dateTime = calendar.AddSeconds(dateTime, 1);

            // Every second case.
            if ((month == Month.Every) && (day == Day.Every) && (weekDay == WeekDay.Every) && (hour == Hour.Every) &&
                (minute == Minute.Every) && (second == Second.Every) &&
                (week == Week.Every))
                return calendar.AddSeconds(dateTime, 1);

            // Get days and months.
            IEnumerable<int> days = day.Days().OrderBy(dy => dy);
            IEnumerable<int> months = month.Months();

            // Remove months where the first day isn't in the month.
            int firstDay = days.First();
            if (firstDay > 28)
            {
                // 2000 is a leap year, so February has 29 days.
                months = months.Where(mn => calendar.GetDaysInMonth(2000, mn) >= firstDay);
                if (months.Count() < 1)
                    return DateTime.MaxValue;
            }

            // Get remaining date components.
            int y = calendar.GetYear(dateTime);
            int m = calendar.GetMonth(dateTime);
            int d = calendar.GetDayOfMonth(dateTime);

            int h = calendar.GetHour(dateTime);
            int n = calendar.GetMinute(dateTime);
            int s = calendar.GetSecond(dateTime);

            IEnumerable<int> weeks = week.Weeks();
            IEnumerable<DayOfWeek> weekDays = weekDay.WeekDays();
            IEnumerable<int> hours = hour.Hours().OrderBy(i => i);
            IEnumerable<int> minutes = minute.Minutes().OrderBy(i => i);
            IEnumerable<int> seconds = second.Seconds();
            
            do
            {
                foreach (int currentMonth in months)
                {
                    if (currentMonth < m)
                        continue;
                    if (currentMonth > m)
                    {
                        d = 1;
                        h = n = s = 0;
                    }
                    m = currentMonth;
                    foreach (int currentDay in days)
                    {
                        if (currentDay < d)
                            continue;
                        if (currentDay > d)
                            h = n = s = 0;
                        d = currentDay;

                        // Check day is valid for this month.
                        if ((d > 28) && (d > calendar.GetDaysInMonth(y, m)))
                            break;

                        // We have a potential day, check week and week day
                        dateTime = new DateTime(y, m, d, h, n, s);
                        if ((week != Week.Every) &&
                            (!weeks.Contains(dateTime.WeekNumber(calendar, calendarWeekRule, firstDayOfWeek))))
                            continue;
                        if ((weekDay != WeekDay.Every) &&
                            (!weekDays.Contains(calendar.GetDayOfWeek(dateTime))))
                            continue;

                        // We have a date match, check time.
                        foreach (int currentHour in hours)
                        {
                            if (currentHour < h) continue;
                            if (currentHour > h)
                                n = s = 0;
                            h = currentHour;
                            foreach (int currentMinute in minutes)
                            {
                                if (currentMinute < n) continue;
                                if (currentMinute > n)
                                    s = 0;
                                n = currentMinute;
                                foreach (int currentSecond in seconds)
                                {
                                    if (currentSecond < s) continue;
                                    return new DateTime(y, m, d, h, n, currentSecond, calendar);
                                }
                                n = s = 0;
                            }
                            h = n = s = 0;
                        }
                        d = 1;
                    }
                    d = 1;
                    h = n = s = 0;
                }
                y++;

                // Don't bother checking max year.
                if (y > 9998)
                    return DateTime.MaxValue;

                // Start next year
                m = d = 1;
                h = n = s = 0;
            } while (true);
        }
Exemplo n.º 34
0
 // Matching signature.
 public static First ASecondRFirst(Second first)
 { return new First(); }
Exemplo n.º 35
0
        public static Instant NextValid(
            this Instant instant,
            Month month = Month.Every,
            Week week = Week.Every,
            Day day = Day.Every,
            WeekDay weekDay = WeekDay.Every,
            Hour hour = Hour.Zeroth,
            Minute minute = Minute.Zeroth,
            Second second = Second.Zeroth,
            [CanBeNull] CalendarSystem calendarSystem = null,
            [CanBeNull] DateTimeZone timeZone = null)
        {
            // Never case, if any are set to never, we'll never get a valid date.
            if ((month == Month.Never) ||
                (week == Week.Never) ||
                (day == Day.Never) ||
                (weekDay == WeekDay.Never) ||
                (hour == Hour.Never) ||
                (minute == Minute.Never) ||
                (second == Second.Never))
                return Instant.MaxValue;

            if (calendarSystem == null)
                calendarSystem = CalendarSystem.Iso;
            if (timeZone == null)
                timeZone = DateTimeZone.Utc;
            Debug.Assert(calendarSystem != null);
            Debug.Assert(timeZone != null);

            // Move to next second.
            instant = instant.CeilingSecond();

            // Every second case.
            if ((month == Month.Every) &&
                (day == Day.Every) &&
                (weekDay == WeekDay.Every) &&
                (hour == Hour.Every) &&
                (minute == Minute.Every) &&
                (second == Second.Every) &&
                (week == Week.Every))
                return instant;

            // Get days and months.
            int[] days = Days(day).OrderBy(dy => dy).ToArray();
            int[] months = month.Months().ToArray();

            // Remove months where the first day isn't in the month.
            int firstDay = days.First();
            if (firstDay > 28)
            {
                // 2000 is a leap year, so February has 29 days.
                months = months.Where(mn => calendarSystem.GetDaysInMonth(2000, mn) >= firstDay).ToArray();
                if (months.Length < 1)
                    return Instant.MaxValue;
            }

            // Get zoned date time.
            ZonedDateTime zdt = new ZonedDateTime(instant, timeZone, calendarSystem);
            int y = zdt.Year;
            int m = zdt.Month;
            int d = zdt.Day;
            int h = zdt.Hour;
            int n = zdt.Minute;
            int s = zdt.Second;

            int[] weeks = week.Weeks().ToArray();

            IsoDayOfWeek[] weekDays = weekDay.WeekDays().ToArray();
            int[] hours = hour.Hours().OrderBy(i => i).ToArray();
            int[] minutes = minute.Minutes().OrderBy(i => i).ToArray();
            int[] seconds = second.Seconds().ToArray();

            do
            {
                foreach (int currentMonth in months)
                {
                    if (currentMonth < m)
                        continue;
                    if (currentMonth > m)
                    {
                        d = 1;
                        h = n = s = 0;
                    }
                    m = currentMonth;
                    foreach (int currentDay in days)
                    {
                        if (currentDay < d)
                            continue;
                        if (currentDay > d)
                            h = n = s = 0;
                        d = currentDay;

                        // Check day is valid for this month.
                        if (d > calendarSystem.GetDaysInMonth(y, m))
                            break;

                        // We have a potential day, check week and week day
                        zdt = timeZone.AtLeniently(new LocalDateTime(y, m, d, h, n, s, calendarSystem));
                        if ((week != Week.Every) &&
                            (!weeks.Contains(zdt.WeekOfWeekYear)))
                            continue;
                        if ((weekDay != WeekDay.Every) &&
                            (!weekDays.Contains(zdt.IsoDayOfWeek)))
                            continue;

                        // We have a date match, check time.
                        foreach (int currentHour in hours)
                        {
                            if (currentHour < h) continue;
                            if (currentHour > h)
                                n = s = 0;
                            h = currentHour;
                            foreach (int currentMinute in minutes)
                            {
                                if (currentMinute < n) continue;
                                if (currentMinute > n)
                                    s = 0;
                                n = currentMinute;
                                foreach (int currentSecond in seconds)
                                {
                                    if (currentSecond < s) continue;
                                    return
                                        timeZone.AtLeniently(
                                            new LocalDateTime(y, m, d, h, n, currentSecond, calendarSystem)).ToInstant();
                                }
                                n = s = 0;
                            }
                            h = n = s = 0;
                        }
                        d = 1;
                    }
                    d = 1;
                    h = n = s = 0;
                }
                y++;

                // Don't bother checking max year.
                if (y >= calendarSystem.MaxYear)
                    return Instant.MaxValue;

                // Start next year
                m = d = 1;
                h = n = s = 0;
            } while (true);
        }
Exemplo n.º 36
0
 // The return type is more derived.
 public static Second ASecondRSecond(Second second)
 { return new Second(); }
Exemplo n.º 37
0
Arquivo: c.cs Projeto: kevinarpe/kx
 void w(Second v)
 {
     w(v.i);
 }