# C1.LiveLinq.Indexing.Index-2

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="C1_LiveLinq_Indexing_Index_2" data-uid="C1.LiveLinq.Indexing.Index`2" class="text-break">Index&lt;T, TKey&gt; Class
</h1>
  <div class="markdown level0 summary"><p>Indexes a collection by an expression (typically, by a field), providing fast access to items having particular
values (or range of values) of that expression.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><a class="xref" href="C1.LiveLinq.Indexing.IndexDefinition-1.html">IndexDefinition</a>&lt;T&gt;</div>
    <div class="level2"><a class="xref" href="C1.LiveLinq.Indexing.Index-1.html">Index</a>&lt;T&gt;</div>
    <div class="level3"><span class="xref">Index&lt;T, TKey&gt;</span></div>
  </div>
  <div class="implements">
    <h5>Implements</h5>
    <div><a class="xref" href="C1.LiveLinq.Indexing.Search.IIndexScanner-2.html">IIndexScanner</a>&lt;T, TKey&gt;</div>
    <div><a class="xref" href="C1.LiveLinq.Indexing.Search.IIndexScanner-1.html">IIndexScanner</a>&lt;T&gt;</div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="C1.LiveLinq.Indexing.html">C1.LiveLinq.Indexing</a></h6>
  <h6><strong>Assembly</strong>: C1.LiveLinq.4.8.dll</h6>
  <h5 id="C1_LiveLinq_Indexing_Index_2_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public abstract class Index&lt;T, TKey&gt; : Index&lt;T&gt;, IIndexScanner&lt;T, TKey&gt;, IIndexScanner&lt;T&gt;</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public MustInherit Class Index(Of T, TKey)
    Inherits Index(Of T)
    Implements IIndexScanner(Of T, TKey), IIndexScanner(Of T)</code></pre>
  </div>
  <h5 class="typeParameters">Type Parameters</h5>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="parametername">T</span></td>
        <td><p>The type of the elements of the collection to index.</p>
</td>
      </tr>
      <tr>
        <td><span class="parametername">TKey</span></td>
        <td><p>The type of the index key.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h5 id="C1_LiveLinq_Indexing_Index_2_remarks"><strong>Remarks</strong></h5>
  <div class="markdown level0 remarks"><p>Indexes can be created and added to a
collection explicitly in code by calling <a class="xref" href="C1.LiveLinq.Indexing.IndexCollection-1.Add.html#C1_LiveLinq_Indexing_IndexCollection_1_Add__1_System_Linq_Expressions_Expression_System_Func__0___0___">IndexCollection.Add</a>, or their creation
can be enforced in LINQ queries by using the <a class="xref" href="C1.LiveLinq.Hints.Indexed.html#C1_LiveLinq_Hints_Indexed__1___0_C1_LiveLinq_IndexingHintAction_">Indexed</a> hint.</p>
<p>In LINQ queries, indexes are used for optimizing query performance if that is specified
with an <a class="xref" href="C1.LiveLinq.Hints.Indexed.html#C1_LiveLinq_Hints_Indexed__1___0_C1_LiveLinq_IndexingHintAction_">Indexed</a> hint. Usually, hints are not required, because LiveLinq can
automatically determine that an index can be used to speedup a query, but using hints 
helps to ensure this optimization.</p>
<p>Indexes can also be used programmatically in code, without LINQ syntax, by using the methods 
of the <a class="xref" href="C1.LiveLinq.Indexing.Search.IIndexScanner-2.html">IIndexScanner&lt;T, TKey&gt;</a> interface that is implemented by the <a class="xref" href="C1.LiveLinq.Indexing.Index-2.html">Index&lt;T, TKey&gt;</a> class.
For example, you can call such methods as <a class="xref" href="C1.LiveLinq.Indexing.Index-2.Find.html#C1_LiveLinq_Indexing_Index_2_Find__1_">Find</a> directly for an <a class="xref" href="C1.LiveLinq.Indexing.Index-2.html">Index&lt;T, TKey&gt;</a> object.</p>
<p>It must be kept in mind that every index you create
introduces a trade-off: it can dramatically speed up searches, but it consumes memory and adds some (usually, small)
overhead every time the indexed collection (or any of the items, its elements) is modified. This is why
indexes should generally be kept only while you need them for queries.
To delete an index, use <a class="xref" href="C1.LiveLinq.Indexing.IndexCollection-1.Remove.html#C1_LiveLinq_Indexing_IndexCollection_1_Remove_System_Linq_Expressions_LambdaExpression_">IndexCollection.Remove</a>.</p>
<p>An index can have subindexes, see <a class="xref" href="C1.LiveLinq.Indexing.Subindex-2.html">Subindex&lt;T, TKey&gt;</a>. Subindexes are optional,
not required for any indexing tasks, but can provide additional optimization and help minimize memory requirements when a collection is 
indexed by multiple keys. In presence of subindexes, an index is the root level of a tree of subindexes.</p>
</div>
  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_KeySelector" data-uid="C1.LiveLinq.Indexing.Index`2.KeySelector">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.KeySelector.html#C1_LiveLinq_Indexing_Index_2_KeySelector">KeySelector</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the expression used to obtain key value from an element of the indexed collection.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_All_C1_LiveLinq_Order_" data-uid="C1.LiveLinq.Indexing.Index`2.All(C1.LiveLinq.Order)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.All.html#C1_LiveLinq_Indexing_Index_2_All_C1_LiveLinq_Order_">All(Order)</a>
        </td>
        <td class="markdown level1 summary"><p>Gets all items in the indexed collection.</p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_ContainsKey__1_" data-uid="C1.LiveLinq.Indexing.Index`2.ContainsKey(`1)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.ContainsKey.html#C1_LiveLinq_Indexing_Index_2_ContainsKey__1_">ContainsKey(TKey)</a>
        </td>
        <td class="markdown level1 summary"><p>Returns a value that indicates whether the collection contains an item with the given key value.</p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_Find__1_" data-uid="C1.LiveLinq.Indexing.Index`2.Find(`1)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.Find.html#C1_LiveLinq_Indexing_Index_2_Find__1_">Find(TKey)</a>
        </td>
        <td class="markdown level1 summary"><p>Finds items with the specified key value.</p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_FindBetween__1_System_Boolean__1_System_Boolean_System_Func__1_System_Boolean__C1_LiveLinq_Order_" data-uid="C1.LiveLinq.Indexing.Index`2.FindBetween(`1,System.Boolean,`1,System.Boolean,System.Func{`1,System.Boolean},C1.LiveLinq.Order)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.FindBetween.html#C1_LiveLinq_Indexing_Index_2_FindBetween__1_System_Boolean__1_System_Boolean_System_Func__1_System_Boolean__C1_LiveLinq_Order_">FindBetween(TKey, bool, TKey, bool, Func&lt;TKey, bool&gt;, Order)</a>
        </td>
        <td class="markdown level1 summary"><p>Finds items with key values in the interval between the specified values.</p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_FindGreater__1_System_Boolean_System_Func__1_System_Boolean__C1_LiveLinq_Order_" data-uid="C1.LiveLinq.Indexing.Index`2.FindGreater(`1,System.Boolean,System.Func{`1,System.Boolean},C1.LiveLinq.Order)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.FindGreater.html#C1_LiveLinq_Indexing_Index_2_FindGreater__1_System_Boolean_System_Func__1_System_Boolean__C1_LiveLinq_Order_">FindGreater(TKey, bool, Func&lt;TKey, bool&gt;, Order)</a>
        </td>
        <td class="markdown level1 summary"><p>Finds items with keys greater than the specified value.</p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_FindKeys_System_Collections_Generic_IEnumerable__1__C1_LiveLinq_Order_" data-uid="C1.LiveLinq.Indexing.Index`2.FindKeys(System.Collections.Generic.IEnumerable{`1},C1.LiveLinq.Order)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.FindKeys.html#C1_LiveLinq_Indexing_Index_2_FindKeys_System_Collections_Generic_IEnumerable__1__C1_LiveLinq_Order_">FindKeys(IEnumerable&lt;TKey&gt;, Order)</a>
        </td>
        <td class="markdown level1 summary"><p>Finds items containing any of the specified key values.</p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_FindLess__1_System_Boolean_System_Func__1_System_Boolean__C1_LiveLinq_Order_" data-uid="C1.LiveLinq.Indexing.Index`2.FindLess(`1,System.Boolean,System.Func{`1,System.Boolean},C1.LiveLinq.Order)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.FindLess.html#C1_LiveLinq_Indexing_Index_2_FindLess__1_System_Boolean_System_Func__1_System_Boolean__C1_LiveLinq_Order_">FindLess(TKey, bool, Func&lt;TKey, bool&gt;, Order)</a>
        </td>
        <td class="markdown level1 summary"><p>Finds items with keys less than the specified value.</p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_FindSingle__1_" data-uid="C1.LiveLinq.Indexing.Index`2.FindSingle(`1)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.FindSingle.html#C1_LiveLinq_Indexing_Index_2_FindSingle__1_">FindSingle(TKey)</a>
        </td>
        <td class="markdown level1 summary"><p>Finds the only item with the specified key value and throws an exception if there is not exactly one item with that key value.</p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_GroupJoin__2_C1_LiveLinq_Indexing_Search_IIndexScanner___0__1__System_Func__0_System_Collections_Generic_IEnumerable___0____1__" data-uid="C1.LiveLinq.Indexing.Index`2.GroupJoin``2(C1.LiveLinq.Indexing.Search.IIndexScanner{``0,`1},System.Func{`0,System.Collections.Generic.IEnumerable{``0},``1})">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.GroupJoin.html#C1_LiveLinq_Indexing_Index_2_GroupJoin__2_C1_LiveLinq_Indexing_Search_IIndexScanner___0__1__System_Func__0_System_Collections_Generic_IEnumerable___0____1__">GroupJoin&lt;T2, TResult&gt;(IIndexScanner&lt;T2, TKey&gt;, Func&lt;T, IEnumerable&lt;T2&gt;, TResult&gt;)</a>
        </td>
        <td class="markdown level1 summary"><p>Correlates the items of this indexed collection with the items of another indexed collection and groups the results by the item of this collection.</p>
<p>Implements <a class="xref" href="C1.LiveLinq.Indexing.Search.IIndexScanner-2.GroupJoin.html#C1_LiveLinq_Indexing_Search_IIndexScanner_2_GroupJoin__2_C1_LiveLinq_Indexing_Search_IIndexScanner___0__1__System_Func__0_System_Collections_Generic_IEnumerable___0____1__">IIndexScanner(T,TKey).GroupJoin</a></p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_GroupJoin__2_System_Collections_Generic_IEnumerable___0__System_Func___0__1__System_Func_System_Collections_Generic_IEnumerable__0____0___1__" data-uid="C1.LiveLinq.Indexing.Index`2.GroupJoin``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,`1},System.Func{System.Collections.Generic.IEnumerable{`0},``0,``1})">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.GroupJoin.html#C1_LiveLinq_Indexing_Index_2_GroupJoin__2_System_Collections_Generic_IEnumerable___0__System_Func___0__1__System_Func_System_Collections_Generic_IEnumerable__0____0___1__">GroupJoin&lt;T2, TResult&gt;(IEnumerable&lt;T2&gt;, Func&lt;T2, TKey&gt;, Func&lt;IEnumerable&lt;T&gt;, T2, TResult&gt;)</a>
        </td>
        <td class="markdown level1 summary"><p>Correlates the items of this indexed collection with the items of another sequence and groups the results by the item of the second sequence.</p>
<p>Implements <a class="xref" href="C1.LiveLinq.Indexing.Search.IIndexScanner-2.GroupJoin.html#C1_LiveLinq_Indexing_Search_IIndexScanner_2_GroupJoin__2_System_Collections_Generic_IEnumerable___0__System_Func___0__1__System_Func_System_Collections_Generic_IEnumerable__0____0___1__">IIndexScanner(T,TKey).GroupJoin</a></p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_GroupJoin__2_System_Collections_Generic_IEnumerable___0__System_Func___0__1__System_Func__0_System_Collections_Generic_IEnumerable___0____1__" data-uid="C1.LiveLinq.Indexing.Index`2.GroupJoin``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,`1},System.Func{`0,System.Collections.Generic.IEnumerable{``0},``1})">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.GroupJoin.html#C1_LiveLinq_Indexing_Index_2_GroupJoin__2_System_Collections_Generic_IEnumerable___0__System_Func___0__1__System_Func__0_System_Collections_Generic_IEnumerable___0____1__">GroupJoin&lt;T2, TResult&gt;(IEnumerable&lt;T2&gt;, Func&lt;T2, TKey&gt;, Func&lt;T, IEnumerable&lt;T2&gt;, TResult&gt;)</a>
        </td>
        <td class="markdown level1 summary"><p>Correlates the items of this indexed collection with the items of another sequence and groups the results by the item of this collection.</p>
<p>Implements <a class="xref" href="C1.LiveLinq.Indexing.Search.IIndexScanner-2.GroupJoin.html#C1_LiveLinq_Indexing_Search_IIndexScanner_2_GroupJoin__2_System_Collections_Generic_IEnumerable___0__System_Func___0__1__System_Func__0_System_Collections_Generic_IEnumerable___0____1__">IIndexScanner(T,TKey).GroupJoin</a></p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_Join__2_C1_LiveLinq_Indexing_Search_IIndexScanner___0__1__System_Func__0___0___1__C1_LiveLinq_Indexing_Search_JoinOperator_" data-uid="C1.LiveLinq.Indexing.Index`2.Join``2(C1.LiveLinq.Indexing.Search.IIndexScanner{``0,`1},System.Func{`0,``0,``1},C1.LiveLinq.Indexing.Search.JoinOperator)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.Join.html#C1_LiveLinq_Indexing_Index_2_Join__2_C1_LiveLinq_Indexing_Search_IIndexScanner___0__1__System_Func__0___0___1__C1_LiveLinq_Indexing_Search_JoinOperator_">Join&lt;T2, TResult&gt;(IIndexScanner&lt;T2, TKey&gt;, Func&lt;T, T2, TResult&gt;, JoinOperator)</a>
        </td>
        <td class="markdown level1 summary"><p>Correlates the items of this indexed collection with the items of another indexed collection and returns the combined items with matching keys.</p>
<p>Implements <a class="xref" href="C1.LiveLinq.Indexing.Search.IIndexScanner-2.Join.html#C1_LiveLinq_Indexing_Search_IIndexScanner_2_Join__2_C1_LiveLinq_Indexing_Search_IIndexScanner___0__1__System_Func__0___0___1__C1_LiveLinq_Indexing_Search_JoinOperator_">IIndexScanner(T,TKey).Join</a></p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_Join__2_System_Collections_Generic_IEnumerable___0__System_Func___0__1__System_Func__0___0___1__C1_LiveLinq_Indexing_Search_JoinOperator_" data-uid="C1.LiveLinq.Indexing.Index`2.Join``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,`1},System.Func{`0,``0,``1},C1.LiveLinq.Indexing.Search.JoinOperator)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.Join.html#C1_LiveLinq_Indexing_Index_2_Join__2_System_Collections_Generic_IEnumerable___0__System_Func___0__1__System_Func__0___0___1__C1_LiveLinq_Indexing_Search_JoinOperator_">Join&lt;T2, TResult&gt;(IEnumerable&lt;T2&gt;, Func&lt;T2, TKey&gt;, Func&lt;T, T2, TResult&gt;, JoinOperator)</a>
        </td>
        <td class="markdown level1 summary"><p>Correlates the items of this indexed collection with the items of another sequence and returns the combined items with matching keys.</p>
<p>Implements <a class="xref" href="C1.LiveLinq.Indexing.Search.IIndexScanner-2.Join.html#C1_LiveLinq_Indexing_Search_IIndexScanner_2_Join__2_System_Collections_Generic_IEnumerable___0__System_Func___0__1__System_Func__0___0___1__C1_LiveLinq_Indexing_Search_JoinOperator_">IIndexScanner(T,TKey).Join</a></p>
</td>
      </tr>
      <tr>
        <td id="C1_LiveLinq_Indexing_Index_2_Keys_C1_LiveLinq_Order_" data-uid="C1.LiveLinq.Indexing.Index`2.Keys(C1.LiveLinq.Order)">
          <a class="xref" href="C1.LiveLinq.Indexing.Index-2.Keys.html#C1_LiveLinq_Indexing_Index_2_Keys_C1_LiveLinq_Order_">Keys(Order)</a>
        </td>
        <td class="markdown level1 summary"><p>Gets distinct key values in all items of the indexed collection.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="extensionmethods">Extension Methods</h3>
  <div>
      <a class="xref" href="C1.LiveLinq.Hints.Indexed.html#C1_LiveLinq_Hints_Indexed__1___0_">Hints.Indexed&lt;T&gt;(T)</a>
  </div>
  <div>
      <a class="xref" href="C1.LiveLinq.Hints.Indexed.html#C1_LiveLinq_Hints_Indexed__1___0_C1_LiveLinq_IndexingHintAction_">Hints.Indexed&lt;T&gt;(T, IndexingHintAction)</a>
  </div>

</div>
