• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Interval类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Interval的典型用法代码示例。如果您正苦于以下问题:C# Interval类的具体用法?C# Interval怎么用?C# Interval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Interval类属于命名空间,在下文中一共展示了Interval类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Intervals_Are_Constructable_From_Semitones

        public void Intervals_Are_Constructable_From_Semitones()
        {
            var i = new Interval(5);

            Assert.Equal(5, i.Semitones);
            Assert.Equal(IntervalDistance.PerfectFourth, i.Distance);
        }
开发者ID:deejaygraham,项目名称:tedesco,代码行数:7,代码来源:IntervalTests.cs


示例2: AxisAlignedBoxEnvironmentComponentOld

 /// <summary>
 /// Initializes a new instance of the AbstractEnvironmentComponent class.
 /// </summary>
 public AxisAlignedBoxEnvironmentComponentOld()
   : base(RS.AABoxEnvName, RS.AABoxEnvNickName,
       RS.AABoxEnvDescription, RS.icon_AABoxEnvironment, RS.AABoxEnvOldGuid)
 {
   Interval interval = new Interval(-RS.boxBoundsDefault, RS.boxBoundsDefault);
   box = new Box(Plane.WorldXY, interval, interval, interval);
 }
开发者ID:lxfschr,项目名称:Quelea,代码行数:10,代码来源:AxisAlignedBoxEnvironmentComponentOld.cs


示例3: Create

 /// <summary>
 /// Método estático encargado de la creación de objetos valor <see cref="IInterval"/>
 /// </summary>
 /// <remarks>
 /// Sin comentarios adicionales.
 /// </remarks>
 /// <param name="fromTime">
 /// Parámetro que indica la hora inicial del intervalo.
 /// </param>
 /// <param name="duration">
 /// Parámetro que indica la duración del intervalo.
 /// </param>
 /// <returns>
 /// Devuelve objeto de tipo <see cref="IInterval"/> creado.
 /// </returns>
 public static IInterval Create(DateTime? fromTime, TimeSpan duration)
 {
     // Creamos el objeto valor de periodo de vigencia.
     IInterval interval = new Interval(fromTime, duration);
     // Devolvemos el objeto valor creado.
     return interval;
 }
开发者ID:llenroc,项目名称:Inflexion2,代码行数:22,代码来源:IntervalFactory.cs


示例4: Insert

 public IList<Interval> Insert(IList<Interval> intervals, Interval newInterval) {
     IList<Interval> result = new List<Interval>();
     if(intervals.Count == 0){
         result.Add(newInterval);
         return result; 
     }
     bool first = true;
     for(int i=0; i<intervals.Count; i++){
         if(intervals[i].end<newInterval.start){
             result.Add(intervals[i]);
         }
         else if(intervals[i].start>newInterval.end){
             if(first){
                 result.Add(newInterval);
                 first = false;
             }
             result.Add(intervals[i]);
         }
         else{
             newInterval = new Interval(Math.Min(newInterval.start, intervals[i].start), Math.Max(newInterval.end, intervals[i].end));
         }
     }
         
         if(first){
             result.Add(newInterval);
             first = false;
         }
     return result;
 }
开发者ID:zhamx1995,项目名称:LeetCode,代码行数:29,代码来源:LC57-Insert_Interval.cs


示例5: CompareDecimals

        protected ComparerResult CompareDecimals(Interval interval, decimal actual)
        {
            if (interval.Contains(actual))
                return ComparerResult.Equality;

            return new ComparerResult(interval.ToString());
        }
开发者ID:zyh329,项目名称:nbi,代码行数:7,代码来源:NumericComparer.cs


示例6: Construct1

 public void Construct1()
 {
     var interval = new Interval();
     Assert.AreEqual(IntervalMode.Interpolate, interval.Mode);
     Assert.AreEqual(0, interval.Time);
     Assert.IsNull(interval.Value);
 }
