@@ -48,6 +48,12 @@ public readonly struct VBuffer<T>
48
48
/// <summary>
49
49
/// The logical length of the buffer.
50
50
/// </summary>
51
+ /// <remarks>
52
+ /// Note that if this vector <see cref="IsDense"/>, then this will be the same as the <see cref="ReadOnlySpan{T}.Length"/>
53
+ /// as returned from <see cref="GetValues"/>, since all values are explicitly represented in a dense representation. If
54
+ /// this is a sparse representation, then that <see cref="ReadOnlySpan{T}.Length"/> will be somewhat shorter, as this
55
+ /// field contains the number of both explicit and implicit entries.
56
+ /// </remarks>
51
57
public readonly int Length ;
52
58
53
59
/// <summary>
@@ -259,7 +265,7 @@ public void CopyTo(Span<T> dst)
259
265
/// </summary>
260
266
/// <param name="dst">The destination buffer. This <see cref="Span{T}.Length"/> must be at least <see cref="Length"/>
261
267
/// plus <paramref name="ivDst"/>.</param>
262
- /// <param name="ivDst">The starting index of <paramref name="dst"/> at which to start copying</param>
268
+ /// <param name="ivDst">The starting index of <paramref name="dst"/> at which to start copying. </param>
263
269
/// <param name="defaultValue">The value to fill in for the implicit sparse entries. This is a potential exception to
264
270
/// general expectation of sparse <see cref="VBuffer{T}"/> that the implicit sparse entries have the default value
265
271
/// of <typeparamref name="T"/>.</param>
@@ -316,7 +322,7 @@ public static void Copy(T[] src, int srcIndex, ref VBuffer<T> dst, int length)
316
322
/// <param name="all">If <see langword="true"/> all pairs, even those implicit values of a sparse representation,
317
323
/// will be returned, with the implicit values having the default value, as is appropriate. If left
318
324
/// <see langword="false"/> then only explicitly defined values are returned.</param>
319
- /// <returns></returns>
325
+ /// <returns>The index/value pairs. </returns>
320
326
public IEnumerable < KeyValuePair < int , T > > Items ( bool all = false )
321
327
{
322
328
return Items ( _values , _indices , Length , _count , all ) ;
@@ -335,9 +341,20 @@ public IEnumerable<T> DenseValues()
335
341
/// In the case of a sparse vector, it will try to find the entry with that index, and set <paramref name="dst"/>
336
342
/// to that stored value, or if no such value was found, assign it the default value.
337
343
/// </summary>
338
- /// <param name="slot">The slot index, which must be a non-negative number less than <see cref="Length"/>.
339
- /// If it is not in that </param>
340
- /// <param name="dst">The value stored </param>
344
+ /// <remarks>
345
+ /// In the case where <see cref="IsDense"/> is <see langword="true"/>, this will take constant time since it an
346
+ /// directly lookup. For sparse vectors, however, because it must perform a bisection seach on the indices to
347
+ /// find the appropriate value, that takes logarithmic time with respect to the number of explicitly represented
348
+ /// items, which is to say, the <see cref="ReadOnlySpan{Int32}.Length"/> of the return value of <see cref="GetIndices"/>.
349
+ ///
350
+ /// For that reason, a single completely isolated lookup, since constructing <see cref="ReadOnlySpan{T}"/> as
351
+ /// <see cref="GetValues"/> does is not a free operation, it may be more efficient to use this method. However
352
+ /// if one is doing a more involved computation involving many operations, it may be faster to utiltize
353
+ /// <see cref="GetValues"/> and, if appropriate, <see cref="GetIndices"/> directly.
354
+ /// </remarks>
355
+ /// <param name="slot">The slot index, which must be a non-negative number less than <see cref="Length"/>.</param>
356
+ /// <param name="dst">The value stored at that index, or if this is a sparse vector where this is an implicit
357
+ /// entry, the default value for <typeparamref name="T"/>.</param>
341
358
public void GetItemOrDefault ( int slot , ref T dst )
342
359
{
343
360
Contracts . CheckParam ( 0 <= slot && slot < Length , nameof ( slot ) ) ;
0 commit comments