File: default.txt

package info (click to toggle)
highlight.js 10.7.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,332 kB
  • sloc: javascript: 41,059; makefile: 157; python: 29; sh: 20
file content (56 lines) | stat: -rw-r--r-- 953 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
namespace LinkedList;

interface

uses
  System.Text;

type
  List<T> = public class
    where T is Object;
  private
    method AppendToString(aBuilder: StringBuilder);
  public
    constructor(aData: T);
    constructor(aData: T; aNext: List<T>);
    property Next: List<T>;
    property Data: T;

    method ToString: string; override;
  end;

implementation

constructor List<T>(aData: T);
begin
  Data := aData;
end;

constructor List<T>(aData: T; aNext: List<T>);
begin
  constructor(aData);
  Next := aNext;
end;

method List<T>.ToString: string;
begin
  with lBuilder := new StringBuilder do begin
    AppendToString(lBuilder);
    result := lBuilder.ToString();
  end;
end;

method List<T>.AppendToString(aBuilder: StringBuilder);
begin
  if assigned(Data) then
    aBuilder.Append(Data.ToString)
  else
    aBuilder.Append('nil');

  if assigned(Next) then begin
    aBuilder.Append(', ');
    Next.AppendToString(aBuilder);
  end;
end;

end.