开发者ID:Supermortal,项目名称:MusicianHelper,代码行数:7,代码来源:IntervalFixture.cs


示例7: GetIntersectionTest

        public void GetIntersectionTest()
        {
            var A = new Interval(0.0f, 5.0f);
            var B = new Interval(2.5f, 7.5f);
            var C = new Interval(6.0f, 10.0f);

            Interval Temp;

            Assert.IsTrue(A.GetIntersection(B, out Temp));
            Assert.AreEqual(new float[] { 2.5f, 5.0f }, Temp.ToArray());
            Assert.IsTrue(B.GetIntersection(A, out Temp));
            Assert.AreEqual(new float[] { 2.5f, 5.0f }, Temp.ToArray());

            Assert.IsTrue(A.GetIntersection(A, out Temp));
            Assert.AreEqual(A.ToArray(), Temp.ToArray());

            Assert.IsTrue(B.GetIntersection(C, out Temp));
            Assert.AreEqual(new float[] { 6.0f, 7.5f }, Temp.ToArray());
            Assert.IsTrue(C.GetIntersection(B, out Temp));
            Assert.AreEqual(new float[] { 6.0f, 7.5f }, Temp.ToArray());

            Assert.IsTrue(B.GetIntersection(B, out Temp));
            Assert.AreEqual(B.ToArray(), Temp.ToArray());

            A.GetIntersection(C, out Temp);
            C.GetIntersection(A, out Temp);

            Assert.IsFalse(A.GetIntersection(C, out Temp));
            Assert.IsFalse(C.GetIntersection(A, out Temp));
        }
开发者ID:sq,项目名称:Fracture,代码行数:30,代码来源:TupleTests.cs


示例8: ConstructorDefault

        public void ConstructorDefault()
        {
            IInterval<int> interval = new Interval<int>(5, 10);

            Assert.AreEqual(5, interval.LowerBound);
            Assert.AreEqual(10, interval.UpperBound);
        }
开发者ID:andipaetzold,项目名称:IntervalDictionary,代码行数:7,代码来源:IntervalTest.cs


示例9: ConstructorWrongOrder

        public void ConstructorWrongOrder()
        {
            IInterval<int> interval = new Interval<int>(10, 5);

            Assert.AreEqual(5, interval.LowerBound);
            Assert.AreEqual(10, interval.UpperBound);
        }
开发者ID:andipaetzold,项目名称:IntervalDictionary,代码行数:7,代码来源:IntervalTest.cs


示例10: CheckRoomTouch

    //If touching, returns unit vector pointing from A towards B
    //else returns 0,0,0
    public static Vector3 CheckRoomTouch(Bounds a, Bounds b, float minOverlap)
    {
        Interval a_x = new Interval(a.min.x, a.max.x);
        Interval a_y = new Interval(a.min.y, a.max.y);
        Interval a_z = new Interval(a.min.z, a.max.z);

        Interval b_x = new Interval(b.min.x, b.max.x);
        Interval b_y = new Interval(b.min.y, b.max.y);
        Interval b_z = new Interval(b.min.z, b.max.z);

        int roomTouchX = Interval.CheckTouching(a_x, b_x);
        int roomTouchY = Interval.CheckTouching(a_y, b_y);
        int roomTouchZ = Interval.CheckTouching(a_z, b_z);

        bool roomOverlapX = Interval.CheckOverlap(a_x, b_x, minOverlap);
        bool roomOverlapY = Interval.CheckOverlap(a_y, b_y, minOverlap);
        bool roomOverlapZ = Interval.CheckOverlap(a_z, b_z, minOverlap);

        //-.-- -.-- --..
        if(roomOverlapX && roomOverlapY) return Vector3.forward * roomTouchZ;
        if(roomOverlapZ && roomOverlapY) return Vector3.right * roomTouchX;
        if(roomOverlapX && roomOverlapZ) return Vector3.up * roomTouchY;

        return Vector3.zero;
    }
