'From Cuis 1.0 of 6 March 2009 [latest update: #5989] on 9 March 2009 at 10:26:21 am'!

!Object methodsFor: 'copying' stamp: 'jmv 3/9/2009 10:22'!
veryDeepCopy
	"Do a complete tree copy using a dictionary.  An object in the tree twice is only copied once.  All references to the object in the copy of the tree will point to the new copy."

	| copier new |
	copier _ DeepCopier new initialize: 4096 "self initialDeepCopierSize".
	new _ self veryDeepCopyWith: copier.
	copier references associationsDo: [:assoc | 
		assoc value veryDeepFixupWith: copier].
	copier fixDependents.
	^ new! !

!Object methodsFor: 'nil' stamp: 'tk 4/16/1998 15:54'!
notify: aString 
	"Create and schedule a Notifier with the argument as the message in 
	order to request confirmation before a process can proceed."

	Debugger
		openContext: thisContext
		label: 'Notifier'
		contents: aString

	"nil notify: 'confirmation message'"! !


!Interval methodsFor: 'nil' stamp: 'di 11/10/97 12:22'!
includes: aNumber
	^ aNumber between: self first and: self last! !


!MIDIScore methodsFor: 'nil' stamp: 'di 10/21/2000 13:41'!
durationInTicks
	
	| t |
	t _ 0.
	tracks, {ambientTrack} do:
		[:track |
		track do:
			[:n | (n isNoteEvent)
				ifTrue: [t _ t max: n endTime]
				ifFalse: [t _ t max: n time]]].
	^ t
! !


!Number methodsFor: 'truncation and round off' stamp: 'yo 8/22/2008 16:48'!
fractionPart

	^ self asFloat fractionPart.
! !

!Number methodsFor: 'truncation and round off' stamp: 'yo 8/22/2008 16:48'!
integerPart
	^ self asFloat integerPart! !

!Number methodsFor: 'nil'!
raisedTo: aNumber 
	"Answer the receiver raised to aNumber."
	(aNumber isInteger)
		ifTrue: ["Do the special case of integer power"
				^self raisedToInteger: aNumber].
	aNumber = 0 ifTrue: [^1].		"Special case of exponent=0"
	aNumber = 1 ifTrue: [^self].		"Special case of exponent=1"
	^(aNumber * self ln) exp		"Otherwise raise it to the power using logarithms"! !

!Number methodsFor: 'mathematical'!
raisedToInteger: anInteger 
	"Answer the receiver raised to the power anInteger where the argument 
	must be a kind of Integer. This is a special case of raisedTo:."
	(anInteger isInteger)
		ifFalse: [^self error: 'raisedToInteger: only works for integral arguments'].
	anInteger = 0 ifTrue: [^1].
	anInteger = 1 ifTrue: [^self].
	anInteger > 1 
		ifTrue: [^(self * self raisedToInteger: anInteger // 2)
					* (self raisedToInteger: anInteger \\ 2)].
	^(self raisedToInteger: anInteger negated) reciprocal! !

!Number methodsFor: 'mathematical'!
reciprocal
	"Answer 1 divided by the receiver. Create an error notification if the 
	receiver is 0."

	self = 0
		ifTrue: [^self error: 'zero has no reciprocal']
		ifFalse: [^1 / self]! !


!Float methodsFor: 'mathematical'!
reciprocal
	^ 1.0 / self! !

!Float methodsFor: 'mathematical'!
sqrt
	"Answer the square root of the receiver.
	 Optional. See Object documentation whatIsAPrimitive."

	| exp guess eps delta |
	<primitive: 55>

	"Newton-Raphson"
	self <= 0.0 ifTrue: [
		self = 0.0
			ifTrue: [^ 0.0]
			ifFalse: [^ self error: 'sqrt is invalid for x < 0']].

	"first guess is half the exponent"
	exp _ self exponent // 2.
	guess _ self timesTwoPower: (0 - exp).

	"get eps value"
	eps _ guess * Epsilon.
	eps _ eps * eps.
	delta _ (self - (guess * guess)) / (guess * 2.0).
	[(delta * delta) > eps] whileTrue: [
		guess _ guess + delta.
		delta _ (self - (guess * guess)) / (guess * 2.0)].
	^ guess! !


!Fraction methodsFor: 'mathematical'!
reciprocal 
	"Refer to the comment in Number|reciprocal."

	numerator = 0 ifTrue: [self error: '0 has no reciprocal'].
	numerator = 1 ifTrue: [^denominator].
	numerator = -1 ifTrue: [^denominator negated].
	^Fraction numerator: denominator denominator: numerator! !


!Integer methodsFor: 'mathematical'!
// aNumber

	| q |
	aNumber = 0 ifTrue: [^self error: 'division by 0'].
	self = 0 ifTrue: [^0].
	q _ self quo: aNumber 
	"Refer to the comment in Number|//.".
	(q negative
		ifTrue: [q * aNumber ~= self]
		ifFalse: [q = 0 and: [self negative ~= aNumber negative]])
		ifTrue: [^q - 1"Truncate towards minus infinity"]
		ifFalse: [^q]! !


!OldHandMorph methodsFor: 'cursor' stamp: 'jmv 3/9/2009 10:09'!
cursorBounds

	temporaryCursor == nil
		ifTrue: [^ self position extent: NormalCursor extent]
		ifFalse: [^ self position + temporaryCursorOffset
								extent: temporaryCursor extent]! !


!Random methodsFor: 'nil' stamp: 'sma 5/12/2000 12:25'!
nextInt: anInteger
	"Answer a random integer in the interval [1, anInteger]."

	^ (self next * anInteger) truncated + 1! !


!SelectorBrowser methodsFor: 'nil' stamp: 'tk 5/6/1999 13:57'!
selectorMenu: aMenu
	^ aMenu labels: 'senders
implementors
copy selector to clipboard'
	lines: #()
	selections: #(senders implementors copyName)! !

SystemVersion class removeSelector: #setVersion!
SoundRecorder removeSelector: #isActive!
Integer class removeSelector: #one!
Integer removeSelector: #adaptToScaledDecimal:andSend:!
Integer removeSelector: #asScaledDecimal:!
Integer removeSelector: #printOn:base:showRadix:!
Integer removeSelector: #printPaddedWith:to:!
Integer removeSelector: #printPaddedWith:to:base:!
Integer removeSelector: #printStringRadix:!
Fraction class removeSelector: #one!
Fraction removeSelector: #adaptToScaledDecimal:andSend:!
Float class removeSelector: #one!
Float removeSelector: #adaptToScaledDecimal:andSend:!
Float removeSelector: #printPaddedWith:to:!
Number removeSelector: #adaptToScaledDecimal:andSend:!
Number removeSelector: #asFloatD!
Number removeSelector: #asFloatE!
Number removeSelector: #asFloatQ!
Number removeSelector: #asScaledDecimal:!
Model removeSelector: #veryDeepInner:!
MethodDictionary removeSelector: #do:!
FileDirectory removeSelector: #filesContaining:caseSensitive:!
FileDirectory removeSelector: #withAllFilesDo:andDirectoriesDo:!
Character class removeSelector: #codePoint:!
Character removeSelector: #codePoint!
Boolean removeSelector: #==>!
BlockContext removeSelector: #argumentCount!
Object removeSelector: #initialDeepCopierSize!
Smalltalk removeClassNamed: #RuleDate!
Smalltalk removeClassNamed: #RuleIndexDate!
Smalltalk removeClassNamed: #RuleSelectionCodeDate!
Smalltalk removeClassNamed: #ScaledDecimal!
