My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
57
58
59
60
61
62
63
64
65
package com.sibirjak.asperform.collectiontests.examples.linkedlist {

public class LinkedListRaw {

public var first : Node;
public var last : Node;
public var size : uint;

public function addFirst(data : *) : void {
if (first) {
first.left = new Node(data);
first.left.right = first;
first = first.left;
} else {
first = last = new Node(data);
}
size++;
}

public function addLast(data : *) : void {
if (last) {
last.right = new Node(data);
last.right.left = last;
last = last.right;
} else {
first = last = new Node(data);
}
size++;
}

public function removeFirst() : void {
if (!first) return;

if (first.right) {
first = first.right;
first.left = null;
} else {
first = last = null;
}
size--;
}

public function removeLast() : void {
if (!last) return;

if (last.left) {
last = last.left;
last.right = null;
} else {
first = last = null;
}
size--;
}
}
}

internal class Node {
public var left : Node;
public var right : Node;
public var data : *;

public function Node(theData : *) {
data = theData;
}
}

Change log

r6 by jens.struwe on Apr 28, 2010   Diff
[DEV] Linked list example, Array and
Dictionary tests added.
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1164 bytes, 65 lines
Powered by Google Project Hosting