开发者ID:Vorren,项目名称:DunGen,代码行数:27,代码来源:RoomNode.cs


示例11: Construction_EqualStartAndEnd

 public void Construction_EqualStartAndEnd()
 {
     var interval = new Interval(SampleStart, SampleStart);
     Assert.AreEqual(SampleStart, interval.Start);
     Assert.AreEqual(SampleStart, interval.End);
     Assert.AreEqual(new Duration(0), interval.Duration);
 }
开发者ID:manirana007,项目名称:NodaTime,代码行数:7,代码来源:IntervalTest.cs


示例12: SurfaceEmitterType

 // Constructor with initial values.
 public SurfaceEmitterType(Surface srf)
 {
   Interval interval = new Interval(0,1);
   srf.SetDomain(0, interval);
   srf.SetDomain(1, interval);
   this.srf = srf;
 }
开发者ID:lxfschr,项目名称:Quelea,代码行数:8,代码来源:SurfaceEmitterType.cs


示例13: Test_AddInterval

        public void Test_AddInterval()
        {
            Interval[] empty = new Interval[] { };
            Interval[] result;
            SortingAlgorithms algo = new SortingAlgorithms();

            result = algo.AddInterval(empty,
                new Interval { start = 0, end = 2 }
                );
            Assert.AreEqual(1, result.Length);

            result = algo.AddInterval(result,
                new Interval { start = 3, end = 5 }
                );
            Assert.AreEqual(2, result.Length);

            result = algo.AddInterval(result,
                new Interval { start = 4, end = 6 }
                );
            Assert.AreEqual(2, result.Length);

            result = algo.AddInterval(result,
                new Interval { start = 1, end = 4 }
                );
            Assert.AreEqual(1, result.Length);
        }
开发者ID:sanjug01,项目名称:Tests,代码行数:26,代码来源:SortingUnitTest.cs


示例14: CrossingVehicleTimes

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="originalArrivingTime">Time when the vehicle originally planned to arrive at the intersection.</param>
 /// <param name="remainingDistance">Remaining distance of the vehicle to the intersection.</param>
 /// <param name="blockingTime">Time interval when the vehicle is going to block the intersection.</param>
 /// <param name="willWaitInFrontOfIntersection">Flag whether vehicle will wait befor intersection or proceed crossing it.</param>
 public CrossingVehicleTimes(double originalArrivingTime, double remainingDistance, Interval<double> blockingTime, bool willWaitInFrontOfIntersection)
 {
     this.originalArrivingTime = originalArrivingTime;
     this.remainingDistance = remainingDistance;
     this.blockingTime = blockingTime;
     this.willWaitInFrontOfIntersection = willWaitInFrontOfIntersection;
 }
开发者ID:chenysh,项目名称:CTS-Develop,代码行数:14,代码来源:Intersection.cs


示例15: Box

 /// <summary>
 /// Initializes a new Box that mimics a BoundingBox struct. 
 /// <para>The orientation plane of the Box is coincident with the 
 /// World XY plane.</para>
 /// </summary>
 /// <param name="bbox">BoundingBox to mimic.</param>
 public Box(BoundingBox bbox)
 {
   m_plane = Plane.WorldXY;
   m_dx = new Interval(bbox.m_min.m_x, bbox.m_max.m_x);
   m_dy = new Interval(bbox.m_min.m_y, bbox.m_max.m_y);
   m_dz = new Interval(bbox.m_min.m_z, bbox.m_max.m_z);
 }
开发者ID:austinlaw,项目名称:rhinocommon,代码行数:13,代码来源:opennurbs_box.cs


