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.
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 express reusable, type-specific collection contracts.
- How deep it goes
- Implements collection and indexed-list methods, then examines type assertions and constraint method sets.
- Examples
- Demonstrates a generic List and LinkedList, an integer list, and a list-reversal function.
- What you can do after
- Build it from scratch by defining a parameterized interface and implementing its methods on a generic data 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
- genericshas part · Generics are programming-language constructs parameterized by types, allowing a definition to apply to multiple concrete types.
- interfacekind of · An interface is a contract or boundary that specifies the operations, members, or data shape a type or component exposes, without prescribing its complete implementation.
- type assertionused by · A type assertion is a language construct that states or checks that a value has a specified type, with runtime behavior depending on the language.
- probability distributionimplements · A probability distribution is a mathematical description assigning probabilities or probability densities to the possible values or outcomes of a random variable, with total probability one.
- visitor design patternused by · The Visitor pattern separates operations on an object structure into visitor objects, allowing operations to be added without changing the structure’s element classes.
- covariant generic interfaceincludes · A covariant generic interface is a generic interface whose type parameter can vary from a derived reference type to a base reference type under type-safe restrictions.
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.

