Porting algorithms by Robert Sedgewick and Kevin Wayne in .NET.
Initial approach was to convert java archives with IKVM, then use ILSpy on the generated bytecode to produce cs files.
Those files would then have to be stripped off the unnecessary metadata.
Source: algs4.jar
.
Instead, it seems easier to port java files from the Princeton repo or the duplicated Brazilian one.
Below is the work for which porting was finished and unit tests passing.
- Fundamentals
- Collections
- Dynamic Connectivity
- Sorting
- Priority Queues
- Symbol tables. Currently in progress.
Files which have been generated by means of IKVM
and ILSpy
but not yet included in the project, or haven't been ported yet listed in the algorithms to do list.
IKVM outputs reside in the ante
folder and are not included in the project. The approach of refactoring IKVM produced code was dropped because most of the code looked bad, especially inner classes for linked lists, list nodes and enumerators, and even after trimming metadata, severe refactoring was needed.
Replaced tokens: using IKVM.Attributes;
, using java.lang;
, In.__<clinit>();
, [HideFromJava]
, using java.util;
, using ikvm.lang;
, Throwable.__<suppressFillInStackTrace>();
, using java.io;
, using ikvm.@internal;
, : java.lang.Object
, using IKVM.Runtime;
, using System.Runtime.CompilerServices;
, using System;
, [MethodImpl(MethodImplOptions.NoInlining)]
Replaced regex: \[LineNumberTable\([^\)]+\)\]
, ^.*(\[[^\]\(\)]+\([^\]\(\)]+\)[^\]\(\)]*\])$
with \/\/\1
, (\[Implements\(new string\[\]\r\n[^{]+{[^\]]+\])
, \[LineNumberTable\(new byte\[\]\r\n[^{]+{[^}]+\}\)
, [LineNumberTable(\d\d), Modifiers(Modifiers.Static | Modifiers.Synthetic)]