当前位置: 首页>>代码示例>>C#>>正文


C# Triplet类代码示例

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


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

示例1: HUSLPToLCH

    public static Triplet HUSLPToLCH(Triplet triple)
    {
        double H = triple.a;
        double S = triple.b;
        double L = triple.c;

        if (L > 99.9999999)
        {
            triple.a = 100;
            triple.b = 0;
            triple.c = H;

            return triple;
        }

        if (L < 0.00000001)
        {
            triple.a = 0;
            triple.b = 0;
            triple.c = H;

            return triple;
        }

        double max = MaxSafeChromaForL(L);
        double C = max / 100 * S;

        triple.a = L;
        triple.b = C;
        triple.c = H;

        return triple;
    }
开发者ID:Ragzouken,项目名称:kooltool-rekindle,代码行数:33,代码来源:HUSL.cs

示例2: CanCompareTwoNullableDifferentTypeTriplets

        public void CanCompareTwoNullableDifferentTypeTriplets()
        {
            var triplet1 = new Triplet<string, int?, Type>("1", 2, typeof(Console));
            var triplet2 = new Triplet<string, int?, Type>("1", 2, typeof(Console));
            var triplet3 = new Triplet<string, int?, Type>("1", null, typeof(Console));

            triplet2.Should().Be(triplet1);
            triplet3.Should().Not.Be(triplet1);
        }
开发者ID:Trovarius,项目名称:simple,代码行数:9,代码来源:TuplesFixture.cs

示例3: CanCompareTwoNullableTriplets

        public void CanCompareTwoNullableTriplets()
        {
            var pair1 = new Triplet<int?>(1, null, 42);
            var pair2 = new Triplet<int?>(1, null, 42);
            var pair3 = new Triplet<int?>(null, 2, null);

            pair2.Should().Be(pair1);
            pair3.Should().Not.Be(pair1);
        }
开发者ID:Trovarius,项目名称:simple,代码行数:9,代码来源:TuplesFixture.cs

示例4: unroll

		public static LNode unroll(LNode var, LNode cases, LNode body, IMessageSink sink)
		{
			if (!cases.Calls(S.Tuple) && !cases.Calls(S.Braces))
				return Reject(sink, cases, "unroll: the right-hand side of 'in' should be a tuple");

			// Maps identifiers => replacements. The integer counts how many times replacement occurred.
			var replacements = InternalList<Triplet<Symbol, LNode, int>>.Empty;
			if (var.IsId && !var.HasPAttrs()) {
				replacements.Add(Pair.Create(var.Name, (LNode)LNode.Missing, 0));
			} else {
				var vars = var.Args;
				if ((var.Calls(S.Tuple) || var.Calls(S.Braces)) && vars.All(a => a.IsId && !a.HasPAttrs())) {
					replacements = new Triplet<Symbol, LNode, int>[vars.Count].AsInternalList();
					for (int i = 0; i < vars.Count; i++) {
						replacements.InternalArray[i].A = vars[i].Name;
						
						// Check for duplicate names
						for (int j = 0; j < i; j++)
							if (replacements[i].A == replacements[j].A && replacements[i].A.Name != "_")
								sink.Write(Severity.Error, vars[i], "unroll: duplicate name in the left-hand tuple"); // non-fatal
					}
				} else
					return Reject(sink, cases, "unroll: the left-hand side of 'in' should be a simple identifier or a tuple of simple identifiers.");
			}

			UnrollCtx ctx = new UnrollCtx { Replacements = replacements };
			WList<LNode> output = new WList<LNode>();
			int iteration = 0;
			foreach (LNode replacement in cases.Args)
			{
				iteration++;
				bool tuple = replacement.Calls(S.Tuple) || replacement.Calls(S.Braces);
				int count = tuple ? replacement.ArgCount : 1;
				if (replacements.Count != count)
				{
					sink.Write(Severity.Error, replacement, "unroll, iteration {0}: Expected {1} replacement items, got {2}", iteration, replacements.Count, count);
					if (count < replacements.Count)
						continue; // too few
				}
				for (int i = 0; i < replacements.Count; i++)
					replacements.InternalArray[i].B = tuple ? replacement.Args[i] : replacement;

				if (body.Calls(S.Braces)) {
					foreach (LNode stmt in body.Args)
						output.Add(ctx.Replace(stmt).Value);
				} else
					output.Add(ctx.Replace(body).Value);
			}

			foreach (var r in replacements)
				if (r.C == 0 && !r.A.Name.StartsWith("_"))
					sink.Write(Severity.Warning, var, "Replacement variable '{0}' was never used", r.A);
			
			return body.With(S.Splice, output.ToVList());
		}
开发者ID:jonathanvdc,项目名称:Loyc,代码行数:55,代码来源:UnrollMacro.cs

