Skip to content

Instantly share code, notes, and snippets.

View mfaella's full-sized avatar

Marco Faella mfaella

View GitHub Profile
@mfaella
mfaella / L.java
Last active April 18, 2021 10:24
A list-like class exposing its length as part of its type (see https://medium.com/@marfaella/counting-with-java-generics-ad33c5ef434d)
import java.util.*;
/**
* A linked list that exposes its length as part of its type.
*
* @author Marco Faella
* @version 1.0
*/
public class L<T,N extends L<T,?>> implements Iterable<T> {
private T item;