The C# docs have a page on indexers, which appears to use "indexer" to refer to the construct required to enable instances of a class to be accessed via square bracket notation.
Indexers allow instances of a class or struct to be indexed just like arrays.
// Define the indexer to allow client code to use [] notation.
public T this[int i]
{
get { return arr[i]; }
set { arr[i] = value; }
}
On the other hand, the pandas docs use "indexer" in several ways. Firstly, DataFrame
attributes such as ix
, loc
and iloc
that exist to enable different kinds of indexing operation on DataFrame
instances are called indexers themselves. For example, see the first line in the docs for ix
:
A primarily label-location based indexer, with integer position fallback.
Yet "indexer" is also used elsewhere to refer to the argument passed within square brackets:
.iloc
is strictly integer position based (from 0 to length-1 of the axis), will raiseIndexError
if an indexer is requested and it is out-of-bounds, exceptslice
indexers which allow out-of-bounds indexing.
Both of these uses are also found in the source code, so this is consistent.
The Wikipedia page for indexers does not help distinguish between all of the examples above, although the page in general does seem biased to the usage in the C# docs.
In object-oriented programming, an indexer allows instances of a particular class or struct to be indexed just like arrays.
What is an indexer? Are all of these usages correct? What am I missing?