Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm guessing you are using a <code>Collection</code> of <code>KeyValuePair&lt;long, long&gt;</code> and that these two values are the x and y coordinates. For settings only value, I would recommend setting the other value to <code>-1</code>. This would be fine as you are not using <code>ulong</code>.</p> <p>Say these assumptions are correct and your collection is called <code>Points</code>.</p> <p>I would recommend using <code>linq</code> where y is your desired value:</p> <pre><code> Points.Select(p =&gt; p.Value).ToArray(); </code></pre> <p>or</p> <pre><code> Points.Select(p =&gt; p.Value).ToList(); </code></pre> <p>This will return a new array or list, depending, containing all of the y values. If you needed the x values you would use <code>Key</code> instead of <code>Value</code>. As you are only grabbing the value, it doesn't matter if the <code>Key</code> (x) is null, -1 or whatever.</p> <p>Taking this a step further, you could select all of the y values, where x meets a condition. I'm guessing this would be useful to you based on your saying </p> <blockquote> <p>only one axes values (y) for some points</p> </blockquote> <p>Again, where <code>Points</code> is the collection of <code>KeyValuePair&lt;long, long&gt;</code></p> <pre><code>int example = 5; Points.Where(p =&gt; p.Key == example).Select(p =&gt; p.Value).ToArray(); </code></pre> <p>or</p> <pre><code>Points.Where(p =&gt; p.Key != -1).Select(p =&gt; p.Value).ToArray(); </code></pre> <p>Continuation(See first comment):</p> <pre><code>Queue&lt;KeyValuePair&lt;long, long&gt;&gt; queue = new Queue&lt;KeyValuePair&lt;long, long&gt;&gt;(); KeyValuePair&lt;string, Queue&lt;KeyValuePair&lt;long, long&gt;&gt;&gt; pair = new KeyValuePair&lt;string, Queue&lt;KeyValuePair&lt;long, long&gt;&gt;&gt;("test", queue); pair.Value.Enqueue(new KeyValuePair&lt;long, long&gt;(-1, 5)); </code></pre> <p>I get no problem with this code, works fine.</p> <p>Possible other solution:</p> <p>Instead of having a <code>KeyValuePair&lt;long,long&gt;</code>. You could have <code>KeyValuePair&lt;long,long[]&gt;</code>. The <code>long[]</code> would store one or two values based on your need. The only limitation would be that you would have to assume that if the array is of length one, then it is only storing <code>y</code> and not <code>x</code>, otherwise if the array is of size 2, then assume it is in an {x, y} format.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload