liveBook · Manning

Generic interface

A generic interface is an interface declaration parameterized by one or more type parameters, defining a contract that can be specialized for particular types.

How 2 Manning books explain it

Go in Action, Second Edition

A generic interface is an interface parameterized by one or more type parameters whose implementations must match the resulting type-specific contract.

How it is used
Uses generic interfaces to give type-safe collection operations a reusable contract independent of a concrete data structure.
How deep it goes
Works through a linked-list implementation, indexed methods, and a function accepting the interface; also identifies assertion and method-set pitfalls.
Examples
Demonstrates List[T] through LinkedList[T], indexed operations, ReverseList, and an assertion from Collection[int] to *LinkedList[int].
What you can do after
Build it from scratch: implement a generic list contract and write functions that accept it without depending on its storage structure.

Read how Go in Action, Second Edition explains generic interface →

Fabulous Adventures in Data Structures and Algorithms

A generic interface is an interface parameterized by one or more type parameters.

How it is used
Uses parameterized contracts to raise randomness and type-specific operations above concrete implementations.
How deep it goes
Builds distribution and visitor interfaces with implementations, then traces overload resolution and dispatch; it stops short of broader interface design.
Examples
Uses Random-backed discrete uniform distributions and expression-tree visitors returning a generic result type.
What you can do after
Build it from scratch as a C# contract, extend it through inheritance, and diagnose visitor dispatch when static types hide subtype-specific methods.

Read how Fabulous Adventures in Data Structures and Algorithms explains generic interface →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.