示例16: NonEmpty_NotContainedInterval__ReturnsFalse

        public void NonEmpty_NotContainedInterval__ReturnsFalse()
        {
            // (-10; 10)
            var a = new Interval(-10, false, 10, false);
            // (-100; -10)
            var b = new Interval(-100, false, -10, false);

            Assert.IsFalse(a.IntersectsWith(b));
            Assert.IsFalse(b.IntersectsWith(a));

            // [-10; 10)
            a = new Interval(-10, true, 10, false);
            // (-100; -10)
            b = new Interval(-100, false, -10, false);

            Assert.IsFalse(a.IntersectsWith(b));
            Assert.IsFalse(b.IntersectsWith(a));

            // (-10; 10)
            a = new Interval(-10, false, 10, false);
            // (-100; -10]
            b = new Interval(-100, false, -10, true);

            Assert.IsFalse(a.IntersectsWith(b));
            Assert.IsFalse(b.IntersectsWith(a));
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:26,代码来源:Interval.IntersectsWith.tests.cs


示例17: IntervalFrom

        public string IntervalFrom(string startNote, int interval, Interval direction)
        {
            int i;
            for( i = 0; i < scale.Length; i++ )
            {
                if( scale[i] == startNote )
                    break;
            }
            if (i >= scale.Length)
                throw new Exception("Invalid start note provided!!!");

            if (direction == Interval.Up) // Move right
            {
                interval--;
                return scale[(i + interval) % 7];
            }
            else // Move left
            {
                interval--;
                while (interval > 0)
                {
                    i--;
                    if (i < 0)
                        i = 6;
                    interval--;
                }
                return scale[i];
            }
        }
开发者ID:p473lr,项目名称:i-urge-mafia-gear,代码行数:29,代码来源:prob09.cs


示例18: Construct3

 public void Construct3()
 {
     var interval = new Interval(1, "0.2");
     Assert.AreEqual(IntervalMode.Interpolate, interval.Mode);
     Assert.AreEqual(1, interval.Time);
     Assert.AreEqual("0.2", interval.Value);
 }
开发者ID:Supermortal,项目名称:MusicianHelper,代码行数:7,代码来源:IntervalFixture.cs


示例19: Shall_the_result_be_correct_for_an_interval_that_has_been_built_in_reverse_order

 public int Shall_the_result_be_correct_for_an_interval_that_has_been_built_in_reverse_order(Interval<int> value)
 {
     var tree = CreateTree(TestEntries().OrderBy(interval => interval.Start).Reverse());
     return tree
         .Search(value)
         .Count();
 }
开发者ID:Venciity,项目名称:Interval-Tree,代码行数:7,代码来源:IntervalTreeSpecs.cs


示例20: GenerateCode

        /// <summary>
        /// Generates a code containing all intervals in a list of intervals of DateTimes.
        /// </summary>
        /// <param name="allIntervals"> The intervals to generate code for. </param>
        /// <param name="varName"> The variable name to use. </param>
        /// <returns> Returns the generated code for the data. </returns>
        public static string GenerateCode(Interval<DateTime>[] allIntervals, string varName)
        {
            var dateToStr = (Func<DateTime, string>)(d => d == default(DateTime) ? "default(DateTime)" : d.ToString("'new DateTime('yyyy', 'MM', 'dd', 'HH', 'mm', 'ss')'"));

            var str = string.Format(
                @"
            #region {0} = ...
            // the following snapshot was generated from a good result using the method GenerateCode(""{0}"")
            var {0} = new []
                {{",
                     varName) + string.Join(
                @",
            ",
                allIntervals.Select(
                    i => string.Format(
                        @"
                    // {5}
                    new Interval<DateTime>({0}, PointState.{1}, {2}, PointState.{3}, isPositive: {4})",
                        dateToStr(i.Start),
                        i.StartState,
                        dateToStr(i.End),
                        i.EndState,
                        i.IsPositive ? "true" : "false",
                        i))) + @"
                };
            #endregion
            ";

            return str;
        }
开发者ID:andrerpena,项目名称:Cerebello,代码行数:36,代码来源:ContinuousSetTests.cs



注:本文中的Interval类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IntervalUnit类代码示例发布时间:2022-05-24
下一篇:
C# IntersectionFlags类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap