'From Squeak3.8alpha of ''17 July 2004'' [latest update: #6315] on 14 October 2004 at 11:05:17 am'! "Change Set: LinkedListAddAfter-md Date: 14 October 2004 Author: Marcus Denker This adds LinkedList>>add:after: and a test"! TestCase subclass: #LinkedListTest instanceVariableNames: 'nextLink n' classVariableNames: '' poolDictionaries: '' category: 'Collections-Sequenceable-Tests'! !LinkedList methodsFor: 'adding' stamp: 'md 10/13/2004 13:50'! add: link after: otherLink "Add otherLink after link in the list. Answer aLink." | savedLink | savedLink := otherLink nextLink. otherLink nextLink: link. link nextLink: savedLink. ^link.! ! !LinkedListTest methodsFor: 'acessing' stamp: 'md 10/14/2004 10:47'! n ^n! ! !LinkedListTest methodsFor: 'acessing' stamp: 'md 10/14/2004 10:47'! n: number n := number. ! ! !LinkedListTest methodsFor: 'acessing' stamp: 'md 10/14/2004 10:46'! nextLink ^nextLink! ! !LinkedListTest methodsFor: 'acessing' stamp: 'md 10/14/2004 10:46'! nextLink: aLink nextLink := aLink! ! !LinkedListTest methodsFor: 'testing' stamp: 'MD 10/14/2004 11:05'! testAddAfter | l first | l := LinkedList new. first := self class new n: 1. l add: first. l add: (self class new n: 3). self assert: (l collect:[:e | e n]) asArray = #(1 3). l add: (self class new n: 2) after: first. self assert: (l collect:[:e | e n]) asArray = #(1 2 3).! ! !LinkedListTest methodsFor: 'testing' stamp: 'MD 10/14/2004 11:04'! testAddAfterLast | l last | l := LinkedList new. last := self class new n: 2. l add: (self class new n: 1). l add: last. self assert: (l collect:[:e | e n]) asArray = #(1 2). l add: (self class new n: 3) after: last. self assert: (l collect:[:e | e n]) asArray = #(1 2 3).! !