示例5: AddSensingProbabilityButton_Click

        private void AddSensingProbabilityButton_Click(object sender, RoutedEventArgs e)
        {
            TextBox stateTextBox = FindTextBoxSibling(sender, "SensedStateTextBox");
            TextBox sensedPerceptionTextBox = FindTextBoxSibling(sender, "SensedPerceptionTextBox");
            TextBox probabilityTextBox = FindTextBoxSibling(sender, "SensingProbabilityTextBox");
            Triplet<String, String, Double> tuple = new Triplet<string, string, double>(stateTextBox.Text, sensedPerceptionTextBox.Text, Double.Parse(probabilityTextBox.Text));

            ModelItem.Properties["SensingProbabilities"].Collection.Add(tuple);
            stateTextBox.Clear();
            sensedPerceptionTextBox.Clear();
            probabilityTextBox.Clear();
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:12,代码来源:HMMFactoryDesigner.xaml.cs

示例6: Where

 public static IEnumerable<Triplet> Where(int maxFactor, int minFactor = 1, int sum = 0)
 {
     var triplets = new List<Triplet>();
     for (int i = minFactor; i < maxFactor - 1; i++)
     {
         for (int j = i + 1; j < maxFactor; j++)
         {
             for (int k = j + 1; k <= maxFactor; k++)
             {
                 var triplet = new Triplet(i, j, k);
                 if (ShouldIncludeTriplet(sum, triplet))
                     triplets.Add(triplet);
             }
         }
     }
     return triplets;
 }
开发者ID:brandonscott,项目名称:xcsharp,代码行数:17,代码来源:Example.cs

示例7: ParentChildRelationships

        static Triplet[] ParentChildRelationships(int a, int b, int c)
        {
            var p1 = new Triplet();
            p1.a = a - 2 * b + 2 * c;
            p1.b = 2 * a - b + 2 * c;
            p1.c = 2 * a - 2 * b + 3 * c;

            var p2 = new Triplet();
            p2.a = a + 2 * b + 2 * c;
            p2.b = 2 * a + b + 2 * c;
            p2.c = 2 * a + 2 * b + 3 * c;

            var p3 = new Triplet();
            p3.a = -a + 2 * b + 2 * c;
            p3.b = -2 * a + b + 2 * c;
            p3.c = -2 * a + 2 * b + 3 * c;

            return new Triplet[3] { p1, p2, p3 };
        }
开发者ID:jtg2078,项目名称:ProjectEuler,代码行数:19,代码来源:Program.cs

示例8: Where

    public static List<Triplet> Where(int maxFactor, int minFactor = 1)
    {
        List<Triplet> triplets = new List<Triplet>();

        for (int a = minFactor; a <= maxFactor; a++)
        {
            for (int b = a; b <= maxFactor; b++)
            {
                for (int c = b; c <= maxFactor; c++)
                {
                    Triplet triplet = new Triplet(a, b, c);
                    if (triplet.IsPythagorean())
                    {
                        triplets.Add(triplet);
                    };
                }
            }
        }
        return triplets;
    }
开发者ID:Zero-man,项目名称:exercism,代码行数:20,代码来源:PythagoreanTriplet.cs

示例9: ExecuteGetOrDeleteAsync

        protected virtual WebQueryAsyncResult ExecuteGetOrDeleteAsync(GetDeleteHeadOptions method, string url, object userState)
        {
            WebResponse = null;

            var request = BuildGetDeleteHeadOptionsWebRequest(method, url);
            var state = new Triplet<WebRequest, object, object>
                            {
                                First = request,
                                Second = null,
                                Third = userState
                            };

            var args = new WebQueryRequestEventArgs(url);
            OnQueryRequest(args);

            var inner = request.BeginGetResponse(GetAsyncResponseCallback, state);
            RegisterAbortTimer(request, inner); 
            var result = new WebQueryAsyncResult { InnerResult = inner };
            return result;
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:20,代码来源:WebQuery.Async.cs

示例10: OnPostStreamQueryRequest

        private Triplet<WebRequest, byte[], Pair<TimeSpan, int>> OnPostStreamQueryRequest(string url, WebRequest request, byte[] content, TimeSpan duration, int resultCount)
        {
            var state = new Triplet<WebRequest, byte[], Pair<TimeSpan, int>>
            {
                First = request,
                Second = content,
                Third = new Pair<TimeSpan, int>
                {
                    First = duration,
                    Second = resultCount
                }
            };

            var args = new WebQueryRequestEventArgs(url);
            OnQueryRequest(args);
            return state;
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:17,代码来源:WebQuery.Async.cs

示例11: ExecutePostOrPutAsync

        protected virtual WebQueryAsyncResult ExecutePostOrPutAsync(PostOrPut method,
                                                                    string url,
                                                                    IEnumerable<HttpPostParameter> parameters,
                                                                    object userState)
        {
            WebResponse = null;

            string boundary;
            var request = BuildMultiPartFormRequest(method, url, parameters, out boundary);

            var state = new Triplet<WebRequest, Pair<string, IEnumerable<HttpPostParameter>>, object>
                            {
                                First = request,
                                Second = new Pair<string, IEnumerable<HttpPostParameter>>
                                             {
                                                 First = boundary,
                                                 Second = parameters
                                             },
                                Third = userState
                            };
            var args = new WebQueryRequestEventArgs(url);

            OnQueryRequest(args);
            
            var inner = request.BeginGetRequestStream(PostAsyncRequestCallbackMultiPart, state);
            var result = new WebQueryAsyncResult { InnerResult = inner };
            RegisterAbortTimer(request, result);
            return result;
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:29,代码来源:WebQuery.Async.cs

示例12: PlayersTurn

 public PlayersTurn(Triplet _tripltetToTurn, bool _isClockwise)
 {
     TripltetToTurn = _tripltetToTurn;
     IsClockwise = _isClockwise;
 }
开发者ID:leandrolimasjrp,项目名称:my-project-hxapp,代码行数:5,代码来源:PlayersTurn.cs

示例13: establishRemoteConnection

    private static void establishRemoteConnection(String strToIP, Triplet triplet, byte[] msg, int offset, int size)
    {
        Console.WriteLine("Boxit::establishRemoteConnection ENTER");

                                byte[] byteIP = {127, 0, 0, 1};
                                IPAddress ipAddress = new IPAddress(byteIP);
                                IPEndPoint ipEnd = new IPEndPoint (ipAddress, triplet.portNo);

                                Console.WriteLine("Boxit::establishRemoteConnection endPoint created");
                                //AsyncCallback beginConnectCallBack = new AsyncCallback(beginConnectCallBackFor_establishRemoteConnection);

                                Console.WriteLine("Boxit::establishRemoteConnection before calling Connect");
                                triplet.sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                                try
            {
                  triplet.sock.Connect(ipEnd);
            }
            catch (SocketException se)
            {
                Console.WriteLine("Connect SOCKET EXCEPTION!! ERROR CODE = {0}",se.ErrorCode);
                if(se.ErrorCode == 10056)
                    Console.WriteLine("10056: socket is already connected");
        //
                //throw se;

            }
                                Console.WriteLine("Boxit::establishRemoteConnection connect DONE");

                                SocketFlags f = new SocketFlags();
                                triplet.sock.BeginSend(msg, 0, msg.Length, f, null, null);
    }
开发者ID:ratulmukh,项目名称:tashjik,代码行数:32,代码来源:Boxit.cs

示例14: GetImageSize

    /// <summary>
    /// Returns the Triplet{width, height, radius} with coordinates containnig respictive width and height of the image
    /// </summary>
    /// <returns>Triplet{width, height, radius}</returns>
    public static Triplet<int, int, int> GetImageSize(ImageType type)
    {
        GlobalData gd = new GlobalData("");
        int thumbnailSize = gd.GetIntegerValue("ThumbnailSize");
        int previewSize = gd.GetIntegerValue("PreviewSize");
        int thumbnailSizeSmall = gd.GetIntegerValue("ThumbnailSizeSmall");//110 gd.GetIntegerValue("ThumbnailSize");
        int thumbnailSizeSlideShow = gd.GetIntegerValue("ThumbnailSizeSlideShow");

        Triplet<int, int, int> dimensions;
        switch (type)
        {
            case ImageType.UserPreview: //1
                dimensions = new Triplet<int, int, int>(previewSize, previewSize, 0);
                break;
            case ImageType.UserThumbnail: //2
                dimensions = new Triplet<int, int, int>(thumbnailSize, thumbnailSize, 0);
                break;
            case ImageType.EventPreview: //3
                dimensions = new Triplet<int, int, int>(previewSize, previewSize, 0);
                break;
            case ImageType.EventThumbnail: //4
                dimensions = new Triplet<int, int, int>(thumbnailSize, thumbnailSize, 0);
                break;
            case ImageType.EventCommentPreview: //5
                dimensions = new Triplet<int, int, int>(previewSize, previewSize, 0);
                break;
            case ImageType.EventCommentThumbnail: //6
                dimensions = new Triplet<int, int, int>(thumbnailSize, thumbnailSize, 0);
                break;
            case ImageType.EventPicturePreview: //7
                dimensions = new Triplet<int, int, int>(previewSize, previewSize, 0);
                break;
            case ImageType.EventPictureThumbnail: //8
                dimensions = new Triplet<int, int, int>(thumbnailSize, thumbnailSize, 0);
                break;
            case ImageType.EventPictureThumbnailSmall: //13
                dimensions = new Triplet<int, int, int>(thumbnailSizeSmall, thumbnailSizeSmall, 0);
                break;
            case ImageType.EventPictureThumbnailSlideShow: //14
                dimensions = new Triplet<int, int, int>(thumbnailSizeSlideShow, thumbnailSizeSlideShow, 0);
                break;
            default:
                dimensions = new Triplet<int, int, int>();
                break;
        }
        return dimensions;
    }
开发者ID:sedogo,项目名称:site,代码行数:51,代码来源:ImageHelper.cs

示例15: ValidTriplet

 private static bool ValidTriplet(Triplet triplet, int sum)
 {
     return triplet.IsPythagorean() && (triplet.Sum() == sum || sum == 0);
 }
开发者ID:cameronjkelley,项目名称:exercism,代码行数:4,代码来源:PythagoreanTriplet.cs


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