Index: doc/theses/jiada_liang_MMath/relatedwork.tex
===================================================================
--- doc/theses/jiada_liang_MMath/relatedwork.tex	(revision 022bce0f1f94d12a2727b9b37e573e3848c466c9)
+++ doc/theses/jiada_liang_MMath/relatedwork.tex	(revision 924534ee4579863d136f5bac2f71e69bfaaf54d0)
@@ -7,13 +7,5 @@
 
 \section{Pascal}
-
-\lstnewenvironment{pascal}[1][]{% necessary
-\lstset{
-language=pascal,
-escapechar=\$,							% LaTeX escape in code
-moredelim=**[is][\color{red}]{@}{@},	% red highlighting @...@
-}% lstset
-\lstset{#1}% necessary
-}{}
+\lstnewenvironment{pascal}[1][]{\lstset{language=pascal,escapechar=\$,moredelim=**[is][\color{red}]{@}{@},}\lstset{#1}}{}
 
 Classic Pascal has the \lstinline[language=pascal]{const} declaration binding a name to a constant literal/expression.
@@ -42,14 +34,5 @@
 
 \section{Ada}
-
-\lstnewenvironment{ada}[1][]{% necessary
-\lstset{
-language=[2005]Ada,
-escapechar=\$,							% LaTeX escape in code
-moredelim=**[is][\color{red}]{@}{@},	% red highlighting @...@
-literate={'}{\ttfamily'\!}1				% remove '-' literate as comment
-}% lstset
-\lstset{#1}% necessary
-}{}
+\lstnewenvironment{ada}[1][]{\lstset{language=[2005]Ada,escapechar=\$,moredelim=**[is][\color{red}]{@}{@},literate={'}{\ttfamily'\!}1}\lstset{#1}}{}
 
 An Ada enumeration type is an ordered list of constants, called \Newterm{literals} (enumerators).
@@ -233,13 +216,5 @@
 \section{\CC}
 \label{s:C++RelatedWork}
-
-\lstnewenvironment{c++}[1][]{% necessary
-\lstset{
-language=[GNU]C++,
-escapechar=\$,							% LaTeX escape in code
-moredelim=**[is][\color{red}]{@}{@},	% red highlighting @...@
-}% lstset
-\lstset{#1}% necessary
-}{}
+\lstnewenvironment{c++}[1][]{\lstset{language=[GNU]C++,escapechar=\$,moredelim=**[is][\color{red}]{@}{@},}\lstset{#1}}{}
 
 \CC is largely backwards compatible with C, so it inherited C's enumerations.
@@ -303,5 +278,5 @@
 enum class srgb @: signed char@ { Red = -1, Green = 0, Blue = 1 };
 \end{c++}
-There is no implicit conversion from the \lstinline[language=c++]{enum class} type and to its type.
+There is no implicit conversion from the \lstinline[language=c++]{enum class} type and to its declared type.
 \begin{c++}
 rgb crgb = rgb::Red;
@@ -312,13 +287,6 @@
 
 \section{C\raisebox{-0.7ex}{\LARGE$^\sharp$}\xspace} % latex bug: cannot use \relsize{2} so use \LARGE
-
-\lstnewenvironment{csharp}[1][]{% necessary
-\lstset{
-language=[Sharp]C,
-escapechar=\$,							% LaTeX escape in code
-moredelim=**[is][\color{red}]{@}{@},	% red highlighting @...@
-}% lstset
-\lstset{#1}% necessary
-}{}
+\label{s:Csharp}
+\lstnewenvironment{csharp}[1][]{\lstset{language=[Sharp]C,escapechar=\$,moredelim=**[is][\color{red}]{@}{@},}\lstset{#1}}{}
 
 % https://www.tutorialsteacher.com/codeeditor?cid=cs-mk8Ojx
@@ -326,5 +294,5 @@
 \Csharp is a dynamically-typed programming-language with a scoped, integral enumeration-type similar to C/\CC enumeration.
 \begin{csharp}
-enum Weekday : byte { Monday, Tuesday, Wednesday, Thursday@ = 10@, Friday, Saturday, Sunday@,@ };
+enum Weekday : byte { Mon, Tue, Wed, Thu@ = 10@, Fri, Sat, Sun@,@ };
 \end{csharp}
 The default underlying type is @int@, with auto-incrementing, implicit/explicit initialization, terminator comma, and optional integral typing (default @int@)
@@ -332,8 +300,8 @@
 As well, there is an explicit bidirectional conversion between an enumeration and its integral type, and an implicit conversion to the enumerator label in display contexts.
 \begin{csharp}
-int day = (int)Weekday.Friday;			$\C{// day == 10}$
-Weekday weekday = (Weekdays)42;			$\C{// weekday == 42}$
-Console.WriteLine( Weekday.Friday );	$\C{// print Friday}$
-string mon = Weekday.Monday.ToString();
+int day = (int)Weekday.Fri;		$\C{// day == 10}$
+Weekday weekday = (Weekdays)42;		$\C{// weekday == 42, logically invalid}$
+Console.WriteLine( Weekday.Fri ); $\C{// print Fri}$
+string mon = Weekday.Mon.ToString(); $\C{// mon == "Mon"}$
 \end{csharp}
 
@@ -348,35 +316,85 @@
 \begin{csharp}
 @[Flags]@ public enum Weekday {
-	None = 0x0, Monday = 0x1, Tuesday = 0x2, Wednesday = 0x4,
-	Thursday = 0x8, Friday = 0x10, Saturday = 0x20, Sunday = 0x40,
-	Weekend = @Saturday | Sunday@,
-	Weekdays = @Monday | Tuesday | Wednesday | Thursday | Friday@
-}
-Weekday meetings = @Weekday.Monday | Weekday.Wednesday@; // 0x5
+	None = 0x0, Mon = 0x1, Tue = 0x2, Wed = 0x4,
+	Thu = 0x8, Fri = 0x10, Sat = 0x20, Sun = 0x40,
+	Weekend = @Sat | Sun@,
+	Weekdays = @Mon | Tue | Wed | Thu | Fri@
+}
+Weekday meetings = @Weekday.Mon | Weekday.Wed@; // 0x5
 \end{csharp}
 
-\Csharp supports an enumeration class to embed enumeration operations, where the enumerators are objects.
+\VRef[Figure]{CsharpFreeVersusClass} shows an enumeration with free routines for manipulation, and embedding the enumeration and operations into an enumeration class.
+The key observation is that an enumeration class is just a structuring mechanism without any additional semantics.
+
+% https://learn.microsoft.com/en-us/dotnet/api/system.enum?view=net-8.0
+
+\begin{figure}
+\centering
+\lstDeleteShortInline@
+\begin{tabular}{@{}l|l@{}}
+\multicolumn{1}{@{}c|}{non-object oriented} & \multicolumn{1}{c@{}}{object oriented} \\
+\hline
 \begin{csharp}
-public class PaymentType : Enumeration {
-    public static readonly PaymentType DebitCard = new PaymentType(0);
-    public static readonly PaymentType CreditCard = new PaymentType(1);
-    private PaymentType(int value, [CallerMemberName] string name = null) : base(value, name) { }
+public class Program {
+
+	enum Weekday {
+		Mon, Tue, Wed, Thu, Fri, Sat, Sun };
+
+
+	static bool isWeekday( Weekday wd ) {
+		return Weekday.Mon <= wd
+			&& wd <= Weekday.Fri;
+	}
+	static bool isWeekend( Weekday wd ) {
+		return Weekday.Sat <= wd
+			&& wd <= Weekday.Sun;
+	}
+
+
+	public static void Main() {
+		Weekday day = Weekday.Sat;
+
+		Console.WriteLine( isWeekday( day ) );
+		Console.WriteLine( isWeekend( day ) );
+	}
 }
 \end{csharp}
-Find a meaningful example and test it.
+&
+\begin{csharp}
+public class Program {
+	public @class@ WeekDay {
+		public enum Weekday {
+			Mon=-4, Tue=-3, Wed=-2, Thu=-1,
+			Fri=0, Sat=1, Sun=2 };
+		Weekday day;
+		public bool isWeekday() {
+			return day <= 0;
+
+		}
+		public bool isWeekend() {
+			return day > 0
+
+		}
+		public WeekDay( Weekday d ) { day = d; }
+	}
+	public static void Main() {
+		WeekDay cday = new
+				WeekDay( WeekDay.Weekday.Sat );
+		Console.WriteLine( cday.isWeekday() );
+		Console.WriteLine( cday.isWeekend() );
+	}
+}
+\end{csharp}
+\end{tabular}
+\lstMakeShortInline@
+\caption{\Csharp: Free Routine Versus Class Enumeration}
+\label{CsharpFreeVersusClass}
+\end{figure}
 
 
 \section{Golang}
-
-\lstnewenvironment{Go}[1][]{% necessary
-\lstset{
-language=Go,
-escapechar=\$,							% LaTeX escape in code
-moredelim=**[is][\color{red}]{@}{@},	% red highlighting @...@
-}% lstset
-\lstset{#1}% necessary
-}{}
-
-The Golang enumeration is similar to classic Pascal \lstinline[language=pascal]{const}, binding a name to a constant literal/expression.
+\lstnewenvironment{Go}[1][]{\lstset{language=Go,escapechar=\$,moredelim=**[is][\color{red}]{@}{@},}\lstset{#1}}{}
+
+Golang provides a mechanism similar to classic Pascal \lstinline[language=pascal]{const}, binding a name to a constant literal/expression (pseudo enumeration).
 \begin{Go}
 const ( R = 0; G; B )					$\C{// implicit: 0 0 0}$
@@ -401,373 +419,162 @@
 Auto-incrementing stops after an explicit initialization.
 \begin{Go}
-const ( Monday = iota; Tuesday; Wednesday; // 0, 1, 2
-	 @Thursday = 10@; Friday; Saturday; Sunday ) // 10, 10, 10, 10
+const ( Mon = iota; Tue; Wed; // 0, 1, 2
+	 @Thu = 10@; Fri; Sat; Sun ) // 10, 10, 10, 10
 \end{Go}
 Auto-incrementing can be restarted with an expression containing \emph{one} \lstinline[language=Go]{iota}.
 \begin{Go}
 const ( V1 = iota; V2; @V3 = 7;@ V4 = @iota@; V5 ) // 0 1 7 3 4
-const ( Monday = iota; Tuesday; Wednesday; // 0, 1, 2
-	 @Thursday = 10;@ Friday = @iota - Wednesday + Thursday - 1@; Saturday; Sunday ) // 10, 11, 12, 13
+const ( Mon = iota; Tue; Wed; // 0, 1, 2
+	 @Thu = 10;@ Fri = @iota - Wed + Thu - 1@; Sat; Sun ) // 10, 11, 12, 13
 \end{Go}
 Note, \lstinline[language=Go]{iota} is advanced for an explicitly initialized enumerator, like the underscore @_@ identifier.
 
+Basic switch and looping are possible.
+\begin{cquote}
+\lstDeleteShortInline@
+\setlength{\tabcolsep}{15pt}
+\begin{tabular}{@{}ll@{}}
+\begin{Go}
+day := Mon;
+switch day {
+  case Mon, Tue, Wed, Thu, Fri:
+	fmt.Println( "weekday" );
+  case Sat, Sun:
+	fmt.Println( "weekend" );
+}
+\end{Go}
+&
+\begin{Go}
+
+for i := Mon; i <= Sun; i += 1 {
+    fmt.Println( i )
+}
+
+
+
+\end{Go}
+\end{tabular}
+\lstMakeShortInline@
+\end{cquote}
+The loop prints the values from 0 to 13 because there is no actual enumeration.
+
 
 \section{Java}
-
-\lstnewenvironment{Java}[1][]{% necessary
-\lstset{
-language=Java,
-escapechar=\$,							% LaTeX escape in code
-moredelim=**[is][\color{red}]{`}{`},	% red highlighting @...@
-}% lstset
-\lstset{#1}% necessary
-}{}
-
-Here's a quick and simple example of an enum that defines the status of a pizza order; the order status can be ORDERED, READY or DELIVERED:
+\lstnewenvironment{Java}[1][]{\lstset{language=Java,escapechar=\$,moredelim=**[is][\color{red}]{!}{!},}\lstset{#1}}{}
+
+Every enumeration in Java is an enumeration class.
+For a basic enumeration
 \begin{Java}
-public enum PizzaStatus {
-    ORDERED,
-    READY, 
-    DELIVERED; 
-}
+enum Weekday { Mon, Tue, Wed, Thu, Fri, Sat, Sun };
+Weekday day = Weekday.Sat;
 \end{Java}
-Additionally, enums come with many useful methods that we would otherwise need to write if we were using traditional public static final constants.
-
-\paragraph{Custom Enum Methods}
-
-Now that we have a basic understanding of what enums are and how we can use them, we'll take our previous example to the next level by defining some extra API methods on the enum:
+the scoped enumerators are an ordered list of @final@ methods of type integer, ordered left to right starting at 0, increasing by 1.
+The value of an enumeration instance is restricted to the enumeration's enumerators.
+There is an implicit integer variable in the enumeration used to store the value of an enumeration instance.
+The position (ordinal) and label are accessible, and the value is the same as the position.
 \begin{Java}
-public class Pizza {
-    private PizzaStatus status;
-    public enum PizzaStatus {
-        ORDERED,
-        READY,
-        DELIVERED;
-    }
-    public boolean isDeliverable() {
-        if (getStatus() == PizzaStatus.READY) {
-            return true;
-        }
-        return false;
-    }
-    // Methods that set and get the status variable.
-}
+System.out.println( !day.ordinal()! + " " + !day! ); // 5 Sat
 \end{Java}
-
-\paragraph{Comparing Enum Types Using "==" Operator}
-
-Since enum types ensure that only one instance of the constants exist in the JVM, we can safely use the "==" operator to compare two variables, like we did in the above example.
-Furthermore, the "==" operator provides compile-time and run-time safety.
-
-First, we'll look at run-time safety in the following snippet, where we'll use the "==" operator to compare statuses.
-Either value can be null and we won't get a NullPointerException. Conversely, if we use the equals method, we will get a NullPointerException:
+There are no implicit conversions to/from an enumerator and its underlying type.
+
+To explicitly assign enumerator values, the enumeration must specify an explicit type in the enumeration class.
 \begin{Java}
-if(testPz.getStatus().equals(Pizza.PizzaStatus.DELIVERED)); 
-if(testPz.getStatus() == Pizza.PizzaStatus.DELIVERED); 
+enum Weekday {
+	Mon( -4 ), Tue( -3 ), Wed( -2 ), Thu( -1 ), Fri( 0 ), Sat( 1 ), Sun( 2 ); // must appear first
+	private int day;					$\C{// underlying enumeration type}$
+	private Weekday( int d ) { day = d; } $\C{// used to initialize enumerators and instances}$
+};
+Weekday day = Weekday.Sat;				$\C{// implicit constructor call}$
 \end{Java}
-As for compile-time safety, let's look at an example where we'll determine that an enum of a different type is equal by comparing it using the equals method.
-This is because the values of the enum and the getStatus method coincidentally are the same;
-however, logically the comparison should be false. We avoid this issue by using the "==" operator.
-
-The compiler will flag the comparison as an incompatibility error:
+The position, value, and label are accessible.
 \begin{Java}
-if(testPz.getStatus().equals(TestColor.GREEN));
-if(testPz.getStatus() == TestColor.GREEN);
+System.out.println( !day.ordinal()! + " " + !day.day! + " " + !day! );  // 5 1 Sat
 \end{Java}
-
-\paragraph{Using Enum Types in Switch Statements}
-
-We can use enum types in switch statements also:
+The constructor is private so only initialization or assignment can be used to set an enumeration, which ensures only corresponding enumerator values are allowed.
+
+Like \Csharp, \VRef[Figure]{f:JavaFreeVersusClass} shows the same example for an enumeration with free routines for manipulation, and embedding the enumeration and operations into an enumeration class.
+
+\begin{figure}
+\centering
+\lstDeleteShortInline@
+\begin{tabular}{@{}l|l@{}}
+\multicolumn{1}{@{}c|}{non-object oriented} & \multicolumn{1}{c@{}}{object oriented} \\
+\hline
 \begin{Java}
-public int getDeliveryTimeInDays() {
-    switch (status) {
-        case ORDERED: return 5;
-        case READY: return 2;
-        case DELIVERED: return 0;
-    }
-    return 0;
+public class test {
+
+	enum Weekday {
+		Mon, Tue, Wed, Thu, Fri, Sat, Sun };
+
+	static boolean isWeekday( Weekday wd ) {
+		return Weekday.Mon.ordinal() <= wd.ordinal()
+			&& wd.ordinal() <= Weekday.Fri.ordinal();
+	}
+	static boolean isWeekend( Weekday wd ) {
+		return Weekday.Sat.ordinal() <= wd.ordinal()
+			&& wd.ordinal() <= Weekday.Sun.ordinal();
+	}
+
+
+	public static void main( String[] args ) {
+		Weekday day = Weekday.Sat;
+		System.out.println( isWeekday( day ) );
+		System.out.println( isWeekend( day ) );
+	}
 }
 \end{Java}
-
-\paragraph{Fields, Methods and Constructors in Enums}
-
-We can define constructors, methods, and fields inside enum types, which makes them very powerful.
-
-Next, let's extend the example above by implementing the transition from one stage of a pizza order to another.
-We'll see how we can get rid of the if and switch statements used before:
+&
 \begin{Java}
-public class Pizza {
-    private PizzaStatus status;
-    public enum PizzaStatus {
-        ORDERED (5){
-            @Override
-            public boolean isOrdered() {
-                return true;
-            }
-        },
-        READY (2){
-            @Override
-            public boolean isReady() {
-                return true;
-            }
-        },
-        DELIVERED (0){
-            @Override
-            public boolean isDelivered() {
-                return true;
-            }
-        };
-
-        private int timeToDelivery;
-        public boolean isOrdered() {return false;}
-        public boolean isReady() {return false;}
-        public boolean isDelivered(){return false;}
-        public int getTimeToDelivery() {
-            return timeToDelivery;
-        }
-        PizzaStatus (int timeToDelivery) {
-            this.timeToDelivery = timeToDelivery;
-        }
-    }
-    public boolean isDeliverable() {
-        return this.status.isReady();
-    }
-    public void printTimeToDeliver() {
-        System.out.println("Time to delivery is " + 
-          this.getStatus().getTimeToDelivery());
-    }
-    // Methods that set and get the status variable.
+public class test {
+	public !enum! WeekDay {
+		Mon(-4), Tue(-3), Wed(-2), Thu(-1),
+			Fri(0), Sat(1), Sun(2);
+		private int day;
+		public boolean isWeekday() {
+			return day <= 0;
+
+		}
+		public boolean isWeekend() {
+			return day > 0;
+
+		}
+		private WeekDay( int d ) { day = d; }
+	}
+	public static void main( String[] args ) {
+		WeekDay day = WeekDay.Sat;
+		System.out.println( day.isWeekday() );
+		System.out.println( day.isWeekend() );
+	}
 }
 \end{Java}
-The test snippet below demonstrates how this works:
+\end{tabular}
+\lstMakeShortInline@
+\caption{Java: Free Routine Versus Class Enumeration}
+\label{f:JavaFreeVersusClass}
+\end{figure}
+
+An enumeration can appear in a @switch@ statement, but no ranges.
 \begin{Java}
-@Test
-public void givenPizaOrder_whenReady_thenDeliverable() {
-    Pizza testPz = new Pizza();
-    testPz.setStatus(Pizza.PizzaStatus.READY);
-    assertTrue(testPz.isDeliverable());
+switch ( day ) {
+  case Mon: case Tue: case Wed: case Thu: case Fri:
+	System.out.println( "weekday" );
+	break;
+  case Sat: case Sun:
+	System.out.println( "weekend" );
+	break;
 }
 \end{Java}
-
-\paragraph{EnumSet and EnumMap}
-
-\paragraph{EnumSet}
-
-The EnumSet is a specialized Set implementation that's meant to be used with Enum types.
-
-Compared to a HashSet, it's a very efficient and compact representation of a particular Set of Enum constants, owing to the internal Bit Vector Representation that's used.
-It also provides a type-safe alternative to traditional int-based "bit flags," allowing us to write concise code that's more readable and maintainable.
-
-The EnumSet is an abstract class that has two implementations, RegularEnumSet and JumboEnumSet, one of which is chosen depending on the number of constants in the enum at the time of instantiation.
-
-Therefore, it's a good idea to use this set whenever we want to work with a collection of enum constants in most scenarios (like subsetting, adding, removing, and bulk operations like containsAll and removeAll), and use Enum.values() if we just want to iterate over all possible constants.
-
-In the code snippet below, we can see how to use EnumSet to create a subset of constants:
+Looping over an enumeration is done using method @values@, which returns the array of enumerator values.
 \begin{Java}
-public class Pizza {
-    private static EnumSet<PizzaStatus> undeliveredPizzaStatuses =
-      EnumSet.of(PizzaStatus.ORDERED, PizzaStatus.READY);
-    private PizzaStatus status;
-    public enum PizzaStatus {
-        ...
-    }
-    public boolean isDeliverable() {
-        return this.status.isReady();
-    }
-    public void printTimeToDeliver() {
-        System.out.println("Time to delivery is " + 
-          this.getStatus().getTimeToDelivery() + " days");
-    }
-    public static List<Pizza> getAllUndeliveredPizzas(List<Pizza> input) {
-        return input.stream().filter(
-          (s) -> undeliveredPizzaStatuses.contains(s.getStatus()))
-            .collect(Collectors.toList());
-    }
-    public void deliver() { 
-        if (isDeliverable()) { 
-            PizzaDeliverySystemConfiguration.getInstance().getDeliveryStrategy()
-              .deliver(this); 
-            this.setStatus(PizzaStatus.DELIVERED); 
-        } 
-    }
-    // Methods that set and get the status variable.
+for ( Weekday iday : Weekday.values() ) {
+	System.out.println( iday.ordinal() + " " + iday + " " );
 }
 \end{Java}
 
-Executing the following test demonstrates the power of the EnumSet implementation of the Set interface:
-\begin{Java}
-@Test
-public void givenPizaOrders_whenRetrievingUnDeliveredPzs_thenCorrectlyRetrieved() {
-    List<Pizza> pzList = new ArrayList<>();
-    Pizza pz1 = new Pizza();
-    pz1.setStatus(Pizza.PizzaStatus.DELIVERED);
-
-    Pizza pz2 = new Pizza();
-    pz2.setStatus(Pizza.PizzaStatus.ORDERED);
-
-    Pizza pz3 = new Pizza();
-    pz3.setStatus(Pizza.PizzaStatus.ORDERED);
-
-    Pizza pz4 = new Pizza();
-    pz4.setStatus(Pizza.PizzaStatus.READY);
-
-    pzList.add(pz1);
-    pzList.add(pz2);
-    pzList.add(pz3);
-    pzList.add(pz4);
-
-    List<Pizza> undeliveredPzs = Pizza.getAllUndeliveredPizzas(pzList); 
-    assertTrue(undeliveredPzs.size() == 3); 
-}
-\end{Java}
-
-\paragraph{EnumMap}
-
-EnumMap is a specialized Map implementation meant to be used with enum constants as keys.
-Compared to its counterpart HashMap, it's an efficient and compact implementation that's internally represented as an array:
-\begin{Java}
-EnumMap<Pizza.PizzaStatus, Pizza> map;
-\end{Java}
-Let's look at an example of how we can use it in practice:
-\begin{Java}
-public static EnumMap<PizzaStatus, List<Pizza>> 
-  groupPizzaByStatus(List<Pizza> pizzaList) {
-    EnumMap<PizzaStatus, List<Pizza>> pzByStatus = 
-      new EnumMap<PizzaStatus, List<Pizza>>(PizzaStatus.class);
-    
-    for (Pizza pz : pizzaList) {
-        PizzaStatus status = pz.getStatus();
-        if (pzByStatus.containsKey(status)) {
-            pzByStatus.get(status).add(pz);
-        } else {
-            List<Pizza> newPzList = new ArrayList<Pizza>();
-            newPzList.add(pz);
-            pzByStatus.put(status, newPzList);
-        }
-    }
-    return pzByStatus;
-}
-\end{Java}
-Executing the following test demonstrates the power of the EnumMap implementation of the Map interface:
-\begin{Java}
-@Test
-public void givenPizaOrders_whenGroupByStatusCalled_thenCorrectlyGrouped() {
-    List<Pizza> pzList = new ArrayList<>();
-    Pizza pz1 = new Pizza();
-    pz1.setStatus(Pizza.PizzaStatus.DELIVERED);
-
-    Pizza pz2 = new Pizza();
-    pz2.setStatus(Pizza.PizzaStatus.ORDERED);
-
-    Pizza pz3 = new Pizza();
-    pz3.setStatus(Pizza.PizzaStatus.ORDERED);
-
-    Pizza pz4 = new Pizza();
-    pz4.setStatus(Pizza.PizzaStatus.READY);
-
-    pzList.add(pz1);
-    pzList.add(pz2);
-    pzList.add(pz3);
-    pzList.add(pz4);
-
-    EnumMap<Pizza.PizzaStatus,List<Pizza>> map = Pizza.groupPizzaByStatus(pzList);
-    assertTrue(map.get(Pizza.PizzaStatus.DELIVERED).size() == 1);
-    assertTrue(map.get(Pizza.PizzaStatus.ORDERED).size() == 2);
-    assertTrue(map.get(Pizza.PizzaStatus.READY).size() == 1);
-}
-\end{Java}
-
-\paragraph{Singleton Pattern}
-
-Normally, implementing a class using the Singleton pattern is quite non-trivial.
-Enums provide a quick and easy way of implementing singletons.
-
-In addition, since the enum class implements the Serializable interface under the hood, the class is guaranteed to be a singleton by the JVM.
-This is unlike the conventional implementation, where we have to ensure that no new instances are created during deserialization.
-
-In the code snippet below, we see how we can implement a singleton pattern:
-\begin{Java}
-public enum PizzaDeliverySystemConfiguration {
-    INSTANCE;
-    PizzaDeliverySystemConfiguration() {
-        // Initialization configuration which involves
-        // overriding defaults like delivery strategy
-    }
-
-    private PizzaDeliveryStrategy deliveryStrategy = PizzaDeliveryStrategy.NORMAL;
-
-    public static PizzaDeliverySystemConfiguration getInstance() {
-        return INSTANCE;
-    }
-
-    public PizzaDeliveryStrategy getDeliveryStrategy() {
-        return deliveryStrategy;
-    }
-}
-\end{Java}
-
-\paragraph{Strategy Pattern}
-
-Conventionally, the Strategy pattern is written by having an interface that is implemented by different classes.
-
-Adding a new strategy means adding a new implementation class.
-With enums, we can achieve this with less effort, and adding a new implementation means simply defining another instance with some implementation.
-
-The code snippet below shows how to implement the Strategy pattern:
-\begin{Java}
-public enum PizzaDeliveryStrategy {
-    EXPRESS {
-        @Override
-        public void deliver(Pizza pz) {
-            System.out.println("Pizza will be delivered in express mode");
-        }
-    },
-    NORMAL {
-        @Override
-        public void deliver(Pizza pz) {
-            System.out.println("Pizza will be delivered in normal mode");
-        }
-    };
-
-    public abstract void deliver(Pizza pz);
-}
-\end{Java}
-Then we add the following method to the Pizza class:
-\begin{Java}
-public void deliver() {
-    if (isDeliverable()) {
-        PizzaDeliverySystemConfiguration.getInstance().getDeliveryStrategy()
-          .deliver(this);
-        this.setStatus(PizzaStatus.DELIVERED);
-    }
-}
-
-@Test
-public void givenPizaOrder_whenDelivered_thenPizzaGetsDeliveredAndStatusChanges() {
-    Pizza pz = new Pizza();
-    pz.setStatus(Pizza.PizzaStatus.READY);
-    pz.deliver();
-    assertTrue(pz.getStatus() == Pizza.PizzaStatus.DELIVERED);
-}
-\end{Java}
-
-8. Java 8 and Enums
-
-We can rewrite the Pizza class in Java 8, and see how the methods getAllUndeliveredPizzas() and groupPizzaByStatus() become so concise with the use of lambdas and the Stream APIs:
-\begin{Java}
-public static List<Pizza> getAllUndeliveredPizzas(List<Pizza> input) {
-    return input.stream().filter(
-      (s) -> !deliveredPizzaStatuses.contains(s.getStatus()))
-        .collect(Collectors.toList());
-}
-
-public static EnumMap<PizzaStatus, List<Pizza>> 
-  groupPizzaByStatus(List<Pizza> pzList) {
-    EnumMap<PizzaStatus, List<Pizza>> map = pzList.stream().collect(
-      Collectors.groupingBy(Pizza::getStatus,
-      () -> new EnumMap<>(PizzaStatus.class), Collectors.toList()));
-    return map;
-}
-\end{Java}
+As well, Java provides an @EnumSet@ where the underlying type is an efficient set of bits, one per enumeration \see{\Csharp \lstinline{Flags}, \VRef{s:Csharp}}, providing (logical) operations on groups of enumerators.
+There is also a specialized version of @HashMap@ with enumerator keys, which has performance benefits.
+
+Enumeration inheritence is disallowed because an enumeration is @final@.
+
 
 
@@ -778,13 +585,5 @@
 
 \section{Swift}
-
-\lstnewenvironment{swift}[1][]{% necessary
-\lstset{
-language=Swift,
-escapechar=\$,							% LaTeX escape in code
-moredelim=**[is][\color{red}]{@}{@},	% red highlighting @...@
-}% lstset
-\lstset{#1}% necessary
-}{}
+\lstnewenvironment{swift}[1][]{\lstset{language=Swift,escapechar=\$,moredelim=**[is][\color{red}]{@}{@},}\lstset{#1}}{}
 
 Model custom types that define a list of possible values.
