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

C# Triplet类代码示例

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

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



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


示例16: HUSLPToRGB

 public static Triplet HUSLPToRGB(Triplet triple)
 {
     return LCHToRGB(HUSLPToLCH(triple));
 }
开发者ID:Ragzouken,项目名称:kooltool-rekindle,代码行数:4,代码来源:HUSL.cs


示例17: XYZToRGB

    public static Triplet XYZToRGB(Triplet triple)
    {
        double R = FromLinear(DotProduct(Mt[0], triple));
        double G = FromLinear(DotProduct(Mt[1], triple));
        double B = FromLinear(DotProduct(Mt[2], triple));

        triple.a = R;
        triple.b = G;
        triple.c = B;

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


示例18: CanToStringNullableTriplet

 public void CanToStringNullableTriplet()
 {
     var pair1 = new Triplet<int?>(1, null, 42);
     pair1.ToString().Should().Be("1, , 42");
 }
开发者ID:Trovarius,项目名称:simple,代码行数:5,代码来源:TuplesFixture.cs


示例19: PostAsyncRequestCallback

        protected virtual void PostAsyncRequestCallback(IAsyncResult asyncResult)
        {
            WebRequest request;
            byte[] post;
            object userState;
            Triplet<ICache, object, string> store;

            var state = asyncResult.AsyncState as Triplet<WebRequest, byte[], object>;
            if (state == null)
            {
                // No expiration specified
                if (asyncResult is Triplet<WebRequest, Triplet<byte[], ICache, string>, object>)
                {
                    var cacheScheme = (Triplet<WebRequest, Triplet<byte[], ICache, string>, object>)asyncResult;
                    var cache = cacheScheme.Second.Second;

                    var url = cacheScheme.First.RequestUri.ToString();
                    var prefix = cacheScheme.Second.Third;
                    var key = CreateCacheKey(prefix, url);

                    var fetch = cache.Get<Stream>(key);
                    if (fetch != null)
                    {
                        var args = new WebQueryResponseEventArgs(fetch);
                        OnQueryResponse(args);
                        return;
                    }

                    request = cacheScheme.First;
                    post = cacheScheme.Second.First;
                    userState = cacheScheme.Third;
                    store = new Triplet<ICache, object, string>
                    {
                        First = cache,
                        Second = null,
                        Third = prefix
                    };
                }
                else
                    // Absolute expiration specified
                    if (asyncResult is Triplet<WebRequest, Pair<byte[], Triplet<ICache, DateTime, string>>, object>)
                    {
                        var cacheScheme = (Triplet<WebRequest, Pair<byte[], Triplet<ICache, DateTime, string>>, object>)asyncResult;
                        var url = cacheScheme.First.RequestUri.ToString();
                        var cache = cacheScheme.Second.Second.First;
                        var expiry = cacheScheme.Second.Second.Second;

                        var prefix = cacheScheme.Second.Second.Third;
                        var key = CreateCacheKey(prefix, url);

                        var fetch = cache.Get<Stream>(key);
                        if (fetch != null)
                        {
                            var args = new WebQueryResponseEventArgs(fetch);
                            OnQueryResponse(args);
                            return;
                        }

                        request = cacheScheme.First;
                        post = cacheScheme.Second.First;
                        userState = cacheScheme.Third;
                        store = new Triplet<ICache, object, string>
                        {
                            First = cache,
                            Second = expiry,
                            Third = prefix
                        };
                    }
                    else
                        // Sliding expiration specified
                        if (asyncResult is Triplet<WebRequest, Pair<byte[], Triplet<ICache, TimeSpan, string>>, object>)
                        {
                            var cacheScheme = (Triplet<WebRequest, Pair<byte[], Triplet<ICache, TimeSpan, string>>, object>)asyncResult;
                            var url = cacheScheme.First.RequestUri.ToString();
                            var cache = cacheScheme.Second.Second.First;
                            var expiry = cacheScheme.Second.Second.Second;

                            var prefix = cacheScheme.Second.Second.Third;
                            var key = CreateCacheKey(prefix, url);

                            var fetch = cache.Get<Stream>(key);
                            if (fetch != null)
                            {
                                var args = new WebQueryResponseEventArgs(fetch);
                                OnQueryResponse(args);
                                return;
                            }

                            request = cacheScheme.First;
                            post = cacheScheme.Second.First;
                            userState = cacheScheme.Third;
                            store = new Triplet<ICache, object, string>
                            {
                                First = cache,
                                Second = expiry,
                                Third = prefix
                            };
                        }
                        else
                        {
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:graveyard,代码行数:101,代码来源:WebQuery.Async.cs


示例20: CompareToTest

        public void CompareToTest()
        {
            var A = new Triplet<float>(1.0f, 2.0f, 1.0f);
            var B = new Triplet<float>(2.0f, 1.0f, 1.0f);
            var C = new Triplet<float>(2.0f, 2.0f, 2.0f);

            Assert.AreEqual(0, A.CompareTo(A));
            Assert.AreEqual(-1, A.CompareTo(B));
            Assert.AreEqual(-1, B.CompareTo(C));
            Assert.AreEqual(-1, A.CompareTo(C));
            Assert.AreEqual(1, C.CompareTo(B));
            Assert.AreEqual(1, C.CompareTo(A));
            Assert.AreEqual(1, B.CompareTo(A));
        }
开发者ID:sq,项目名称:Fracture,代码行数:14,代码来源:TupleTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# TrivialHashtable类代码示例发布时间:2022-05-24
下一篇:
C# TripleStore类代码示例发布时间: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