using System.Collections;
using System.Collections.Generic;
var lst = new Liste<string>();
foreach (var s in new[] { "J'aime", "mon", "prof" })
lst.Accepter(s => Console.Write($"{s} "));
string plusseLongue = null;
if (plusseLongue == null || s.Length > plusseLongue.Length)
Console.WriteLine($"Chaîne la plusse longue : {plusseLongue}");
string plusseCourte = null;
if (plusseCourte == null || s.Length < plusseCourte.Length)
Console.WriteLine($"Chaîne la plusse courte : {plusseCourte}");
class ListeVideException : Exception { }
class Liste<T> : IEnumerable<T> where T : IEquatable<T>
public IEnumerator<T> GetEnumerator() =>
IEnumerator IEnumerable.GetEnumerator() =>
class Énumérateur : IEnumerator<T>
public Énumérateur(Noeud tête)
public void Reset() => throw new NotImplementedException();
public void Dispose() { }
public T Current => Cur.Valeur;
object IEnumerator.Current => Cur.Valeur;
public T Valeur { get; init; }
public Noeud Succ { get; set; } = null;
Noeud Tête { get; set; } = null;
Noeud Queue { get; set; } = null;
public bool EstVide => Tête == null;
public void AjouterDébut(T val)
var noeud = new Noeud(val);
public void AjouterFin(T val)
public void SupprimerDébut()
throw new ListeVideException();
EstVide? throw new ListeVideException(): Tête.Valeur;
throw new ListeVideException();
public Liste<T> Dupliquer()
for (Noeud p = Tête; p != null; p = p.Succ)
dest.AjouterFin(p.Valeur);
public int Count { get; private set; } = 0;
public void ForEach(Action<T> f)
public bool Contains(T elem)
public Liste(IEnumerable<T> objs)
public void Accepter(Action<T> f)