From VisualWorks®, 7.5 of April 16, 2007 on November 13, 2007 at 10:35:43 am (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] <name>Squeak</name> <environment>Smalltalk</environment> <private>false</private> <imports> private Smalltalk.* </imports> <category>Squeak</category> <attributes> <package>Squeak-Namespace</package> </attributes> <class> <name>FillInTheBlank</name> <environment>Squeak</environment> <super>UI.Dialog</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <comment> Squeak.FillInTheBlank
Same functionality as the Dialog class, just subclass it with no method. I represent a prompt for string input from the user. The user is asked to type in and edit a string. The resulting string is supplied as the argument to a client-supplied action block.
</comment> <class> <name>CrLfFileStream</name> <environment>Smalltalk</environment> <super>OS.ExternalReadWriteStream</super> <private>false</private> none <imports></imports> <category>Seaside-Squeak-Extensions</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <class> <name>Color</name> <environment>Squeak</environment> <super>Graphics.ColorValue</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <comment> Squeak.Color
Squeak class similar to ColorValue
</comment> <class> <name>LimitedWriteStream</name> <environment>Smalltalk</environment> <super>Core.WriteStream</super> <private>false</private> none limit limitBlock <imports></imports> <category>Seaside-Squeak-Extensions</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <comment> LimitedWriteStream
A LimitedWriteStream is a specialized WriteStream that has a maximum size of the collection it streams over. When this limit is reached a special limitBlock is executed. This can for example be used to "bail out" of lengthy streaming operations before they have finished. For a simple example take a look at the universal Object printString. The message SequenceableCollection class streamContents:limitedTo: creates a LimitedWriteStream. In this case it prevents very large (or possibly recursive) object structures to "overdo" their textual representation.
</comment> <class> <name>CharacterSet</name> <environment>Squeak</environment> <super>Core.Collection</super> <private>false</private> none map <imports></imports> <category>Collections-Text</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <comment> Squeak.CharacterSet
A set of characters. Lookups for inclusion are very fast.
</comment> <class> <name>DateAndTime</name> <environment>Squeak</environment> <super>Core.Magnitude</super> <private>false</private> none seconds offset jdn nanos <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>TimeStamp</name> <environment>Squeak</environment> <super>Squeak.DateAndTime</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>MIMEDocument</name> <environment>Squeak</environment> <super>Core.Object</super> <private>false</private> none contentType content url <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Network</package> </attributes> </class> <comment> Squeak.MIMEDocument
Very minimal implementation of the Squeak class. a MIME object, along with its type and the URL it was found at (if any). My implementation is not complete and I should only be used by the Seaside framework. Instance Variables: content <Collection> Actual contents of the document, String or ByteArray contentType <String> exemple : text/html url <String> The URL where the document was found
</comment> <class> <name>ChronologyConstants</name> <environment>Squeak</environment> <super>Core.Object</super> <private>false</private> none seconds offset jdn nanos <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>TimeZone</name> <environment>Squeak</environment> <super>Core.Object</super> <private>false</private> none offset abbreviation name <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>StandardScriptingSystem</name> <environment>Squeak</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Scripting</package> </attributes> </class> <comment> Squeak.StandardScriptingSystem
IMinimal implementation of the Squeak class
</comment> <class> <name>Deprecation</name> <environment>Squeak</environment> <super>Core.Warning</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <comment> Squeak.Deprecation
This Warning is signalled by methods which are deprecated. The use of Object>>#deprecatedExplanation: aString and Object>>#deprecated: aBlock explanation: aString is recommended. Idiom: Imagine I want to deprecate the message #foo. foo ^ 'foo' I can replace it with: foo self deprecatedExplanation: 'The method #foo was not good. Use Bar>>newFoo instead.' ^ 'foo' Or, for certain cases such as when #foo implements a primitive, #foo can be renamed to #fooDeprecated. fooDeprecated ^ <primitive> foo ^ self deprecated: [self fooDeprecated] explanation: 'The method #foo was not good. Use Bar>>newFoo instead.'
</comment> <class> <name>Heap</name> <environment>Squeak</environment> <super>Core.SequenceableCollection</super> <private>false</private> none array tally sortBlock <imports></imports> <category>Collections-Sequenceable</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <comment> Squeak.Heap
Class Heap implements a special data structure commonly referred to as 'heap'. Heaps are more efficient than SortedCollections if: a) Elements are only removed at the beginning b) Elements are added with arbitrary sort order. The sort time for a heap is O(n log n) in all cases. Instance variables: array <Array> the data repository tally <Integer> the number of elements in the heap sortBlock <Block|nil> a two-argument block defining the sort order, or nil in which case the default sort order is [:element1 :element2| element1 <= element2]
</comment> <class> <name>Stopwatch</name> <environment>Squeak</environment> <super>Core.Object</super> <private>false</private> none timespans state <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>Browser</name> <environment>Squeak</environment> <super>Core.Object</super> <private>false</private> none systemCategories classNames methodCategories selectors contents displayOption isClassComment namespace <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-ClassBrowser</package> </attributes> </class> <comment> Squeak.Browser
Very minimal re-implementation of the Squeak browser.
</comment> <class> <name>FileDirectory</name> <environment>Smalltalk</environment> <super>Core.Object</super> <private>false</private> none path <imports></imports> <category>Seaside-Squeak-Extensions</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <comment> FileDirectory
A FileDirectory represents a folder or directory in the underlying platform's file system. It carries a fully-qualified path name for the directory it represents, and can enumerate the files and directories within that directory. A FileDirectory can be thought of as a Dictionary whose keys are the local names of files in that directory, and whose values are directory "entries". Each entry is an array of five items: <name> <creationTime> <modificationTime> <dirFlag> <fileSize> The times are given in seconds, and can be converted to a time and date via Time>dateAndTimeFromSeconds:. See the comment in lookupEntry:... which provides primitive access to this information. Instance Variables: path <Filename> A Filename object representing the path of the file directory
</comment> <class> <name>WeakSet</name> <environment>Squeak</environment> <super>Core.WeakDictionary</super> <private>false</private> objects <imports></imports> <category>Seaside/VW Support</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <comment> Squeak.WeakSet
Very minimal implementation of a Squeak class that has no equivalent in VisualWorks I am a Set whose values are stored in a WeakArray. My implementation is not complete and I should only be used by the Seaside framework.
</comment> <class> <name>Timespan</name> <environment>Squeak</environment> <super>Core.Magnitude</super> <private>false</private> none start duration <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>Schedule</name> <environment>Squeak</environment> <super>Squeak.Timespan</super> <private>false</private> none schedule <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>Date</name> <environment>Squeak</environment> <super>Squeak.Timespan</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>Year</name> <environment>Squeak</environment> <super>Squeak.Timespan</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>Week</name> <environment>Squeak</environment> <super>Squeak.Timespan</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>Duration</name> <environment>Squeak</environment> <super>Core.Magnitude</super> <private>false</private> none nanos seconds <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>AssertionFailure</name> <environment>Squeak</environment> <super>Core.HaltInterrupt</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Extensions</package> </attributes> </class> <comment> Squeak.AssertionFailure
AsssertionFailure is the exception signaled from Object>>assert: when the assertion block evaluates to false.
</comment> <class> <name>Month</name> <environment>Squeak</environment> <super>Squeak.Timespan</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <class> <name>Preferences</name> <environment>Squeak</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Preferences</package> </attributes> </class> <comment> Squeak.Preferences
Unsophisticated preference system
</comment> <class> <name>Time</name> <environment>Squeak</environment> <super>Core.Magnitude</super> <private>false</private> none seconds nanos <imports></imports> <category>Squeak</category> <attributes> <package>Squeak-Chronology</package> </attributes> </class> <name>LocalTimeZone</name> <environment>Squeak.DateAndTime</environment> <private>false</private> <constant>false</constant> <category>class variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>RandomForPicking</name> <environment>Core.Collection</environment> <private>false</private> <constant>false</constant> <category>accessing</category> <initializer>Random new</initializer> <attributes> <package>Squeak-Extensions</package> </attributes> <name>StartDay</name> <environment>Squeak.Week</environment> <private>false</private> <constant>false</constant> <category>class variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>ColorNames</name> <environment>Squeak.Color</environment> <private>false</private> <constant>false</constant> <category>color names</category> <initializer>Core.ColorValue.ColorNames keys</initializer> <attributes> <package>Squeak-Extensions</package> </attributes> <name>CSSeparators</name> <environment>Core.String</environment> <private>false</private> <constant>false</constant> <category>Squeak-Globals</category> <initializer>Squeak.CharacterSet separators</initializer> <attributes> <package>Squeak-Extensions</package> </attributes> <name>CSNonSeparators</name> <environment>Core.String</environment> <private>false</private> <constant>false</constant> <category>Squeak-Globals</category> <initializer>Squeak.CharacterSet separators complement</initializer> <attributes> <package>Squeak-Extensions</package> </attributes> <name>DefaultDirectory</name> <environment>FileDirectory</environment> <private>false</private> <constant>false</constant> <category>Statics</category> <attributes> <package>Squeak-Extensions</package> </attributes> <name>FormDictionary</name> <environment>Squeak.StandardScriptingSystem</environment> <private>false</private> <constant>false</constant> <category>static</category> <initializer>Dictionary new</initializer> <attributes> <package>Squeak-Scripting</package> </attributes> <name>DictionaryOfPreferences</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>IdentityDictionary new</initializer> <attributes> <package>Squeak-Preferences</package> </attributes> <name>MonthNames</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>ScriptingSystem</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Scripting</package> </attributes> <name>SqueakEpoch</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>SecondsInDay</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>NanosInSecond</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>DayNames</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>SecondsInMinute</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>DaysInMonth</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>NanosInMillisecond</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <name>SecondsInHour</name> <environment>Squeak</environment> <private>false</private> <constant>false</constant> <category>global variables</category> <initializer>nil</initializer> <attributes> <package>Squeak-Chronology</package> </attributes> <methods> Squeak.FillInTheBlank class <category>fill In the blank dialogs</category>
request: messageString "((( FillInTheBlank request: 'Please choose an administrator\username for the application' )))" ^self request: messageString initialAnswer: String new.
</methods> <methods> CrLfFileStream <category>character/binary</category>
ascii
</methods> <methods> CrLfFileStream class <category>instance creation</category>
oldFileNamed: aString ^self on: (FileConnection openFileNamed: aString asFilename mode: #readOnly creationRule: #noCreate)
</methods> <methods> Squeak.Color <category>squeak- testing</category>
isColor ^true
</methods> <methods> Squeak.Color <category>squeak-groups of shades</category>
wheel: thisMany "An array of thisMany colors around the color wheel starting at self and ending all the way around the hue space just before self. Array is of length thisMany. Very useful for displaying color based on a variable in your program. " | sat bri hue step c | sat := self saturation. bri := self brightness. hue := self hue. step := 1.0 / (thisMany max: 1). ^(1 to: thisMany) collect: [:num | c := Color h: hue s: sat v: bri. hue := hue + step. c] " (Color wheel: 8) withIndexDo: [:c :i | Display fill: (i*10@20 extent: 10@20) fillColor: c] "
</methods> <methods> Squeak.Color class <category>instance creation</category>
fromString: aString "for HTML color spec: #FFCCAA or white/black" "Color fromString: '#FFCCAA'. Color fromString: 'white'. Color fromString: 'orange'" | aColorHex red green blue | aString isEmptyOrNil ifTrue: [^ Color white]. aString first = $# ifTrue: [aColorHex := aString copyFrom: 2 to: aString size] ifFalse: [aColorHex := aString]. [aColorHex size = 6 ifTrue: [aColorHex := aColorHex asUppercase. red := ('16r', (aColorHex copyFrom: 1 to: 2)) asNumber/255. green := ('16r', (aColorHex copyFrom: 3 to: 4)) asNumber/255. blue := ('16r', (aColorHex copyFrom: 5 to: 6)) asNumber/255. ^ self r: red g: green b: blue]] ifError: [:err :rcvr | "not a hex color triplet" ]. "try to match aColorHex with known named colors" aColorHex := aColorHex asLowercase. ^self perform: (ColorNames detect: [:i | i asString asLowercase = aColorHex] ifNone: [#white])
h: hue s: saturation v: brightness "Create a color with the given hue, saturation, and brightness. Hue is given as the angle in degrees of the color on the color circle where red is zero degrees. Saturation and brightness are numbers in [0.0..1.0] where larger values are more saturated or brighter colors. For example, (Color h: 0 s: 1 v: 1) is pure red." "Note: By convention, brightness is abbreviated 'v' to to avoid confusion with blue." ^ self hue: hue saturation: saturation brightness: brightness
r: r g: g b: b ^ self red: r green: g blue: b
r: r g: g b: b range: range ^ self red: r green: g blue: b range: range
wheel: thisMany saturation: s brightness: v "Return a collection of thisMany colors evenly spaced around the color wheel, all of the given saturation and brightness." "Color showColors: (Color wheel: 12 saturation: 0.4 brightness: 1.0)" "Color showColors: (Color wheel: 12 saturation: 0.8 brightness: 0.5)" ^ (Color h: 0 s: s v: v) wheel: thisMany
</methods> <methods> LimitedWriteStream <category>squeak</category>
pastEndPut: anObject collection size >= limit ifTrue: [limitBlock value]. "Exceptional return" ^ super pastEndPut: anObject
setLimit: sizeLimit limitBlock: aBlock "Limit the numer of elements this stream will write..." limit := sizeLimit. "Execute this (typically ^ contents) when that limit is exceded" limitBlock := aBlock
</methods> <methods> Squeak.CharacterSet <category>comparison</category>
= anObject ^self species == anObject species and: [ self byteArrayMap = anObject byteArrayMap ]
hash ^self byteArrayMap hash
species ^CharacterSet
</methods> <methods> Squeak.CharacterSet <category>collection ops</category>
add: aCharacter map at: aCharacter asciiValue+1 put: 1.
do: aBlock "evaluate aBlock with each character in the set" Character allCharacters do: [ :c | (self includes: c) ifTrue: [ aBlock value: c ] ]
includes: aCharacter ^(map at: aCharacter asciiValue + 1) > 0
remove: aCharacter map at: aCharacter asciiValue + 1 put: 0
</methods> <methods> Squeak.CharacterSet <category>private</category>
byteArrayMap "return a ByteArray mapping each ascii value to a 1 if that ascii value is in the set, and a 0 if it isn't. Intended for use by primitives only" ^map
initialize map := ByteArray new: 256 withAll: 0.
</methods> <methods> Squeak.CharacterSet <category>conversion</category>
complement "return a character set containing precisely the characters the receiver does not" | set | set := CharacterSet allCharacters. self do: [ :c | set remove: c ]. ^set
</methods> <methods> Squeak.CharacterSet class <category>instance creation</category>
allCharacters "return a set containing all characters" | set | set := self empty. 0 to: 255 do: [ :ascii | set add: (Character value: ascii) ]. ^set
empty "return an empty set of characters" ^super new initialize
new ^super new initialize
newFrom: aCollection | newCollection | newCollection := self new. newCollection addAll: aCollection. ^newCollection
nonSeparators "return a set containing everything but the whitespace characters" ^self separators complement
separators "return a set containing just the whitespace characters" | set | set := self empty. set addAll: Character separators. ^set
</methods> <methods> Squeak.DateAndTime <category>ansi protocol</category>
+ operand "operand conforms to protocol Duration" | ticks | ticks := self ticks + (operand asDuration ticks) . ^ self class basicNew ticks: ticks offset: self offset; yourself.
- operand "operand conforms to protocol DateAndTime or protocol Duration" ^ (operand respondsTo: #asDateAndTime) ifTrue: [ | lticks rticks | lticks := self asLocal ticks. rticks := operand asDateAndTime asLocal ticks. Duration seconds: (SecondsInDay *(lticks first - rticks first)) + (lticks second - rticks second) nanoSeconds: (lticks third - rticks third) ] ifFalse: [ self + (operand negated) ].
< comparand "comparand conforms to protocol DateAndTime, or can be converted into something that conforms." | lticks rticks comparandAsDateAndTime | comparandAsDateAndTime := comparand asDateAndTime. offset = comparandAsDateAndTime offset ifTrue: [lticks := self ticks. rticks := comparandAsDateAndTime ticks] ifFalse: [lticks := self asUTC ticks. rticks := comparandAsDateAndTime asUTC ticks]. ^ lticks first < rticks first or: [lticks first > rticks first ifTrue: [false] ifFalse: [lticks second < rticks second or: [lticks second > rticks second ifTrue: [false] ifFalse: [lticks third < rticks third]]]]
= comparand "comparand conforms to protocol DateAndTime, or can be converted into something that conforms." | comparandAsDateAndTime | self == comparand ifTrue: [^ true]. [comparandAsDateAndTime := comparand asDateAndTime] on: MessageNotUnderstood do: [:e | ^ false]. ^ self offset = comparandAsDateAndTime offset ifTrue: [self ticks = comparandAsDateAndTime ticks] ifFalse: [self asUTC ticks = comparandAsDateAndTime asUTC ticks]
asLocal ^ (self offset = self class localOffset) ifTrue: [self] ifFalse: [self utcOffset: self class localOffset]
asUTC ^ self utcOffset: 0
dayOfMonth "Answer which day of the month is represented by the receiver." ^ self dayMonthYearDo: [ :d :m :y | d ]
dayOfWeek "Sunday=1, ... , Saturday=7" ^ (jdn + 1 rem: 7) + 1
dayOfWeekAbbreviation ^ self dayOfWeekName copyFrom: 1 to: 3
dayOfWeekName ^ Week nameOfDay: self dayOfWeek
dayOfYear ^ jdn - (Year year: self year) start julianDayNumber + 1
hash ^ self asUTC ticks hash
hour ^ self hour24
hour12 "Answer an <integer> between 1 and 12, inclusive, representing the hour of the day in the 12-hour clock of the local time of the receiver." ^ self hour24 - 1 \\ 12 + 1
hour24 ^ (Duration seconds: seconds) hours
isLeapYear ^ Year isLeapYear: self year.
meridianAbbreviation ^ self asTime meridianAbbreviation
minute ^ (Duration seconds: seconds) minutes
month ^ self dayMonthYearDo: [ :d :m :y | m ].
monthAbbreviation ^ self monthName copyFrom: 1 to: 3
monthName ^ Month nameOfMonth: self month
offset ^ offset
offset: anOffset "Answer a <DateAndTime> equivalent to the receiver but with its local time being offset from UTC by offset." ^ self class basicNew ticks: self ticks offset: anOffset asDuration; yourself
second ^ (Duration seconds: seconds) seconds
timeZoneAbbreviation ^ self class localTimeZone abbreviation
timeZoneName ^ self class localTimeZone name
year ^ self dayMonthYearDo: [ :d :m :y | y ]
</methods> <methods> Squeak.DateAndTime <category>smalltalk-80</category>
asSeconds "Return the number of seconds since the Squeak epoch" ^ (self - (self class epoch)) asSeconds
day ^ self dayOfYear
daysInMonth "Answer the number of days in the month represented by the receiver." ^ self asMonth daysInMonth
daysInYear "Answer the number of days in the year represented by the receiver." ^ self asYear daysInYear
daysLeftInYear "Answer the number of days in the year after the date of the receiver." ^ self daysInYear - self dayOfYear
firstDayOfMonth ^ self asMonth start day
hours ^ self hour
minutes ^ self minute
monthIndex ^ self month
seconds ^ self second
</methods> <methods> Squeak.DateAndTime <category>squeak protocol</category>
asDate ^ Date starting: self
asDateAndTime ^ self
asDuration "Answer the duration since midnight" ^ Duration seconds: seconds nanoSeconds: nanos
asMonth ^ Month starting: self
asNanoSeconds "Answer the number of nanoseconds since midnight" ^ self asDuration asNanoSeconds
asTime ^ Time seconds: seconds nanoSeconds: nanos
asTimeStamp ^ self as: TimeStamp
asWeek ^ Week starting: self
asYear ^ Year starting: self
dayMonthYearDo: aBlock "Evaluation the block with three arguments: day month, year." | l n i j dd mm yyyy | l := jdn + 68569. n := 4 * l // 146097. l := l - (146097 * n + 3 // 4). i := 4000 * (l + 1) // 1461001. l := l - (1461 * i // 4) + 31. j := 80 * l // 2447. dd := l - (2447 * j // 80). l := j // 11. mm := j + 2 - (12 * l). yyyy := 100 * (n - 49) + i + l. ^ aBlock value: dd value: mm value: yyyy.
duration ^ Duration zero
julianDayNumber ^ jdn
middleOf: aDuration "Return a Timespan where the receiver is the middle of the Duration" | duration | duration := aDuration asDuration. ^ Timespan starting: (self - (duration / 2)) duration: duration.
midnight "Answer a DateAndTime starting at midnight local time" ^ self dayMonthYearDo: [ :d :m :y | self class year: y month: m day: d ]
nanoSecond ^ nanos
noon "Answer a DateAndTime starting at noon" ^ self dayMonthYearDo: [ :d :m :y | self class year: y month: m day: d hour: 12 minute: 0 second: 0 ]
printHMSOn: aStream "Print just hh:mm:ss" aStream nextPutAll: (self hour asString padded: #left to: 2 with: $0); nextPut: $:; nextPutAll: (self minute asString padded: #left to: 2 with: $0); nextPut: $:; nextPutAll: (self second asString padded: #left to: 2 with: $0).
printOn: aStream "Print as per ISO 8601 sections 5.3.3 and 5.4.1. Prints either: 'YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for positive years) or '-YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for negative years)" ^self printOn: aStream withLeadingSpace: false
printOn: aStream withLeadingSpace: printLeadingSpaceToo "Print as per ISO 8601 sections 5.3.3 and 5.4.1. If printLeadingSpaceToo is false, prints either: 'YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for positive years) or '-YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for negative years) If printLeadingSpaceToo is true, prints either: ' YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for positive years) or '-YYYY-MM-DDThh:mm:ss.s+ZZ:zz:z' (for negative years) " self printYMDOn: aStream withLeadingSpace: printLeadingSpaceToo. aStream nextPut: $T. self printHMSOn: aStream. self nanoSecond ~= 0 ifTrue: [ | z ps | ps := self nanoSecond printString padded: #left to: 9 with: $0. z := ps findLast: [ :c | c asciiValue > $0 asciiValue ]. ps from: 1 to: z do: [ :c | aStream nextPut: c ] ]. aStream nextPut: (offset positive ifTrue: [$+] ifFalse: [$-]); nextPutAll: (offset hours abs asString padded: #left to: 2 with: $0); nextPut: $:; nextPutAll: (offset minutes abs asString padded: #left to: 2 with: $0). offset seconds = 0 ifFalse: [ aStream nextPut: $:; nextPutAll: (offset seconds abs truncated asString) ].
printYMDOn: aStream "Print just YYYY-MM-DD part. If the year is negative, prints out '-YYYY-MM-DD'." ^self printYMDOn: aStream withLeadingSpace: false.
printYMDOn: aStream withLeadingSpace: printLeadingSpaceToo "Print just the year, month, and day on aStream. If printLeadingSpaceToo is true, then print as: ' YYYY-MM-DD' (if the year is positive) or '-YYYY-MM-DD' (if the year is negative) otherwise print as: 'YYYY-MM-DD' or '-YYYY-MM-DD' " | year month day | self dayMonthYearDo: [ :d :m :y | year := y. month := m. day := d ]. year negative ifTrue: [ aStream nextPut: $- ] ifFalse: [ printLeadingSpaceToo ifTrue: [ aStream space ]]. aStream nextPutAll: (year abs asString padded: #left to: 4 with: $0); nextPut: $-; nextPutAll: (month asString padded: #left to: 2 with: $0); nextPut: $-; nextPutAll: (day asString padded: #left to: 2 with: $0)
to: anEnd "Answer a Timespan. anEnd conforms to protocol DateAndTime or protocol Timespan" ^ Timespan starting: self ending: (anEnd asDateAndTime).
to: anEnd by: aDuration "Answer a Timespan. anEnd conforms to protocol DateAndTime or protocol Timespan" ^ (Schedule starting: self ending: (anEnd asDateAndTime)) schedule: (Array with: aDuration asDuration); yourself.
to: anEnd by: aDuration do: aBlock "Answer a Timespan. anEnd conforms to protocol DateAndTime or protocol Timespan" ^ (self to: anEnd by: aDuration) scheduleDo: aBlock
utcOffset: anOffset "Answer a <DateAndTime> equivalent to the receiver but offset from UTC by anOffset" | equiv | equiv := self + (anOffset asDuration - self offset). ^ equiv ticks: (equiv ticks) offset: anOffset asDuration; yourself
</methods> <methods> Squeak.DateAndTime <category>private</category>
ticks "Private - answer an array with our instance variables. Assumed to be UTC " ^ Array with: jdn with: seconds with: nanos .
ticks: ticks offset: utcOffset "ticks is {julianDayNumber. secondCount. nanoSeconds}" | normalize | normalize := [ :i :base | | tick div quo rem | tick := ticks at: i. div := tick digitDiv: base neg: tick negative. quo := div first normalize. rem := div second normalize. rem < 0 ifTrue: [ quo := quo - 1. rem := base + rem ]. ticks at: (i-1) put: ((ticks at: i-1) + quo). ticks at: i put: rem ]. normalize value: 3 value: NanosInSecond. normalize value: 2 value: SecondsInDay. jdn := ticks first. seconds := ticks second. nanos := ticks third. offset := utcOffset.
</methods> <methods> Squeak.DateAndTime class <category>squeak protocol</category>
current ^ self now
date: aDate time: aTime ^ self year: aDate year day: aDate dayOfYear hour: aTime hour minute: aTime minute second: aTime second
epoch "Answer a DateAndTime representing the Squeak epoch: 1 January 1901" ^ self julianDayNumber: SqueakEpoch
fromString: aString ^ self readFrom: (ReadStream on: aString)
julianDayNumber: aJulianDayNumber ^ self basicNew ticks: aJulianDayNumber days ticks offset: self localOffset; yourself
localOffset "Answer the duration we are offset from UTC" ^ self localTimeZone offset
localTimeZone "Answer the local time zone" ^ LocalTimeZone ifNil: [ LocalTimeZone := TimeZone default ]
localTimeZone: aTimeZone "Set the local time zone" " DateAndTime localTimeZone: (TimeZone offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'). DateAndTime localTimeZone: (TimeZone offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'). " LocalTimeZone := aTimeZone
midnight ^ self now midnight
new "Answer a DateAndTime representing the Squeak epoch: 1 January 1901" ^ self epoch
noon ^ self now noon
readFrom: aStream | bc year month day hour minute second nanos offset buffer ch | aStream peek = $- ifTrue: [ aStream next. bc := -1] ifFalse: [bc := 1]. year := (aStream upTo: $-) asInteger * bc. month := (aStream upTo: $-) asInteger. day := (aStream upTo: $T) asInteger. hour := (aStream upTo: $:) asInteger. buffer := '00:' copy. ch := nil. minute := WriteStream on: buffer. [ aStream atEnd | (ch = $:) | (ch = $+) | (ch = $-) ] whileFalse: [ ch := minute nextPut: aStream next. ]. (ch isNil or: [ch isDigit]) ifTrue: [ ch := $: ]. minute := ((ReadStream on: buffer) upTo: ch) asInteger. buffer := '00.' copy. second := WriteStream on: buffer. [ aStream atEnd | (ch = $.) | (ch = $+) | (ch = $-) ] whileFalse: [ ch := second nextPut: aStream next. ]. (ch isNil or: [ch isDigit]) ifTrue: [ ch := $. ]. second := ((ReadStream on: buffer) upTo: ch) asInteger. buffer := '00000000+' copy. nanos := WriteStream on: buffer. [ aStream atEnd | (ch = $+) | (ch = $-) ] whileFalse: [ ch := nanos nextPut: aStream next. ]. (ch isNil or: [ch isDigit]) ifTrue: [ ch := $+ ]. nanos := ((ReadStream on: buffer) upTo: ch) asInteger. aStream atEnd ifTrue: [ offset := self localOffset ] ifFalse: [offset := Duration fromString: (ch asString, '0:', aStream upToEnd). (offset = self localOffset) ifTrue: [ offset := self localOffset ]]. ^ self year: year month: month day: day hour: hour minute: minute second: second nanoSecond: nanos offset: offset. " '-1199-01-05T20:33:14.321-05:00' asDateAndTime ' 2002-05-16T17:20:45.00000001+01:01' asDateAndTime ' 2002-05-16T17:20:45.00000001' asDateAndTime ' 2002-05-16T17:20' asDateAndTime ' 2002-05-16T17:20:45' asDateAndTime ' 2002-05-16T17:20:45+01:57' asDateAndTime ' 2002-05-16T17:20:45-02:34' asDateAndTime ' 2002-05-16T17:20:45+00:00' asDateAndTime ' 1997-04-26T01:02:03+01:02:3' asDateAndTime "
today ^ self midnight
tomorrow ^ self today asDate next asDateAndTime
year: year day: dayOfYear "Return a DateAndTime" ^ self year: year day: dayOfYear hour: 0 minute: 0 second: 0
year: year month: month day: day "Return a DateAndTime, midnight local time" ^ self year: year month: month day: day hour: 0 minute: 0
year: year month: month day: day hour: hour minute: minute "Return a DateAndTime" ^ self year: year month: month day: day hour: hour minute: minute second: 0
year: year month: month day: day hour: hour minute: minute second: second nanoSecond: nanoCount offset: offset "Return a DateAndTime" | monthIndex p q r s julianDayNumber since | monthIndex := month isInteger ifTrue: [month] ifFalse: [Month indexOfMonth: month]. p := (monthIndex - 14) quo: 12. q := year + 4800 + p. r := monthIndex - 2 - (12 * p). s := (year + 4900 + p) quo: 100. julianDayNumber := ( (1461 * q) quo: 4 ) + ( (367 * r) quo: 12 ) - ( (3 * s) quo: 4 ) + ( day - 32075 ). since := Duration days: julianDayNumber hours: hour minutes: minute seconds: second nanoSeconds: nanoCount. ^ self basicNew ticks: since ticks offset: offset; yourself.
yesterday ^ self today asDate previous asDateAndTime
</methods> <methods> Squeak.DateAndTime class <category>ansi protocol</category>
clockPrecision "One nanosecond precision" ^ Duration nanoSeconds: 1
now ^ self basicNew ticks: (Duration days: SqueakEpoch hours: 0 minutes: 0 seconds: self totalSeconds nanoSeconds: 0) ticks offset: self localOffset; yourself
year: year day: dayOfYear hour: hour minute: minute second: second ^ self year: year day: dayOfYear hour: hour minute: minute second: second offset: self localOffset.
year: year day: dayOfYear hour: hour minute: minute second: second offset: offset "Return a DataAndTime" | y d | y := self year: year month: 1 day: 1 hour: hour minute: minute second: second nanoSecond: 0 offset: offset. d := Duration days: (dayOfYear - 1). ^ y + d
year: year month: month day: day hour: hour minute: minute second: second "Return a DateAndTime" ^ self year: year month: month day: day hour: hour minute: minute second: second offset: self localOffset
year: year month: month day: day hour: hour minute: minute second: second offset: offset ^ self year: year month: month day: day hour: hour minute: minute second: second nanoSecond: 0 offset: offset
</methods> <methods> Squeak.DateAndTime class <category>smalltalk-80</category>
fromSeconds: seconds "Answer a DateAndTime since the Squeak epoch: 1 January 1901" | since | since := Duration days: SqueakEpoch hours: 0 minutes: 0 seconds: seconds. ^ self basicNew ticks: since ticks offset: self localOffset; yourself.
millisecondClockValue ^ Time millisecondClockValue
totalSeconds ^ Time totalSeconds
</methods> <methods> Squeak.TimeStamp <category>squeak protocol</category>
asTimeStamp "Answer the receiver as an instance of TimeStamp." ^ self
date "Answer the date of the receiver." ^ self asDate
dateAndTime "Answer a two element Array containing the receiver's date and time." ^ Array with: self date with: self time
minusDays: anInteger "Answer a TimeStamp which is anInteger days before the receiver." ^ self - (anInteger days)
minusSeconds: anInteger "Answer a TimeStamp which is anInteger number of seconds before the receiver." ^ self - (anInteger seconds)
plusDays: anInteger "Answer a TimeStamp which is anInteger days after the receiver." ^ self + (anInteger days)
plusSeconds: anInteger "Answer a TimeStamp which is anInteger number of seconds after the receiver." ^ self + (anInteger seconds)
printOn: aStream "Print receiver's date and time on aStream." aStream nextPutAll: self date printString; space; nextPutAll: self time printString.
storeOn: aStream aStream print: self printString; nextPutAll: ' asTimeStamp'
time "Answer the time of the receiver." ^ self asTime
</methods> <methods> Squeak.TimeStamp <category>deprecated</category>
date: aDate self deprecated: 'Deprecated'
time: aTime self deprecated: 'Deprecated'
</methods> <methods> Squeak.TimeStamp class <category>deprecated</category>
midnightOn: aDate "Answer a new instance that represents aDate at midnight." ^ self deprecated: 'Deprecated'; date: aDate time: Time midnight
noonOn: aDate "Answer a new instance that represents aDate at noon." ^ self deprecated: 'Deprecated'; date: aDate time: Time noon
</methods> <methods> Squeak.TimeStamp class <category>squeak protocol</category>
current ^ self now
</methods> <methods> Squeak.TimeStamp class <category>ansi protocol</category>
now | ts ticks | ts := super now. ticks := ts ticks. ticks at: 3 put: 0. ts ticks: ticks offset: ts offset. ^ ts
readFrom: stream | date time | stream skipSeparators. date := Date readFrom: stream. stream skipSeparators. time := Time readFrom: stream. ^self date: date time: time
</methods> <methods> Squeak.MIMEDocument <category>accessing</category>
content ^content
content: anObject content := anObject
contentType ^contentType
contentType: anObject contentType := anObject
url ^url
url: anObject url := anObject
</methods> <methods> Squeak.MIMEDocument <category>convenience</category>
contentStream ^ self content readWriteStream
</methods> <methods> Squeak.MIMEDocument class <category>instance creation</category>
contentType: contentType content: content ^self new contentType: (contentType ifNil: [self defaultContentType]); content: content; yourself
defaultContentType ^'application/octet-stream'
</methods> <methods> Squeak.ChronologyConstants class <category>as yet unclassified</category>
initialize "ChronologyConstants initialize" SqueakEpoch := 2415386. "Julian day number of 1 Jan 1901" SecondsInDay := 86400. SecondsInHour := 3600. SecondsInMinute := 60. NanosInSecond := 10 raisedTo: 9. NanosInMillisecond := 10 raisedTo: 6. DayNames := #(Sunday Monday Tuesday Wednesday Thursday Friday Saturday). MonthNames := #(January February March April May June July August September October November December). DaysInMonth := #(31 28 31 30 31 30 31 31 30 31 30 31).
</methods> <methods> Squeak.TimeZone <category>accessing</category>
abbreviation ^ abbreviation
abbreviation: aString abbreviation := aString
name ^ name
name: aString name := aString
offset ^ offset
offset: aDuration offset := aDuration
</methods> <methods> Squeak.TimeZone <category>private</category>
printOn: aStream super printOn: aStream. aStream nextPut: $(; nextPutAll: self abbreviation; nextPut: $).
</methods> <methods> Squeak.TimeZone class <category>accessing</category>
default "Answer the default time zone - GMT" ^ self timeZones detect: [ :tz | tz offset = Duration zero ]
timeZones ^ OrderedCollection new add: (self offset: 0 hours name: 'Universal Time' abbreviation: 'UTC'); add: (self offset: 0 hours name: 'Greenwich Mean Time' abbreviation: 'GMT'); add: (self offset: 0 hours name: 'British Summer Time' abbreviation: 'BST'); add: (self offset: 2 hours name: 'South African Standard Time' abbreviation: 'SAST'); add: (self offset: -8 hours name: 'Pacific Standard Time' abbreviation: 'PST'); add: (self offset: -7 hours name: 'Pacific Daylight Time' abbreviation: 'PDT'); asArray
</methods> <methods> Squeak.TimeZone class <category>instance creation</category>
offset: aDuration name: aName abbreviation: anAbbreviation ^ self new offset: aDuration; name: aName; abbreviation: anAbbreviation; yourself
</methods> <methods> Squeak.StandardScriptingSystem <category>form dictionary</category>
formAtKey: aString "Answer the form saved under the given key" Symbol hasInterned: aString ifTrue: [:aKey | ^ self formDictionary at: aKey ifAbsent: [nil]]. ^ nil
formDictionary FormDictionary isEmpty ifTrue: [self class initializeIcons]. ^FormDictionary.
</methods> <methods> Squeak.StandardScriptingSystem class <category>resources</category>
transparentColor ^ ColorValue veryLightGray
</methods> <methods> Squeak.StandardScriptingSystem class <category>initialize-release</category>
imageFrom: anIcon ^ anIcon image asGIFWithTransparentPaint: self transparentColor.
initialize ScriptingSystem := self new. FormDictionary := Dictionary new.
initializeIcons FormDictionary at: #'Halo-Debug' put: (self imageFrom: self iconDebug); at: #'Halo-View' put: (self imageFrom: self iconView); at: #'Halo-Paint' put: (self imageFrom: self iconPaint); at: #'Halo-Tile' put: (self imageFrom: self iconTile); at: #DownArrow put: (self imageFrom: self iconDownArrow); at: #UpArrow put: (self imageFrom: self iconUpArrow); at: #CheckBoxOn put: (self imageFrom: self iconCheckBoxOn); at: #CheckBoxOff put: (self imageFrom: self iconCheckBoxOff); at: #RadioButtonOn put: (self imageFrom: self iconRadioButtonOn); at: #RadioButtonOff put: (self imageFrom: self iconRadioButtonOff)
</methods> <methods> Squeak.Heap <category>comparing</category>
= aHeap "Answer true if my and aHeap's species are the same, and if our blocks are the same, and if our elements are the same." self species = aHeap species ifFalse: [^ false]. sortBlock = aHeap sortBlock ifTrue: [^ super = aHeap] ifFalse: [^ false]
</methods> <methods> Squeak.Heap <category>adding</category>
add: anObject "Include newObject as one of the receiver's elements. Answer newObject." tally = array size ifTrue:[self grow]. array at: (tally := tally + 1) put: anObject. self upHeap: tally. ^anObject
</methods> <methods> Squeak.Heap <category>private</category>
array ^array
privateRemoveAt: index "Remove the element at the given index and make sure the sorting order is okay" | removed | removed := array at: index. array at: index put: (array at: tally). array at: tally put: nil. tally := tally - 1. "Use #downHeapSingle: since only one element has been removed" self downHeapSingle: index. ^removed
setCollection: aCollection array := aCollection. tally := 0.
setCollection: aCollection tally: newTally array := aCollection. tally := newTally.
</methods> <methods> Squeak.Heap <category>accessing</category>
at: index "Return the element at the given position within the receiver" (index < 1 or:[index > tally]) ifTrue:[^self errorSubscriptBounds: index]. ^array at: index
at: index put: newObject "Heaps are accessed with #add: not #at:put:" ^self shouldNotImplement
first "Return the first element in the receiver" self emptyCheck. ^array at: 1
reSort "Resort the entire heap" self isEmpty ifTrue:[^self]. tally // 2 to: 1 by: -1 do:[:i| self downHeap: i].
size "Return the number of elements in the receiver" ^tally
sortBlock ^sortBlock
sortBlock: aBlock sortBlock := aBlock. "sortBlock fixTemps." self reSort.
</methods> <methods> Squeak.Heap <category>enumerating</category>
do: aBlock "Evaluate aBlock with each of the receiver's elements as the argument." 1 to: tally do:[:i| aBlock value: (array at: i)]
</methods> <methods> Squeak.Heap <category>private-heap</category>
downHeap: anIndex "Check the heap downwards for correctness starting at anIndex. Everything above (i.e. left of) anIndex is ok." | value k n j | anIndex = 0 ifTrue:[^self]. n := tally bitShift: -1. k := anIndex. value := array at: anIndex. [k <= n] whileTrue:[ j := k + k. "use max(j,j+1)" (j < tally and:[self sorts: (array at: j+1) before: (array at: j)]) ifTrue:[ j := j + 1]. "check if position k is ok" (self sorts: value before: (array at: j)) ifTrue:[ "yes -> break loop" n := k - 1] ifFalse:[ "no -> make room at j by moving j-th element to k-th position" array at: k put: (array at: j). "and try again with j" k := j]]. array at: k put: value.
downHeapSingle: anIndex "This version is optimized for the case when only one element in the receiver can be at a wrong position. It avoids one comparison at each node when travelling down the heap and checks the heap upwards after the element is at a bottom position. Since the probability for being at the bottom of the heap is much larger than for being somewhere in the middle this version should be faster." | value k n j | anIndex = 0 ifTrue:[^self]. n := tally bitShift: -1. k := anIndex. value := array at: anIndex. [k <= n] whileTrue:[ j := k + k. "use max(j,j+1)" (j < tally and:[self sorts: (array at: j+1) before: (array at: j)]) ifTrue:[ j := j + 1]. array at: k put: (array at: j). "and try again with j" k := j]. array at: k put: value. self upHeap: k
upHeap: anIndex "Check the heap upwards for correctness starting at anIndex. Everything below anIndex is ok." | value k kDiv2 tmp | anIndex = 0 ifTrue:[^self]. k := anIndex. value := array at: anIndex. [ (k > 1) and:[self sorts: value before: (tmp := array at: (kDiv2 := k bitShift: -1))] ] whileTrue:[ array at: k put: tmp. k := kDiv2]. array at: k put: value.
</methods> <methods> Squeak.Heap <category>growing</category>
grow "Become larger." self growTo: self size + self growSize.
growSize "Return the size by which the receiver should grow if there are no empty slots left." ^array size max: 5
growTo: newSize "Grow to the requested size." | newArray | newArray := Array new: (newSize max: tally). newArray replaceFrom: 1 to: array size with: array startingAt: 1. array := newArray
trim "Remove any empty slots in the receiver." self growTo: self size.
</methods> <methods> Squeak.Heap <category>testing</category>
isEmpty "Answer whether the receiver contains any elements." ^tally = 0
sorts: element1 before: element2 "Return true if element1 should be sorted before element2. This method defines the sort order in the receiver" ^sortBlock == nil ifTrue:[element1 <= element2] ifFalse:[sortBlock value: element1 value: element2].
</methods> <methods> Squeak.Heap <category>removing</category>
remove: oldObject ifAbsent: aBlock "Remove oldObject as one of the receiver's elements. If several of the elements are equal to oldObject, only one is removed. If no element is equal to oldObject, answer the result of evaluating anExceptionBlock. Otherwise, answer the argument, oldObject." 1 to: tally do:[:i| (array at: i) = oldObject ifTrue:[^self privateRemoveAt: i]]. ^aBlock value
removeAt: index "Remove the element at given position" (index < 1 or:[index > tally]) ifTrue:[^self errorSubscriptBounds: index]. ^self privateRemoveAt: index
removeFirst "Remove the first element from the receiver" ^self removeAt: 1
</methods> <methods> Squeak.Heap class <category>examples</category>
heapExample "Heap heapExample" "Create a sorted collection of numbers, remove the elements sequentially and add new objects randomly. Note: This is the kind of benchmark a heap is designed for." | n rnd array time sorted | n := 5000. "# of elements to sort" rnd := Random new. array := (1 to: n) collect:[:i| rnd next]. "First, the heap version" time := Time millisecondsToRun:[ sorted := Heap withAll: array. 1 to: n do:[:i| sorted removeFirst. sorted add: rnd next]. ]. Transcript cr; show:'Time for Heap: ', time printString,' msecs'. "The quicksort version" time := Time millisecondsToRun:[ sorted := SortedCollection withAll: array. 1 to: n do:[:i| sorted removeFirst. sorted add: rnd next]. ]. Transcript cr; show:'Time for SortedCollection: ', time printString,' msecs'.
heapSortExample "Heap heapSortExample" "Sort a random collection of Floats and compare the results with SortedCollection (using the quick-sort algorithm) and ArrayedCollection>>mergeSortFrom:to:by: (using the merge-sort algorithm)." | n rnd array time sorted | n := 10000. "# of elements to sort" rnd := Random new. array := (1 to: n) collect: [:i | rnd next]. "First, the heap version" time := Time millisecondsToRun: [sorted := Heap withAll: array. 1 to: n do: [:i | sorted removeFirst]]. Transcript cr; show: 'Time for heap-sort: ' , time printString , ' msecs'. "The quicksort version" time := Time millisecondsToRun: [sorted := SortedCollection withAll: array]. Transcript cr; show: 'Time for quick-sort: ' , time printString , ' msecs'. "The merge-sort version" time := Time millisecondsToRun: [array mergeSortFrom: 1 to: array size by: [:v1 :v2 | v1 <= v2]]. Transcript cr; show: 'Time for merge-sort: ' , time printString , ' msecs'
</methods> <methods> Squeak.Heap class <category>instance creation</category>
new ^self new: 10
new: n ^super new setCollection: (Array new: n)
sortBlock: aBlock "Create a new heap sorted by the given block" ^self new sortBlock: aBlock
withAll: aCollection "Create a new heap with all the elements from aCollection" ^(self basicNew) setCollection: aCollection asArray copy tally: aCollection size; reSort; yourself
</methods> <methods> Squeak.Stopwatch <category>squeak protocol</category>
activate self isSuspended ifTrue: [self timespans add: (Timespan starting: DateAndTime now duration: Duration zero). self state: #active]
duration | ts last | self isSuspended ifTrue: [ (ts := self timespans) isEmpty ifTrue: [ ts := Array with: (Timespan starting: DateAndTime now duration: Duration zero ) ] ] ifFalse: [ last := self timespans last. ts := self timespans allButLast add: (last duration: (DateAndTime now - last start); yourself); yourself ]. ^ (ts collect: [ :t | t duration ]) sum
end ^ self timespans last next
isActive ^ self state = #active
isSuspended ^ self state = #suspended
printOn: aStream super printOn: aStream. aStream nextPut: $(; nextPutAll: self state; nextPut: $:; print: self duration; nextPut: $).
reActivate self suspend; activate.
reset self suspend. timespans := nil.
start ^ self timespans first start
state ^ state ifNil: [ state := #suspended ]
state: aSymbol state := aSymbol
suspend | ts | self isActive ifTrue: [ ts := self timespans last. ts duration: (DateAndTime now - ts start). self state: #suspended]
timespans ^ timespans ifNil: [ timespans := OrderedCollection new ]
</methods> <methods> Squeak.Browser <category>seaside-api</category>
classList ^ self classNames list
classListIndex ^self classNames selectionIndex
classListIndex: anInteger | save | save := self isClassComment. self classNames selectionIndex: anInteger. self methodCategories: nil. self methodCategories. self isClassComment: save. self computeContents
indicateClassMessages self displayOption: self displayOptionClass. self isClassComment: false.
indicateInstanceMessages self displayOption: self displayOptionInstance. self isClassComment: false.
messageCategoryList ^ self methodCategories list.
messageCategoryListIndex ^self methodCategories selectionIndex
messageCategoryListIndex: anInteger self methodCategories selectionIndex: anInteger. self selectors: nil. anInteger >0 ifTrue: [self isClassComment: false]. self computeContents
messageList ^ self selectors list
messageListIndex ^ self selectors selectionIndex
messageListIndex: anInteger | className class category | self selectors selectionIndex: anInteger. anInteger > 0 ifTrue: [self isClassComment: false. className := self classNames selection. class := className asQualifiedReference binding value. self isDisplayingClass ifTrue: [class := class class]. category := class whichCategoryIncludesSelector: self selectedMethod. self methodCategories selection: category]. self computeContents
metaClassIndicated ^self isDisplayingClass
plusButtonHit self isClassComment: self isClassComment not. self isClassComment ifTrue: [self messageCategoryListIndex: 0. self messageListIndex: 0].
selectedMessageName self messageListIndex = 0 ifTrue: [^nil]. ^self messageList at: self messageListIndex.
selectedMessageName: aSelector "No effect for now"
setClass: aClass selector: aSelector | category theClass | theClass := aClass isMeta ifTrue: [aClass theNonMetaClass] ifFalse: [aClass]. category := theClass category. self systemCategoryListIndex: (self systemCategoryList indexOf: category). self classListIndex: (self classList indexOf: theClass fullyQualifiedReference). aClass isMeta ifTrue: [self indicateClassMessages]. self messageListIndex: (self messageList indexOf: aSelector). self computeContents
systemCategoryList ^ self systemCategories list.
systemCategoryListIndex ^self systemCategories selectionIndex
systemCategoryListIndex: anInteger self systemCategories selectionIndex: anInteger. self classNames: nil. self computeContents
</methods> <methods> Squeak.Browser <category>private</category>
changed self changed: #contents.
classComment | comment | comment := self selectedClass comment. comment isEmpty ifTrue: [comment := self selectedClass commentTemplateString]. ^ comment.
classDefinition | stream class extra superclassSpec | class := self selectedClass. extra := class extraAttributesForDefinition. superclassSpec := class superclass isNil ifFalse: [class superclass fullyQualifiedReference printString] ifTrue: [nil printString]. stream := (String new: 150) writeStream. stream nextPutAll: class environment fullName; nextPutAll: ' defineClass: '; nextPutAll: class name printString; cr; tab; nextPutAll: 'superclass: '; nextPutAll: superclassSpec; cr; tab; nextPutAll: 'indexedType: '; nextPutAll: class behaviorType printString; cr; tab; nextPutAll: 'private: '; nextPutAll: (class environment bindingFor: class name) isPrivate printString; cr; tab; nextPutAll: 'instanceVariableNames: '; nextPutAll: class instanceVariablesString printString; cr; tab; nextPutAll: 'classInstanceVariableNames: '; nextPutAll: class class instanceVariablesString printString; cr; tab; nextPutAll: 'imports: '; nextPutAll: class asNameSpace importString printString; cr; tab; nextPutAll: 'category: '; nextPutAll: class category asString printString; cr. extra isEmpty ifFalse: [stream tab; nextPutAll: 'attributes: '. extra printOn: stream. stream cr]. ^ stream contents.
classTemplate ^ (self namespace fullyQualifiedReferenceFrom: Root) asString , ' defineClass: #NameOfClass superclass: #{Core.Object} indexedType: #none private: false instanceVariableNames: ''instVarName1 instVarName2'' classInstanceVariableNames: '''' imports: '''' category: ''', self selectedSystemCategory, ''' attributes: #( #( #package ''(none)'' ) )'
compileClassDefinition: aString notifying: anObject | theClass pos | [theClass := Compiler evaluate: aString for: nil in: self namespace notifying: nil logged: false. self classNames: nil. self systemCategories selection: self selectedSystemCategory. self classNames selection: theClass fullyQualifiedReference. self changed] on: Error do: [:error | pos := (error respondsTo: #position) ifTrue: [error position] ifFalse: [0]. anObject notify: error description at: pos in: aString readStream].
compileMethod: aString notifying: anObject | category class pos result | class := self selectedClass. self isDisplayingClass ifTrue: [class := class class]. category := self selectedMethodCategory. [(category notNil and: [category ~= self allMethods]) ifTrue: [result := class compile: aString classified: category. self selectors: nil] ifFalse: [result := class compile: aString. self methodCategories: nil. self methodCategories selection: category]. self selectors selection: result. self changed] on: Error do: [:error | pos := (error respondsTo: #position) ifTrue: [error position] ifFalse: [0]. anObject notify: error description at: pos in: aString readStream]
compileNewClass: aString notifying: anObject | theClass pos | [theClass := Compiler evaluate: aString for: nil in: self namespace notifying: nil logged: false. self classNames: nil. self systemCategories selection: self selectedSystemCategory. self classNames selection: theClass fullyQualifiedReference. self changed] on: Error do: [:error | pos := (error respondsTo: #position) ifTrue: [error position] ifFalse: [0]. anObject notify: error description at: pos in: aString readStream].
computeContents self contents: self computedContents. self changed.
computedContents self isClassComment ifTrue: [^self isClassSelected ifTrue: [self classComment] ifFalse: [self classTemplate]]. self isMethodSelected ifTrue: [^self methodSource]. self isMethodCategorySelected ifTrue: [^self sourceCodeTemplate]. self isClassSelected ifTrue: [^self classDefinition]. ^self classTemplate
methodSource | class | class := self selectedClass. self isDisplayingClass ifTrue: [class:= class class]. ^ class sourceCodeAt: self selectedMethod
performChange: change Refactory.Browser.RefactoryChangeManager instance performChange: change
refreshClassList self classListIndex: self classListIndex
refreshMessageCategoryList self messageCategoryListIndex: self messageCategoryListIndex
refreshSystemCategoryList self systemCategoryListIndex: self systemCategoryListIndex
selectedClass ^self selectedClassName asQualifiedReference ifDefinedDo: [:value | value] elseDo: [nil]
selectedClassName ^ self classNames selection
selectedMethod ^ self selectors selection
selectedMethodCategory ^self methodCategories selection ifNil: [self allMethods]
selectedSystemCategory ^ self systemCategories selection
sourceCodeTemplate ^ self selectedClass sourceCodeTemplate
</methods> <methods> Squeak.Browser <category>ui</category>
confirm: aString ^Dialog confirm: aString
request: a initialAnswer: b ^FillInTheBlank request: a initialAnswer: b
</methods> <methods> Squeak.Browser <category>seaside-api-changes</category>
contents: aString notifying: anObject self contents: aString. self isClassComment ifTrue: [^self isClassSelected ifTrue: [self selectedClass comment: aString] ifFalse: [self compileClassDefinition: aString notifying: anObject]]. self isMethodCategorySelected | self isMethodSelected ifTrue: [^self compileMethod: aString notifying: anObject]. ^ self compileClassDefinition: aString notifying: anObject
removeClass | change | (self confirm: 'Are you certain that you want to REMOVE the class ' , self selectedClassName asString , ' from the system?') ifFalse: [^self]. change := Refactory.Browser.RemoveClassChange removeClassName: self selectedClassName. self performChange: change. self refreshSystemCategoryList
removeMessage | class change | class := self selectedClass. self isDisplayingClass ifTrue: [class := class class]. change := Refactory.Browser.RemoveMethodChange remove: self selectedMethod from: class. self performChange: change. self messageList size > 1 ifTrue: [self refreshMessageCategoryList] ifFalse: [self refreshClassList]
removeMessageCategory | class change protocolName | (self messageList isEmpty or: [self confirm: 'Are you sure you want to remove this method category and all its methods?']) ifFalse: [^self]. class := self selectedClass. protocolName := self selectedMethodCategory. self isDisplayingClass ifTrue: [class := class class]. self messageList do: [:selector | change := Refactory.Browser.RemoveMethodChange remove: selector from: class. self performChange: change]. change := Refactory.Browser.RemoveProtocolChange class: class protocol: protocolName. self performChange: change. self refreshClassList
renameCategory "Prompt for a new category name and add it before the current selection, or at the end if no current selection" | oldName newName change class | class := self selectedClass. self isDisplayingClass ifTrue: [class := class class]. self classListIndex = 0 ifTrue: [^self]. self messageCategoryListIndex <= 1 ifTrue: [^self]. oldName := self selectedMethodCategory. newName := self request: 'Please type new category name' initialAnswer: oldName. newName isEmpty ifTrue: [^self] ifFalse: [newName := newName asSymbol]. newName = oldName ifTrue: [^self]. change := Refactory.Browser.RenameProtocolChange class: class oldProtocol: oldName newProtocol: newName. self performChange: change. self refreshClassList
</methods> <methods> Squeak.Browser <category>constants</category>
allMethods ^ '-- all --'.
defaultDisplayOption ^self displayOptionInstance
displayOptionClass ^ #class
displayOptionInstance ^ #instance
</methods> <methods> Squeak.Browser <category>accessing</category>
classNames classNames isNil ifTrue: [self initializeClassNames]. ^classNames
classNames: anObject classNames := anObject. self methodCategories: nil.
contents ^contents
contents: anObject contents := anObject
displayOption displayOption isNil ifTrue: [self initializeDisplayOption]. ^displayOption
displayOption: anObject anObject == displayOption ifFalse: [displayOption := anObject. self methodCategories: nil]
isClassComment isClassComment isNil ifTrue: [self isClassComment: false]. ^isClassComment
isClassComment: anObject isClassComment := anObject. self changed.
methodCategories methodCategories isNil ifTrue: [self initializeMethodCategories]. ^methodCategories
methodCategories: anObject methodCategories := anObject. self selectors: nil.
namespace namespace isNil ifTrue: [^Squeak]. ^namespace
namespace: anObject namespace := anObject
selectors selectors isNil ifTrue: [self initializeSelectors]. ^selectors
selectors: anObject selectors := anObject. self changed.
systemCategories systemCategories isNil ifTrue: [self initializeSystemCategories]. ^systemCategories
systemCategories: anObject systemCategories := anObject. self classNames: nil.
</methods> <methods> Squeak.Browser <category>lazy initializations</category>
initializeClassNames | category list | category := self systemCategories selection. list := Set new. Root withAllNameSpacesDo: [:each | list addAll: ((each classNames select: [:name | (each at: name) category = category]) collect: [:name | (each at: name) fullyQualifiedReference])]. self classNames: (SelectionInList with: list asSortedCollection).
initializeDisplayOption self displayOption: self defaultDisplayOption.
initializeMethodCategories | className class list | className := self classNames selection. list := className isNil ifTrue: [Array new] ifFalse: [class := className asQualifiedReference binding value. self isDisplayingClass ifTrue: [class := class class]. class organization categories]. list := list asOrderedCollection. list addFirst: self allMethods. self methodCategories: (SelectionInList with: list). self selectors: nil.
initializeSelectors | className class list category | className := self classNames selection. category := self methodCategories selection. list := className isNil ifTrue: [Array new] ifFalse: [class := className asQualifiedReference binding value. self isDisplayingClass ifTrue: [class := class class]. (category isNil or: [category = self allMethods]) ifFalse: [class organization listAtCategoryNamed: category] ifTrue: [class selectors asSortedCollection]]. self selectors: (SelectionInList with: list).
initializeSystemCategories | list | list := Set new. Root withAllNameSpacesDo: [:each | list addAll: each organization classCategories]. self systemCategories: (SelectionInList with: list asSortedCollection).
</methods> <methods> Squeak.Browser <category>testing</category>
isClassSelected ^ self isSystemCategorySelected and: [self selectedClassName notNil].
isDisplayingClass ^ self displayOption == self displayOptionClass
isMethodCategorySelected ^ self isClassSelected and: [self methodCategories selection notNil].
isMethodSelected ^ self selectors selection notNil
isSystemCategorySelected ^ self selectedSystemCategory notNil
</methods> <methods> Squeak.Browser class <category>instance creation</category>
new "We need to setup a namespace that will be used for new classes created by this Browser object" | method namespace | namespace := (method := thisContext sender method) notNil ifTrue: [method mclass environment] ifFalse: [nil]. ^ super new namespace: namespace
</methods> <methods> FileDirectory <category>testing</category>
fileExists: filenameOrPath "Answer true if a file of the given name exists. The given name may be either a full path name or a local file within this directory." | aFilename dir | aFilename := filenameOrPath asFilename. dir := aFilename components size = 1 ifTrue: [self] ifFalse: [FileDirectory on: aFilename head]. ^(dir fullNameFor: aFilename tail) asFilename exists
</methods> <methods> FileDirectory <category>file directory</category>
assureExistence path exists ifTrue: [^self]. (FileDirectory on: path head) assureExistence. path makeDirectory.
</methods> <methods> FileDirectory <category>stream creation</category>
forceNewFileNamed: localFileName "Open the file with the given name in this directory for writing. If it already exists, delete it first without asking." ^ (path construct: localFileName) writeStream
oldFileNamed: localFileName "Open the existing file with the given name in this directory." ^ (path construct: localFileName) readStream
readOnlyFileNamed: localFileName "Open the existing file with the given name in this directory for read-only access." ^ (path construct: localFileName) readStream
</methods> <methods> FileDirectory <category>accessing</category>
fileNames ^path directoryContents
fullNameFor: aString ^(path construct: aString) asString
localName ^path tail
path ^path
path: anObject path := anObject
</methods> <methods> FileDirectory <category>enumeration</category>
directoryNamed: localFileName "Return the subdirectory of this directory with the given name." ^ self species on: (self fullNameFor: localFileName)
</methods> <methods> FileDirectory class <category>instance creation</category>
default ^DefaultDirectory
on: aString ^self new path: aString asFilename
</methods> <methods> FileDirectory class <category>class initialization</category>
initialize DefaultDirectory := self new path: Filename defaultDirectory
</methods> <methods> Squeak.WeakSet <category>adding</category>
add: anObject "Include anObject as one of the receiver's elements. Answer anObject." self at: anObject put: anObject. ^anObject
</methods> <methods> Squeak.WeakSet <category>printing</category>
printOn: aStream "Append to the argument aStream a sequence of characters that identifies the collection. The general format for collections is Collection-name ( element element element ) unless there are a large number in which case the listing is truncated with the words ...etc..." | tooMany | tooMany := aStream position + self maxPrint. aStream print: self class; nextPutAll: ' ('. self do: [:element | aStream position > tooMany ifTrue: [aStream nextPutAll: '...etc...)'. ^self]. element printOn: aStream] separatedBy: [aStream space]. aStream nextPut: $)
</methods> <methods> Squeak.WeakSet <category>removing</category>
remove: oldObject "Remove oldObject as one of the receiver's elements. Answer oldObject unless no element is equal to oldObject, in which case, provide an error notification. " ^self remove: oldObject ifAbsent: [self notFoundError]
remove: oldObject ifAbsent: anExceptionBlock "Remove oldObject as one of the receiver's elements. If several of the elements are equal to oldObject, only one is removed. If no element is equal to oldObject, answer the result of evaluating anExceptionBlock. Otherwise, answer the argument, oldObject." ^self removeKey: oldObject ifAbsent: anExceptionBlock
</methods> <methods> Squeak.Timespan <category>ansi protocol</category>
+ operand "operand conforms to protocol Duration" ^ self class starting: (self start + operand) duration: self duration
- operand "operand conforms to protocol DateAndTime or protocol Duration" ^ (operand respondsTo: #asDateAndTime) ifTrue: [ self start - operand ] ifFalse: [ self + (operand negated) ].
< comparand ^ self start < comparand
= comparand ^ comparand species = self species and: [(self start = comparand start) and: [self duration = comparand duration]]
dayOfMonth "Answer the day of the month represented by the receiver." ^ start dayOfMonth
dayOfWeek "Answer the day of the week represented by the receiver." ^ start dayOfWeek
dayOfWeekName "Answer the day of the week represented by the receiver." ^ start dayOfWeekName
dayOfYear "Answer the day of the year represented by the receiver." ^ start dayOfYear
hash ^ start hash + duration hash
isLeapYear ^ start isLeapYear
month ^ start month
monthAbbreviation ^ start monthAbbreviation
monthName ^ start monthName
year ^ start year
</methods> <methods> Squeak.Timespan <category>squeak protocol</category>
asDate ^ start asDate
asDateAndTime ^ start
asDuration ^ self duration
asMonth ^ start asMonth
asTime ^ start asTime
asTimeStamp ^ start asTimeStamp
asWeek ^ start asWeek
asYear ^ start asYear
duration "Answer the Duration of this timespan" ^ duration
end ^ self next start - DateAndTime clockPrecision
includes: aDateAndTime ^ (aDateAndTime isKindOf: Timespan) ifTrue: [ (self includes: aDateAndTime start) and: [ self includes: aDateAndTime end ] ] ifFalse: [ aDateAndTime asDateAndTime between: start and: self end ]
includesAllOf: aCollection "Answer whether all the elements of aCollection are in the receiver." aCollection do: [:elem | (self includes: elem) ifFalse: [^ false]]. ^ true
includesAnyOf: aCollection "Answer whether any element of aCollection is included in the receiver" aCollection do: [ :elem | (self includes: elem) ifTrue: [^ true]]. ^false
intersection: aTimespan "Return the Timespan both have in common, or nil" | aBegin anEnd | aBegin := self start max: aTimespan start. anEnd := self end min: aTimespan end. anEnd < aBegin ifTrue: [^nil]. ^ self class starting: aBegin ending: anEnd.
julianDayNumber ^ start julianDayNumber
printOn: aStream super printOn: aStream. aStream nextPut: $(; print: start; nextPut: $D; print: duration; nextPut: $).
start "Answer the start DateAndTime of this timespan" ^ start
start: aDateAndTime "Store the start DateAndTime of this timespan" start := aDateAndTime asDateAndTime
to: anEnd "Answer an Timespan. anEnd must be aDateAndTime or a Timespan" ^ Timespan starting: (self start) ending: (anEnd asDateAndTime).
union: aTimespan "Return the Timespan spanned by both" | aBegin anEnd | aBegin := self start min: aTimespan start. anEnd := self end max: aTimespan end. ^ Timespan starting: aBegin ending: (anEnd + DateAndTime clockPrecision).
</methods> <methods> Squeak.Timespan <category>enumerating</category>
dates | dates | dates := OrderedCollection new. self datesDo: [ :m | dates add: m ]. ^ dates asArray.
datesDo: aBlock self do: aBlock with: start asDate.
every: aDuration do: aBlock | element end | element := self start. end := self end. [ element <= end ] whileTrue: [ aBlock value: element. element := element + aDuration. ]
months | months | months := OrderedCollection new: 12. self monthsDo: [ :m | months add: m ]. ^ months asArray.
monthsDo: aBlock self do: aBlock with: start asMonth.
weeks | weeks | weeks := OrderedCollection new. self weeksDo: [ :m | weeks add: m ]. ^ weeks asArray.
weeksDo: aBlock self do: aBlock with: self asWeek.
workDatesDo: aBlock "Exclude Saturday and Sunday" self do: aBlock with: start asDate when: [ :d | d dayOfWeek < 6 ].
years | years | years := OrderedCollection new. self yearsDo: [ :m | years add: m ]. ^ years asArray.
yearsDo: aBlock self do: aBlock with: start asYear.
</methods> <methods> Squeak.Timespan <category>smalltalk-80</category>
day "Answer the day of the year represented by the receiver." ^ self dayOfYear
daysInMonth ^ start daysInMonth
daysInYear "Answer the number of days in the month represented by the receiver." ^ start daysInYear
daysLeftInYear ^ start daysLeftInYear
firstDayOfMonth ^ start firstDayOfMonth
monthIndex ^ self month
next ^ self class starting: (start + duration) duration: duration
previous ^ self class starting: (start - duration) duration: duration
</methods> <methods> Squeak.Timespan <category>private</category>
do: aBlock with: aFirstElement self do: aBlock with: aFirstElement when: [ :t | true ].
do: aBlock with: aFirstElement when: aConditionBlock | element end | element := aFirstElement. end := self end. [ element start <= end ] whileTrue: [(aConditionBlock value: element) ifTrue: [ aBlock value: element ]. element := element next. ]
duration: aDuration "Set the Duration of this timespan" duration := aDuration
</methods> <methods> Squeak.Timespan <category>deprecated</category>
firstDate self deprecated: 'Use #start'. ^ self start asDate
lastDate self deprecated: 'Use #end'. ^ self end asDate
</methods> <methods> Squeak.Timespan class <category>squeak protocol</category>
current ^ self starting: DateAndTime now
new "Answer a Timespan starting on the Squeak epoch: 1 January 1901" ^ self starting: DateAndTime new
starting: aDateAndTime ^ self starting: aDateAndTime duration: Duration zero
starting: aDateAndTime duration: aDuration ^ self basicNew start: aDateAndTime asDateAndTime; duration: aDuration; yourself.
starting: startDateAndTime ending: endDateAndTime ^ self starting: startDateAndTime duration: (endDateAndTime asDateAndTime - startDateAndTime).
</methods> <methods> Squeak.Timespan class <category>deprecated</category>
fromDate: aDate ^ self deprecated: 'Use #starting: '; starting: aDate
</methods> <methods> Squeak.Schedule <category>enumerating</category>
between: aStart and: anEnd do: aBlock | element end i | end := self end min: anEnd. element := self start. i := 1. [ element < aStart ] whileTrue: [ element := element + (schedule at: i). i := i + 1. (i > schedule size) ifTrue: [i := 1]]. i := 1. [ element <= end ] whileTrue: [ aBlock value: element. element := element + (schedule at: i). i := i + 1. (i > schedule size) ifTrue: [i := 1]] .
dateAndTimes | dateAndTimes | dateAndTimes := OrderedCollection new. self scheduleDo: [ :e | dateAndTimes add: e ]. ^ dateAndTimes asArray.
schedule ^ schedule
schedule: anArrayOfDurations schedule := anArrayOfDurations
scheduleDo: aBlock self between: (self start) and: (self end) do: aBlock.
</methods> <methods> Squeak.Schedule <category>squeak protocol</category>
includes: aDateAndTime | dt | dt := aDateAndTime asDateAndTime. self scheduleDo: [ :e | e = dt ifTrue: [^true] ]. ^ false.
</methods> <methods> Squeak.Date <category>smalltalk-80</category>
addDays: dayCount ^ (self asDateAndTime + (dayCount days)) asDate
asSeconds "Answer the seconds since the Squeak epoch: 1 January 1901" ^ start asSeconds
leap "Answer whether the receiver's year is a leap year." ^ start isLeapYear ifTrue: [1] ifFalse: [0].
previous: dayName "Answer the previous date whose weekday name is dayName." | days | days := 7 + self weekdayIndex - (self class dayOfWeek: dayName) \\ 7. days = 0 ifTrue: [ days := 7 ]. ^ self subtractDays: days
subtractDate: aDate "Answer the number of days between self and aDate" ^ (self start - aDate asDateAndTime) days
subtractDays: dayCount ^ (self asDateAndTime - (dayCount days)) asDate
weekday "Answer the name of the day of the week on which the receiver falls." ^ self dayOfWeekName
weekdayIndex "Sunday=1, ... , Saturday=7" ^ self dayOfWeek
</methods> <methods> Squeak.Date <category>squeak protocol</category>
asDate ^ self
dayMonthYearDo: aBlock "Supply integers for day, month and year to aBlock and return the result" ^ start dayMonthYearDo: aBlock
month ^ self asMonth
monthIndex ^ super month
</methods> <methods> Squeak.Date <category>deprecated</category>
asGregorian "Return an array of integers #(dd mm yyyy)" ^ self deprecated: 'Use #dayMonthYearDo:'; dayMonthYearDo: [ :d :m :y | Array with: d with: m with: y ]
asJulianDayNumber ^ self deprecated: 'Use #julianDayNumber'; julianDayNumber
day: dayInteger year: yearInteger ^ self deprecated: 'Obsolete'
daylightSavingsInEffect "Return true if DST is observed at or after 2am on this day" self deprecated: 'Deprecated'. self dayMonthYearDo: [ :day :month :year | (month < 4 or: [month > 10]) ifTrue: [^ false]. "False November through March" (month > 4 and: [month < 10]) ifTrue: [^ true]. "True May through September" month = 4 ifTrue: ["It's April -- true on first Sunday or later" day >= 7 ifTrue: [^ true]. "Must be after" ^ day > (self weekdayIndex \\ 7)] ifFalse: ["It's October -- false on last Sunday or later" day <= 24 ifTrue: [^ true]. "Must be before" ^ day <= (24 + (self weekdayIndex \\ 7))]]
daylightSavingsInEffectAtStandardHour: hour "Return true if DST is observed at this very hour (standard time)" "Note: this *should* be the kernel method, and daylightSavingsInEffect should simply be self daylightSavingsInEffectAtHour: 3" self deprecated: 'Deprecated'. self daylightSavingsInEffect ifTrue: [^ (self addDays: -1) daylightSavingsInEffect or: [hour >= 2]] ifFalse: [^ (self addDays: -1) daylightSavingsInEffect and: [hour < 1]]
firstDayOfMonthIndex: monthIndex ^ self deprecated: 'Obsolete'
julianDayNumber: anInteger "Set the number of days elapsed since midnight GMT on January 1st, 4713 B.C." self deprecated: 'Obsolete'.
mmddyy "Please use mmddyyyy instead, so dates in 2000 will be unambiguous" ^ self deprecated: 'Use #mmddyyyy'; printFormat: #(2 1 3 $/ 1 2)
uniqueDateStringBetween: aStart and: anEnd "Return a String, with just enough information to distinguish it from other dates in the range." "later, be more sophisticated" self deprecated: 'Deprecated'. aStart year + 1 >= anEnd year ifFalse: [^ self printFormat: #(1 2 3 $ 3 1)]. "full" aStart week next >= anEnd week ifFalse: [^ self printFormat: #(2 1 9 $ 3 1)]. "May 6" ^ self weekday
week ^ self deprecated: 'Use #asWeek'; asWeek
</methods> <methods> Squeak.Date <category>converting</category>
asTimeStamp "Answer the receiver as a TimeStamp at midnight." ^TimeStamp date: self time: (Time fromSeconds: 0)
asTimestamp ^self dayMonthYearDo: [:d :m :y | (Core.Date newDay: d monthNumber: m year: y) asTimestamp]
</methods> <methods> Squeak.Date <category>printing</category>
mmddyyyy "Answer the receiver rendered in standard U.S.A format mm/dd/yyyy. Note that the name here is slightly misleading -- the month and day numbers don't show leading zeros, so that for example February 1 1996 is 2/1/96" ^ self printFormat: #(2 1 3 $/ 1 1)
printFormat: formatArray "Answer a String describing the receiver using the argument formatArray." | aStream | aStream := WriteStream on: (String new: 16). self printOn: aStream format: formatArray. ^ aStream contents
printOn: aStream self printOn: aStream format: #(1 2 3 $ 3 1 )
printOn: aStream format: formatArray "Print a description of the receiver on aStream using the format denoted the argument, formatArray: #(item item item sep monthfmt yearfmt twoDigits) items: 1=day 2=month 3=year will appear in the order given, separated by sep which is eaither an ascii code or character. monthFmt: 1=09 2=Sep 3=September yearFmt: 1=1996 2=96 digits: (missing or)1=9 2=09. See the examples in printOn: and mmddyy" | gregorian twoDigits element monthFormat | gregorian := self dayMonthYearDo: [ :d :m :y | Array with: d with: m with: y ]. twoDigits := formatArray size > 6 and: [(formatArray at: 7) > 1]. 1 to: 3 do: [ :i | element := formatArray at: i. element = 1 ifTrue: [twoDigits ifTrue: [aStream nextPutAll: (gregorian first asString padded: #left to: 2 with: $0)] ifFalse: [gregorian first printOn: aStream]]. element = 2 ifTrue: [monthFormat := formatArray at: 5. monthFormat = 1 ifTrue: [twoDigits ifTrue: [aStream nextPutAll: (gregorian middle asString padded: #left to: 2 with: $0)] ifFalse: [gregorian middle printOn: aStream]]. monthFormat = 2 ifTrue: [aStream nextPutAll: ((Month nameOfMonth: gregorian middle) copyFrom: 1 to: 3)]. monthFormat = 3 ifTrue: [aStream nextPutAll: (Month nameOfMonth: gregorian middle)]]. element = 3 ifTrue: [(formatArray at: 6) = 1 ifTrue: [gregorian last printOn: aStream] ifFalse: [aStream nextPutAll: ((gregorian last \\ 100) asString padded: #left to: 2 with: $0)]]. i < 3 ifTrue: [(formatArray at: 4) ~= 0 ifTrue: [aStream nextPut: (formatArray at: 4) asCharacter]]]
storeOn: aStream aStream print: self printString; nextPutAll: ' asDate'
yyyymmdd "Format the date in ISO 8601 standard like '2002-10-22'." ^ self printFormat: #(3 2 1 $- 1 1 2)
</methods> <methods> Squeak.Date <category>comparing</category>
= aDate "Answer whether the argument, aDate, is the same day as the receiver. " ^self species = aDate species and: [self day = aDate day and: [self year = aDate year]]
species ^Core.Date
</methods> <methods> Squeak.Date class <category>deprecated</category>
absoluteDaysToYear: gregorianYear self deprecated: 'Deprecated'
fromJulianDayNumber: aJulianDayNumber self deprecated: 'Deprecated'; julianDayNumber: aJulianDayNumber
yearAndDaysFromDays: days into: aTwoArgBlock self deprecated: 'Deprecated'
</methods> <methods> Squeak.Date class <category>smalltalk-80</category>
dateAndTimeNow "Answer an Array whose with Date today and Time now." ^ Time dateAndTimeNow
dayOfWeek: dayName ^ Week indexOfDay: dayName
daysInMonth: monthName forYear: yearInteger ^ Month daysInMonth: monthName forYear: yearInteger.
daysInYear: yearInteger ^ Year daysInYear: yearInteger.
firstWeekdayOfMonth: month year: year "Answer the weekday index of the first day in <month> in the <year>." ^ (self newDay: 1 month: month year: year) weekdayIndex
fromDays: dayCount "Days since 1 January 1901" ^ self julianDayNumber: dayCount + SqueakEpoch
fromSeconds: seconds "Answer an instance of me which is 'seconds' seconds after January 1, 1901." ^ self fromDays: ((Duration seconds: seconds) days)
indexOfMonth: aMonthName ^ Month indexOfMonth: aMonthName.
leapYear: yearInteger ^ Year leapYear: yearInteger
nameOfDay: dayIndex ^ Week nameOfDay: dayIndex
nameOfMonth: anIndex ^ Month nameOfMonth: anIndex.
newDay: day month: month year: year ^ self year: year month: month day: day
newDay: dayCount year: yearInteger ^ self year: yearInteger day: dayCount
today ^ self current
</methods> <methods> Squeak.Date class <category>squeak protocol</category>
fromString: aString "Answer an instance of created from a string with format dd.mm.yyyy." ^ self readFrom: aString readStream.
julianDayNumber: aJulianDayNumber ^ self starting: (DateAndTime julianDayNumber: aJulianDayNumber)
newDay: dayNumber monthNumber: monthNumber year: yearNumber ^ self newDay: dayNumber month: monthNumber year: yearNumber
readFrom: aStream "Read a Date from the stream in any of the forms: <day> <monthName> <year> (5 April 1982; 5-APR-82) <monthName> <day> <year> (April 5, 1982) <monthNumber> <day> <year> (4/5/82) <day><monthName><year> (5APR82)" | day month year | aStream peek isDigit ifTrue: [day := Integer readFrom: aStream]. [aStream peek isAlphaNumeric] whileFalse: [aStream skip: 1]. aStream peek isLetter ifTrue: ["number/name... or name..." month := WriteStream on: (String new: 10). [aStream peek isLetter] whileTrue: [month nextPut: aStream next]. month := month contents. day isNil ifTrue: ["name/number..." [aStream peek isAlphaNumeric] whileFalse: [aStream skip: 1]. day := Integer readFrom: aStream]] ifFalse: ["number/number..." month := Month nameOfMonth: day. day := Integer readFrom: aStream]. [aStream peek isAlphaNumeric] whileFalse: [aStream skip: 1]. year := Integer readFrom: aStream. year < 10 ifTrue: [year := 2000 + year] ifFalse: [ year < 1900 ifTrue: [ year := 1900 + year]]. ^ self year: year month: month day: day
starting: aDateAndTime ^super starting: (aDateAndTime midnight) duration: (Duration days: 1)
tomorrow ^ self today next
year: year day: dayOfYear ^ self starting: (DateAndTime year: year day: dayOfYear)
year: year month: month day: day ^ self starting: (DateAndTime year: year month: month day: day)
yesterday ^ self today previous
</methods> <methods> Squeak.Year <category>squeak protocol</category>
asYear ^ self
daysInMonth self shouldNotImplement
daysInYear ^ self duration days.
printOn: aStream aStream nextPutAll: 'a Year ('. self start year printOn: aStream. aStream nextPutAll: ')'.
</methods> <methods> Squeak.Year class <category>squeak protocol</category>
current ^ self year: (DateAndTime now year)
isLeapYear: aYearInteger | adjustedYear | adjustedYear := aYearInteger > 0 ifTrue: [aYearInteger] ifFalse: [(aYearInteger + 1) negated]. "There was no year 0" ^ ((adjustedYear \\ 4 ~= 0) or: [(adjustedYear \\ 100 = 0) and: [adjustedYear \\ 400 ~= 0]]) not.
starting: aDateAndTime duration: aDuration "Override - start from midnight" | midnight | midnight := aDateAndTime asDateAndTime midnight. ^ super starting: midnight duration: (Duration days: (self daysInYear: midnight year)).
year: aYear ^ self starting: (DateAndTime year: aYear month: 1 day: 1).
</methods> <methods> Squeak.Year class <category>smalltalk-80</category>
daysInYear: yearInteger ^ 365 + ((self isLeapYear: yearInteger) ifTrue: [1] ifFalse: [0]).
leapYear: yearInteger ^ (self isLeapYear: yearInteger) ifTrue: [1] ifFalse: [0]
</methods> <methods> Squeak.Week <category>squeak protocol</category>
asWeek ^ self
printOn: aStream aStream nextPutAll: 'a Week starting: '. self start printOn: aStream.
</methods> <methods> Squeak.Week <category>deprecated</category>
do: aBlock self deprecated: 'Use #datesDo:'. self datesDo: aBlock
index self deprecated: 'obsolete'. ^ self indexInMonth: self asMonth
indexInMonth: aMonth "1=first week, 2=second week, etc." self deprecated: 'obsolete'. ^ (Date dayOfWeek: aMonth dayOfWeekName) + self dayOfMonth - 2 // 7 + 1
</methods> <methods> Squeak.Week class <category>squeak protocol</category>
dayNames ^ DayNames
indexOfDay: aSymbol ^ DayNames indexOf: aSymbol asSymbol
startDay ^ StartDay ifNil: [ StartDay := DayNames first ]
startDay: aSymbol (DayNames includes: aSymbol asSymbol) ifTrue: [ StartDay := aSymbol asSymbol ] ifFalse: [ self error: aSymbol, ' is not a recognised day name' ]
starting: aDateAndTime duration: aDuration "Override - the duration is always one week. Week will start from the Week class>>startDay" | midnight delta adjusted | midnight := aDateAndTime asDateAndTime midnight. delta := ((midnight dayOfWeek + 7 - (DayNames indexOf: self startDay)) rem: 7) abs. adjusted := midnight - (Duration days: delta hours: 0 minutes: 0 seconds: 0). ^ super starting: adjusted duration: (Duration weeks: 1).
</methods> <methods> Squeak.Week class <category>smalltalk-80</category>
nameOfDay: anIndex ^ DayNames at: anIndex
</methods> <methods> Squeak.Week class <category>deprecated</category>
startMonday self deprecated: 'Use #startDay'. ^ self startDay = #Monday
toggleStartMonday self deprecated: 'Use #startDay:'. (self startDay = #Monday) ifTrue: [ self startDay: #Sunday ] ifFalse: [ self startDay: #Monday ]
</methods> <methods> Squeak.Duration <category>ansi protocol</category>
* operand "operand is a Number" ^ self class nanoSeconds: ( (self asNanoSeconds * operand) asInteger).
+ operand "operand is a Duration" ^ self class nanoSeconds: (self asNanoSeconds + operand asNanoSeconds)
- operand "operand is a Duration" ^ self + operand negated
/ operand "operand is a Duration or a Number" ^ operand isNumber ifTrue: [ self class nanoSeconds: (self asNanoSeconds / operand) asInteger ] ifFalse: [ self asNanoSeconds / operand asDuration asNanoSeconds ] .
< comparand ^ self asNanoSeconds < comparand asNanoSeconds
= comparand "Answer whether the argument is a <Duration> representing the same period of time as the receiver." ^ self == comparand ifTrue: [true] ifFalse: [self species = comparand species ifTrue: [self asNanoSeconds = comparand asNanoSeconds] ifFalse: [false] ]
abs ^ self class seconds: seconds abs nanoSeconds: nanos abs
asDuration ^ self
asSeconds ^ seconds
days "Answer the number of days the receiver represents." ^ seconds quo: SecondsInDay
hash ^seconds bitXor: nanos
hours "Answer the number of hours the receiver represents." ^ (seconds rem: SecondsInDay) quo: SecondsInHour
minutes "Answer the number of minutes the receiver represents." ^ (seconds rem: SecondsInHour) quo: SecondsInMinute
negated ^ self class seconds: seconds negated nanoSeconds: nanos negated
negative ^ self positive not
positive ^ seconds = 0 ifTrue: [ nanos positive ] ifFalse: [ seconds positive ]
seconds "Answer the number of seconds the receiver represents." ^ (seconds rem: SecondsInMinute) + (nanos / NanosInSecond)
</methods> <methods> Squeak.Duration <category>squeak protocol</category>
// operand "operand is a Duration or a Number" ^ operand isNumber ifTrue: [ self class nanoSeconds: (self asNanoSeconds // operand) asInteger ] ifFalse: [ self asNanoSeconds // operand asDuration asNanoSeconds ]
asDelay ^ Delay forDuration: self
asMilliSeconds ^ ((seconds * NanosInSecond) + nanos) // (10 raisedToInteger: 6)
asNanoSeconds ^ (seconds * NanosInSecond) + nanos
nanoSeconds ^ nanos
printOn: aStream "Format as per ANSI 5.8.2.16: [-]D:HH:MM:SS[.S]" | d h m s n | d := self days abs. h := self hours abs. m := self minutes abs. s := self seconds abs truncated. n := self nanoSeconds abs. self negative ifTrue: [ aStream nextPut: $- ]. d printOn: aStream. aStream nextPut: $:. h < 10 ifTrue: [ aStream nextPut: $0. ]. h printOn: aStream. aStream nextPut: $:. m < 10 ifTrue: [ aStream nextPut: $0. ]. m printOn: aStream. aStream nextPut: $:. s < 10 ifTrue: [ aStream nextPut: $0. ]. s printOn: aStream. n = 0 ifFalse: [ | z ps | aStream nextPut: $.. ps := n printString padded: #left to: 9 with: $0. z := ps findLast: [ :c | c asciiValue > $0 asciiValue ]. ps from: 1 to: z do: [ :c | aStream nextPut: c ] ].
roundTo: aDuration "e.g. if the receiver is 5 minutes, 37 seconds, and aDuration is 2 minutes, answer 6 minutes." ^ self class nanoSeconds: (self asNanoSeconds roundTo: aDuration asNanoSeconds)
truncateTo: aDuration "e.g. if the receiver is 5 minutes, 37 seconds, and aDuration is 2 minutes, answer 4 minutes." ^ self class nanoSeconds: (self asNanoSeconds truncateTo: aDuration asNanoSeconds)
\\ operand "modulo. Remainder defined in terms of //. Answer a Duration with the same sign as aDuration. operand is a Duration or a Number." ^ operand isNumber ifTrue: [ self class nanoSeconds: (self asNanoSeconds \\ operand) ] ifFalse: [ self - (operand * (self // operand)) ]
</methods> <methods> Squeak.Duration <category>initialize-release</category>
initialize self seconds: 0 nanoSeconds: 0.
</methods> <methods> Squeak.Duration <category>private</category>
seconds: secondCount nanoSeconds: nanoCount "Private - only used by Duration class" seconds := secondCount. nanos := nanoCount
storeOn: aStream aStream nextPut: $(; nextPutAll: self className; nextPutAll: ' seconds: '; print: seconds; nextPutAll: ' nanoSeconds: '; print: nanos; nextPut: $).
ticks "Answer an array {days. seconds. nanoSeconds}. Used by DateAndTime and Time" ^ Array with: self days with: (self hours * 3600) + (self minutes * 60 ) + (self seconds truncated) with: self nanoSeconds
</methods> <methods> Squeak.Duration class <category>ansi protocol</category>
days: days hours: hours minutes: minutes seconds: seconds ^ self days: days hours: hours minutes: minutes seconds: seconds nanoSeconds: 0.
seconds: aNumber ^ self days: 0 hours: 0 minutes: 0 seconds: aNumber nanoSeconds: 0.
zero ^ (self basicNew) seconds: 0 nanoSeconds: 0; yourself.
</methods> <methods> Squeak.Duration class <category>squeak protocol</category>
days: aNumber ^ self days: aNumber hours: 0 minutes: 0 seconds: 0 nanoSeconds: 0
days: days hours: hours minutes: minutes seconds: seconds nanoSeconds: nanos ^ self nanoSeconds: ( ( (days * SecondsInDay) + (hours * SecondsInHour) + (minutes * SecondsInMinute) + seconds ) * NanosInSecond ) + nanos.
fromString: aString ^ self readFrom: (ReadStream on: aString)
hours: aNumber ^ self days: 0 hours: aNumber minutes: 0 seconds: 0 nanoSeconds: 0
milliSeconds: milliCount ^ self days: 0 hours: 0 minutes: 0 seconds: 0 nanoSeconds: (milliCount * (10 raisedToInteger: 6))
minutes: aNumber ^ self days: 0 hours: 0 minutes: aNumber seconds: 0 nanoSeconds: 0
month: aMonth "aMonth is an Integer or a String" ^ (Month month: aMonth year: Year current year) duration
nanoSeconds: nanos ^ self new seconds: (nanos quo: NanosInSecond) nanoSeconds: (nanos rem: NanosInSecond) rounded; yourself.
readFrom: aStream "Formatted as per ANSI 5.8.2.16: [-]D:HH:MM:SS[.S] To assiste DateAndTime>>#readFrom: SS may be unpadded or absent." | sign days hours minutes seconds nanos ws ch | sign := (aStream peekFor: $-) ifTrue: [-1] ifFalse: [1]. days := (aStream upTo: $:) asInteger sign: sign. hours := (aStream upTo: $:) asInteger sign: sign. minutes := (aStream upTo: $:) asInteger sign: sign. aStream atEnd ifTrue: [seconds := 0. nanos := 0] ifFalse: [ ws := String new writeStream. [ch := aStream next. (ch isNil) | (ch = $.)] whileFalse: [ ws nextPut: ch ]. seconds := ws contents asInteger sign: sign. ws reset. 9 timesRepeat: [ ch := aStream next. ws nextPut: (ch ifNil: [$0] ifNotNil: [ch]) ]. nanos := ws contents asInteger sign: sign]. ^ self days: days hours: hours minutes: minutes seconds: seconds nanoSeconds: nanos. " '0:00:00:00' asDuration '0:00:00:00.000000001' asDuration '0:00:00:00.999999999' asDuration '0:00:00:00.100000000' asDuration '0:00:00:00.10' asDuration '0:00:00:00.1' asDuration '0:00:00:01' asDuration '0:12:45:45' asDuration '1:00:00:00' asDuration '365:00:00:00' asDuration '-7:09:12:06.10' asDuration '+0:01:02' asDuration '+0:01:02:3' asDuration "
seconds: seconds nanoSeconds: nanos ^ self days: 0 hours: 0 minutes: 0 seconds: seconds nanoSeconds: nanos
weeks: aNumber ^ self days: (aNumber * 7) hours: 0 minutes: 0 seconds: 0 nanoSeconds: 0
</methods> <methods> Squeak.Month <category>squeak protocol</category>
asMonth ^ self
daysInMonth ^ self duration days.
index ^ self monthIndex
name ^ self monthName
previous ^ self class starting: (self start - 1)
printOn: aStream aStream nextPutAll: self monthName, ' ', self year printString.
</methods> <methods> Squeak.Month <category>deprecated</category>
eachWeekDo: aBlock self deprecated: 'Use #weeksDo:'. self weeksDo: aBlock
</methods> <methods> Squeak.Month class <category>squeak protocol</category>
month: month year: year "Create a Month for the given <year> and <month>. <month> may be a number or a String with the name of the month. <year> should be with 4 digits." ^ self starting: (DateAndTime year: year month: month day: 1)
readFrom: aStream | m y c | m := (ReadWriteStream with: '' copy) reset. [(c := aStream next) isSeparator] whileFalse: [m nextPut: c]. [(c := aStream next) isSeparator] whileTrue. y := (ReadWriteStream with: '' copy) reset. y nextPut: c. [aStream atEnd] whileFalse: [y nextPut: aStream next]. ^ self month: m contents year: y contents "Month readFrom: 'July 1998' readStream"
starting: aDateAndTime duration: aDuration "Override - a each month has a defined duration" | start adjusted days | start := aDateAndTime asDateAndTime. adjusted := DateAndTime year: start year month: start month day: 1. days := self daysInMonth: adjusted month forYear: adjusted year. ^ super starting: adjusted duration: (Duration days: days)
</methods> <methods> Squeak.Month class <category>smalltalk-80</category>
daysInMonth: indexOrName forYear: yearInteger | index | index := indexOrName isInteger ifTrue: [indexOrName] ifFalse: [self indexOfMonth: indexOrName]. ^ (DaysInMonth at: index) + ((index = 2 and: [Year isLeapYear: yearInteger]) ifTrue: [1] ifFalse: [0])
indexOfMonth: aMonthName 1 to: 12 do: [ :i | (aMonthName, '*' match: (MonthNames at: i)) ifTrue: [^i] ]. self error: aMonthName , ' is not a recognized month name'.
nameOfMonth: anIndex ^ MonthNames at: anIndex.
</methods> <methods> Squeak.Preferences class <category>initialize-release</category>
initialize DictionaryOfPreferences at:#showDeprecationWarnings put: false asValue; at: #compileUseNewCompiler put: true asValue; yourself.
</methods> <methods> Squeak.Preferences class <category>preference-object access</category>
preferenceAt: aSymbol ifAbsent: aBlock "Answer the Preference object at the given symbol, or the value of aBlock if not present" ^ DictionaryOfPreferences at: aSymbol ifAbsent: [aBlock value]
</methods> <methods> Squeak.Preferences class <category>get/set</category>
setPreference: prefSymbol toValue: aBoolean "Set the given preference to the given value, and answer that value" ^ (self preferenceAt: prefSymbol ifAbsent: [^ aBoolean]) value: aBoolean
valueOfFlag: aFlagName ifAbsent: booleanValuedBlock "Answer the value of the given flag" ^ (self preferenceAt: aFlagName ifAbsent: [^ booleanValuedBlock value]) value
</methods> <methods> Squeak.Preferences class <category>standard queries</category>
showDeprecationWarnings ^ self valueOfFlag: #showDeprecationWarnings ifAbsent: [false]
</methods> <methods> Squeak.Time <category>ansi protocol</category>
< aTime ^ self asDuration < aTime asDuration
= aTime ^self species = aTime species and: [self hours = aTime hours and: [self minutes = aTime minutes and: [self seconds = aTime seconds]]]
duration ^ Duration zero
hash ^ self ticks hash
hour ^ self hour24
hour12 "Answer an <integer> between 1 and 12, inclusive, representing the hour of the day in the 12-hour clock of the local time of the receiver." ^ self hour24 - 1 \\ 12 + 1
hour24 ^ self asDuration hours
meridianAbbreviation ^ self hour < 12 ifTrue: ['AM'] ifFalse: ['PM'].
minute ^ self asDuration minutes
second ^ self asDuration seconds
</methods> <methods> Squeak.Time <category>smalltalk-80</category>
addSeconds: nSeconds "Answer a Time that is nSeconds after the receiver." ^ self class seconds: self asSeconds + nSeconds
addTime: timeAmount "Answer a Time that is timeInterval after the receiver. timeInterval is an instance of Date or Time." ^ self class seconds: self asSeconds + timeAmount asSeconds
asSeconds "Answer the number of seconds since midnight of the receiver." ^ seconds
hours ^ self hour
intervalString "Treat the time as a difference. Give it in hours and minutes with two digits of accuracy." | d | d := self asDuration. ^ String streamContents: [ :s | d hours > 0 ifTrue: [s print: d hours; nextPutAll: ' hours']. d minutes > 0 ifTrue: [s space; print: d minutes; nextPutAll: ' minutes']. d seconds > 0 ifTrue: [s space; print: d seconds; nextPutAll: ' seconds'] ].
minutes ^ self asDuration minutes
seconds ^ self second
subtractTime: timeAmount "Answer a Time that is timeInterval before the receiver. timeInterval is an instance of Date or Time." ^ self class seconds: self asSeconds - timeAmount asSeconds
</methods> <methods> Squeak.Time <category>squeak protocol</category>
asDate ^ Date today
asDateAndTime ^ DateAndTime today + self
asDuration "Answer the duration since midnight" ^ Duration seconds: seconds nanoSeconds: nanos
asMonth ^ self asDateAndTime asMonth
asNanoSeconds "Answer the number of nanoseconds since midnight" ^ self asDuration asNanoSeconds
asTime ^ self
asTimeStamp ^ self asDateAndTime asTimeStamp
asWeek ^ self asDateAndTime asWeek
asYear ^ self asDateAndTime asYear
nanoSecond ^ nanos
to: anEnd "Answer a Timespan. anEnd must respond to #asDateAndTime" ^ self asDateAndTime to: anEnd
</methods> <methods> Squeak.Time <category>printing</category>
hhmm24 "Return a string of the form 1123 (for 11:23 am), 2154 (for 9:54 pm), of exactly 4 digits" ^(String streamContents: [ :aStream | self print24: true showSeconds: false on: aStream ]) copyWithout: $:
print24 "Return as 8-digit string 'hh:mm:ss', with leading zeros if needed" ^String streamContents: [ :aStream | self print24: true on: aStream ]
print24: hr24 on: aStream "Format is 'hh:mm:ss' or 'h:mm:ss am' " self print24: hr24 showSeconds: true on: aStream
print24: hr24 showSeconds: showSeconds on: aStream "Format is 'hh:mm:ss' or 'h:mm:ss am' or, if showSeconds is false, 'hh:mm' or 'h:mm am'" | h m s | h := self hour. m := self minute. s := self second. hr24 ifTrue: [ h < 10 ifTrue: [ aStream nextPutAll: '0' ]. h printOn: aStream ] ifFalse: [ h > 12 ifTrue: [h - 12 printOn: aStream] ifFalse: [h < 1 ifTrue: [ 12 printOn: aStream ] ifFalse: [ h printOn: aStream ]]]. aStream nextPutAll: (m < 10 ifTrue: [':0'] ifFalse: [':']). m printOn: aStream. showSeconds ifTrue: [ aStream nextPutAll: (s < 10 ifTrue: [':0'] ifFalse: [':']). s asInteger printOn: aStream ]. hr24 ifFalse: [ aStream nextPutAll: (h < 12 ifTrue: [' am'] ifFalse: [' pm']) ].
printMinutes "Return as string 'hh:mm pm' " ^String streamContents: [ :aStream | self print24: false showSeconds: false on: aStream ]
printOn: aStream self print24: false showSeconds: (self seconds ~= 0) on: aStream
storeOn: aStream aStream print: self printString; nextPutAll: ' asTime'
</methods> <methods> Squeak.Time <category>deprecated</category>
hours: anInteger self deprecated: 'Deprecated'; hours: anInteger minutes: 0 seconds: 0.
hours: hourInteger minutes: minInteger seconds: secInteger self deprecated: 'Deprecated'; setSeconds: (hourInteger * SecondsInHour) + (minInteger * SecondsInMinute) + secInteger.
setSeconds: secondCount self deprecated: 'Deprecated'. self ticks: (Array with: 0 with: secondCount with: 0)
</methods> <methods> Squeak.Time <category>private</category>
ticks "Answer an Array: { seconds. nanoSeconds }" ^ Array with: 0 with: seconds with: nanos.
ticks: anArray "ticks is an Array: { days. seconds. nanoSeconds }" seconds := anArray second. nanos := anArray third.
</methods> <methods> Squeak.Time <category>comparing</category>
species ^Core.Time
</methods> <methods> Squeak.Time class <category>smalltalk-80</category>
dateAndTimeFromSeconds: secondCount ^ Array with: (Date fromSeconds: secondCount) with: (Time fromSeconds: secondCount \\ 86400)
dateAndTimeNow "Answer a two-element Array of (Date today, Time now)." ^ self dateAndTimeFromSeconds: self totalSeconds
fromSeconds: secondCount "Answer an instance of me that is secondCount number of seconds since midnight." ^ self seconds: secondCount
millisecondsToRun: timedBlock "Answer the number of milliseconds timedBlock takes to return its value." | initialMilliseconds | initialMilliseconds := self millisecondClockValue. timedBlock value. ^ self millisecondClockValue - initialMilliseconds
new "Answer a Time representing midnight" ^ self midnight
primMillisecondClock "Primitive. Answer the number of milliseconds since the millisecond clock was last reset or rolled over. Answer zero if the primitive fails. Optional. See Object documentation whatIsAPrimitive." ^ Core.Time millisecondClockValue
primSecondsClock "Answer the number of seconds since 00:00 on the morning of January 1, 1901 (a 32-bit unsigned number). Essential. See Object documentation whatIsAPrimitive. " ^ Core.Time totalSeconds "Note : Local time"
readFrom: aStream "Read a Time from the stream in the form: <hour>:<minute>:<second> <am/pm> <minute>, <second> or <am/pm> may be omitted. e.g. 1:59:30 pm; 8AM; 15:30" | hour minute second ampm | hour := Integer readFrom: aStream. minute := 0. second := 0. (aStream peekFor: $:) ifTrue: [ minute := Integer readFrom: aStream. (aStream peekFor: $:) ifTrue: [ second := Integer readFrom: aStream ]]. aStream skipSeparators. (aStream atEnd not and: [aStream peek isLetter]) ifTrue: [ampm := aStream next asLowercase. (ampm = $p and: [hour < 12]) ifTrue: [hour := hour + 12]. (ampm = $a and: [hour = 12]) ifTrue: [hour := 0]. (aStream peekFor: $m) ifFalse: [aStream peekFor: $M ]]. ^ self hour: hour minute: minute second: second "Time readFrom: (ReadStream on: '2:23:09 pm')"
totalSeconds "Answer the total seconds since the Squeck epoch: 1 January 1901." ^ self primSecondsClock
</methods> <methods> Squeak.Time class <category>general inquiries</category>
condenseBunches: aCollectionOfSeconds | secArray pause now out prev bunchEnd ago | "Identify the major intervals in a bunch of numbers. Each number is a seconds since 1901 that represents a date and time. We want the last event in a bunch. Return array of seconds for: Every event in the last half hour. Every bunch separated by 30 min in the last 24 hours. Every bunch separated by two hours before that." "Time condenseBunches: (#(20 400 401 20000 20200 20300 40000 45000 200000 201000 202000) collect: [ :tt | self totalSeconds - tt]) " secArray := aCollectionOfSeconds asSortedCollection. pause := 1. now := self totalSeconds. out := OrderedCollection new. prev := 0. bunchEnd := nil. secArray reverseDo: [:secs | "descending" ago := now - secs. ago > (60*30) ifTrue: [pause := "60*30" 1800]. ago > (60*60*24) ifTrue: [pause := "60*120" 7200]. ago - prev >= pause ifTrue: [out add: bunchEnd. bunchEnd := secs]. prev := ago]. out add: bunchEnd. out removeFirst. ^ out
humanWordsForSecondsAgo: secs | date today | "Return natural language for this date and time in the past." secs <= 1 ifTrue: [^ 'a second ago']. secs < 45 ifTrue: [^ secs printString, ' seconds ago']. secs < 90 ifTrue: [^ 'a minute ago']. secs < "45*60" 2700 ifTrue: [^ (secs//60) printString, ' minutes ago']. secs < "90*60" 5400 ifTrue: [^ 'an hour ago']. secs < "18*60*60" 64800 ifTrue: [^ (secs//3600) printString, ' hours ago']. date := Date fromSeconds: self totalSeconds - secs. "now work with dates" today := Date today. date > (today subtractDays: 2) ifTrue: [^ 'yesterday']. date > (today subtractDays: 8) ifTrue: [^ 'last ', date dayOfWeekName]. date > (today subtractDays: 13) ifTrue: [^ 'a week ago']. date > (today subtractDays: 28) ifTrue: [ ^ ((today subtractDate: date)//7) printString, ' weeks ago']. date > (today subtractDays: 45) ifTrue: [^ 'a month ago']. date > (today subtractDays: 300) ifTrue: [^ 'last ', date monthName]. ^ date monthName, ', ', date year printString "Example #(0.5 30 62 130 4000 10000 60000 90000 345600 864000 1728000 3456000 17280000 34560000 345600000) collect: [:ss | Time humanWordsForSecondsAgo: ss]. "
millisecondClockValue "Answer the number of milliseconds since the millisecond clock was last reset or rolled over. Answer 0 if the primitive fails." ^ Core.Time millisecondClockValue
namesForTimes: arrayOfSeconds | simpleEnglish prev final prevPair myPair | "Return English descriptions of the times in the array. They are each seconds since 1901. If two names are the same, append the date and time to distinguish them." simpleEnglish := arrayOfSeconds collect: [:secsAgo | self humanWordsForSecondsAgo: self totalSeconds - secsAgo]. prev := ''. final := simpleEnglish copy. simpleEnglish withIndexDo: [:eng :ind | eng = prev ifFalse: [eng] ifTrue: ["both say 'a month ago'" prevPair := self dateAndTimeFromSeconds: (arrayOfSeconds at: ind-1). myPair := self dateAndTimeFromSeconds: (arrayOfSeconds at: ind). (final at: ind-1) = prev ifTrue: ["only has 'a month ago'" final at: ind-1 put: (final at: ind-1), ', ', prevPair first mmddyyyy]. final at: ind put: (final at: ind), ', ', myPair first mmddyyyy. prevPair first = myPair first ifTrue: [ (final at: ind-1) last == $m ifFalse: ["date but no time" final at: ind-1 put: (final at: ind-1), ', ', prevPair second printMinutes]. final at: ind put: (final at: ind), ', ', myPair second printMinutes]]. prev := eng]. ^ final
</methods> <methods> Squeak.Time class <category>benchmarks</category>
benchmarkMillisecondClock "Time benchmarkMillisecondClock" "Benchmark the time spent in a call to Time>>millisecondClockValue. On the VM level this tests the efficiency of calls to ioMSecs()." "PII/400 Windows 98: 0.725 microseconds per call" | temp1 temp2 temp3 delayTime nLoops time | delayTime := 5000. "Time to run benchmark is approx. 2*delayTime" "Don't run the benchmark if we have an active delay since we will measure the additional penalty in the primitive dispatch mechanism (see #benchmarkPrimitiveResponseDelay)." Delay anyActive ifTrue:[ ^self notify:'Some delay is currently active. Running this benchmark will not give any useful result.']. "Flush the cache for this benchmark so we will have a clear cache hit for each send to #millisecondClockValue below" Object flushCache. temp1 := 0. temp2 := self. "e.g., temp1 == Time" temp3 := self millisecondClockValue + delayTime. "Now check how often we can run the following loop in the given time" [temp2 millisecondClockValue < temp3] whileTrue:[temp1 := temp1 + 1]. nLoops := temp1. "Remember the loops we have run during delayTime" "Setup the second loop" temp1 := 0. temp3 := nLoops. "Now measure how much time we spend without sending #millisecondClockValue" time := Time millisecondClockValue. [temp1 < temp3] whileTrue:[temp1 := temp1 + 1]. time := Time millisecondClockValue - time. "And compute the number of microseconds spent per call to #millisecondClockValue" ^((delayTime - time * 1000.0 / nLoops) truncateTo: 0.001) printString, ' microseconds per call to Time>>millisecondClockValue'
benchmarkPrimitiveResponseDelay "Time benchmarkPrimitiveResponseDelay" "Benchmark the overhead for primitive dispatches with an active Delay. On the VM level, this tests the efficiency of ioLowResMSecs." "PII/400 Windows98: 0.128 microseconds per prim" "ar 9/6/1999: This value is *extremely* important for stuff like sockets etc. I had a bad surprise when Michael pointed this particular problem out: Using the hardcoded clock() call for ioLowResMSecs on Win32 resulted in an overhead of 157.4 microseconds per primitive call - meaning you can't get no more than approx. 6000 primitives per second on my 400Mhz PII system with an active delay! BTW, it finally explains why Squeak seemed soooo slow when running PWS or other socket stuff. The new version (not using clock() but some Windows function) looks a lot better (see above; approx. 8,000,000 prims per sec with an active delay)." | nLoops bb index baseTime actualTime delayTime | delayTime := 5000. "Time to run this test is approx. 3*delayTime" Delay anyActive ifTrue:[ ^self notify:'Some delay is currently active. Running this benchmark will not give any useful result.']. bb := Array new: 1. "The object we send the prim message to" "Compute the # of loops we'll run in a decent amount of time" [(Delay forMilliseconds: delayTime) wait] forkAt: Processor userInterruptPriority. nLoops := 0. [Delay anyActive] whileTrue:[ bb basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize. nLoops := nLoops + 1. ]. "Flush the cache and make sure #basicSize is in there" Object flushCache. bb basicSize. "Now run the loop without any active delay for getting an idea about its actual speed." baseTime := self millisecondClockValue. index := nLoops. [index > 0] whileTrue:[ bb basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize. index := index - 1. ]. baseTime := self millisecondClockValue - baseTime. "Setup the active delay but try to never make it active" [(Delay forMilliseconds: delayTime + delayTime) wait] forkAt: Processor userInterruptPriority. "And run the loop" actualTime := self millisecondClockValue. index := nLoops. [index > 0] whileTrue:[ bb basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize; basicSize. index := index - 1. ]. actualTime := self millisecondClockValue - actualTime. "And get us some result" ^((actualTime - baseTime) * 1000 asFloat / (nLoops * 10) truncateTo: 0.001) printString, ' microseconds overhead per primitive call'
</methods> <methods> Squeak.Time class <category>squeak protocol</category>
current ^ self now
hour: hour minute: minute second: second "Answer a Time" ^ self hour: hour minute: minute second: second nanoSecond: 0
hour: hour minute: minute second: second nanoSecond: nanoCount "Answer a Time - only second precision for now" ^ self seconds: (hour * SecondsInHour) + (minute * SecondsInMinute) + second nanoSeconds: nanoCount
milliseconds: currentTime since: lastTime "Answer the elapsed time since last recorded in milliseconds. Compensate for rollover." | delta | delta := currentTime - lastTime. ^ delta < 0 ifTrue: [SmallInteger maxVal + delta] ifFalse: [delta]
millisecondsSince: lastTime "Answer the elapsed time since last recorded in milliseconds. Compensate for rollover." ^self milliseconds: self millisecondClockValue since: lastTime
seconds: seconds "Answer a Time from midnight" ^ self seconds: seconds nanoSeconds: 0
seconds: seconds nanoSeconds: nanoCount "Answer a Time from midnight" ^ self basicNew ticks: (Duration seconds: seconds nanoSeconds: nanoCount) ticks; yourself
</methods> <methods> Squeak.Time class <category>instance creation</category>
fromString: aString "Answer a new instance for the value given by aString. Time fromString: '11:55:23 am' " ^self readFrom: (ReadStream on: aString)
midnight "Answer a new instance at midnight." ^self fromSeconds: 0
noon "Answer a new instance at noon." ^self fromSeconds: 43200
</methods> <methods> Squeak.Time class <category>ansi protocol</category>
now "Answer a Time representing the time right now - this is a 24 hour clock." ^ self seconds: self totalSeconds \\ 86400.
</methods> <methods> Core.Fraction <category>squeak-testing</category>
isFraction ^true
</methods> <methods> Core.ClassDescription <category>squeak-fileIn/Out</category>
methodsFor: aString stamp: ignored ^self methodsFor: aString
</methods> <methods> Core.SequenceableCollection class <category>squeak-instance creation</category>
ofSize: anInteger ^ self withSize: anInteger
</methods> <methods> Core.SequenceableCollection class <category>squeak-stream creation</category>
streamContents: blockWithArg | stream | stream := WriteStream on: (self new: 100). blockWithArg value: stream. ^stream contents
streamContents: blockWithArg limitedTo: sizeLimit | stream | stream := LimitedWriteStream on: (self new: (100 min: sizeLimit)). stream setLimit: sizeLimit limitBlock: [^ stream contents]. blockWithArg value: stream. ^ stream contents " String streamContents: [:s | 1000 timesRepeat: [s nextPutAll: 'Junk']] limitedTo: 25 'JunkJunkJunkJunkJunkJunkJ' "
</methods> <methods> Core.SequenceableCollection <category>squeak-copying</category>
allButFirst "Answer a copy of the receiver containing all but the first element. Raise an error if there are not enough elements." ^ self allButFirst: 1.
allButFirst: n "Answer all but the first n elements of the receiver." | size | size := self size. ^self copyFrom: ((size - ((size - n min: size) max: 0) + 1 min: size + 1) max: 1) to: size "(-5 to: 5) collect: [:n| 'yo!' allButFirst: n]"
allButLast "Answer a copy of the receiver containing all but the last element. Raise an error if there are not enough elements." ^ self allButLast: 1
allButLast: n "Answer all but the last n elements of the receiver." | size | size := self size. ^self copyFrom: 1 to: ((size - n max: 0) min: size) "(-5 to: 5) collect: [:n| 'yo!' allButLast: n]"
</methods> <methods> Core.SequenceableCollection <category>squeak-converting</category>
asWordArray ^self as: WordArray
</methods> <methods> Core.SequenceableCollection <category>squeak-accessing</category>
at: index ifAbsent: exceptionBlock "Answer the element at my position index. If I do not contain an element at index, answer the result of evaluating the argument, exceptionBlock." (index between: 1 and: self size) ifTrue: [^ self at: index]. ^ exceptionBlock value
atRandom "Answer a random element of the receiver. Uses a shared random number generator owned by class Collection. If you use this a lot, define your own instance of Random and use #atRandom:. Causes an error if self has no elements." ^ self atRandom: Collection randomForPicking "Examples: #('one' 'or' 'the' 'other') atRandom (1 to: 10) atRandom 'Just pick one of these letters at random' atRandom "
atRandom: aGenerator "Answer a random element of the receiver. Uses aGenerator which should be kept by the user in a variable and used every time. Use this instead of #atRandom for better uniformity of random numbers because only you use the generator. Causes an error if self has no elements." ^ self at: (aGenerator nextInt: self size)
</methods> <methods> Core.SequenceableCollection <category>squeak-enumerating</category>
collect: aBlock from: firstIndex to: lastIndex "Refer to the comment in Collection|collect:." | result | result := self species new: lastIndex - firstIndex + 1. firstIndex to: lastIndex do: [:index | result at: index put: (aBlock value: (self at: index))]. ^ result
</methods> <methods> Core.SequenceableCollection <category>squeak-copying</category>
copyAfter: anElement "Answer a copy of the receiver from after the first occurence of anElement up to the end. If no such element exists, answer an empty copy." ^ self allButFirst: (self indexOf: anElement ifAbsent: [^ self copyEmpty])
copyAfterLast: anElement "Answer a copy of the receiver from after the last occurence of anElement up to the end. If no such element exists, answer an empty copy." ^ self allButFirst: (self lastIndexOf: anElement ifAbsent: [^ self copyEmpty])
copyEmpty ^self copyEmpty: 0
copyUpToLast: anElement "Answer a copy of the receiver from index 1 to the last occurrence of anElement, not including anElement." ^ self first: (self lastIndexOf: anElement ifAbsent: [^ self copy]) - 1
copyWithFirst: newElement "Answer a copy of the receiver that is 1 bigger than the receiver with newElement as the first element." | newIC | newIC := self species ofSize: self size + 1. newIC replaceFrom: 2 to: self size + 1 with: self startingAt: 1. newIC at: 1 put: newElement. ^ newIC
copyWithoutIndex: index "Return a copy containing all elements except the index-th." | copy | copy := self species ofSize: self size - 1. copy replaceFrom: 1 to: index - 1 with: self startingAt: 1. copy replaceFrom: index to: copy size with: self startingAt: index + 1. ^ copy
</methods> <methods> Core.SequenceableCollection <category>squeak-accessing</category>
eighth "Answer the eighth element of the receiver. Raise an error if there are not enough elements." ^ self checkedAt: 8
</methods> <methods> Core.SequenceableCollection <category>squeak-testing</category>
endsWith: aSequenceableCollection | start | (aSequenceableCollection isEmpty or: [self size < aSequenceableCollection size]) ifTrue: [^false]. start := self size - aSequenceableCollection size. aSequenceableCollection withIndexDo: [:each :index | (self at: start + index) ~= each ifTrue: [^false]]. ^true
</methods> <methods> Core.SequenceableCollection <category>squeak-accessing</category>
fifth "Answer the fifth element of the receiver. Raise an error if there are not enough elements." ^ self checkedAt: 5
</methods> <methods> Core.SequenceableCollection <category>squeak-copying</category>
first: n "Answer the first n elements of a the receiver." ^self copyFrom: 1 to: ((n min: self size) max: 0) "(-5 to: 5) collect: [:n| 'yo!' first: n]"
</methods> <methods> Core.SequenceableCollection <category>squeak-accessing</category>
fourth "Answer the fourth element of the receiver. Raise an error if there are not enough elements." ^ self checkedAt: 4
</methods> <methods> Core.SequenceableCollection <category>squeak-enumerating</category>
from: start to: stop do: aBlock "Evaluate aBlock for all elements between start and stop (inclusive)." start to: stop do: [:index | aBlock value: (self at: index)]
</methods> <methods> Core.SequenceableCollection <category>squeak-testing</category>
hasEqualElements: otherCollection "Answer whether the receiver's size is the same as otherCollection's size, and each of the receiver's elements equal the corresponding element of otherCollection. This should probably replace the current definition of #= ." | size | (otherCollection isKindOf: SequenceableCollection) ifFalse: [^ false]. (size := self size) = otherCollection size ifFalse: [^ false]. 1 to: size do: [:index | (self at: index) = (otherCollection at: index) ifFalse: [^ false]]. ^ true
</methods> <methods> Core.SequenceableCollection <category>squeak-copying</category>
last: n "Answer the last n elements of the receiver." | size | size := self size. ^self copyFrom: ((size - n + 1 min: size + 1) max: 1) to: size "(-5 to: 5) collect: [:n| 'yo!' last: n]"
</methods> <methods> Core.SequenceableCollection <category>squeak-accessing</category>
middle "Answer the middle element of the receiver." self emptyCheck. ^ self at: self size // 2 + 1
ninth "Answer the ninth element of the receiver. Raise an error if there are not enough elements." ^ self checkedAt: 9
</methods> <methods> Core.SequenceableCollection <category>squeak-enumerating</category>
pairsDo: aBlock "Evaluate aBlock with my elements taken two at a time. If there's an odd number of items, ignore the last one. Allows use of a flattened array for things that naturally group into pairs. See also pairsCollect:" 1 to: self size // 2 do: [:index | aBlock value: (self at: 2 * index - 1) value: (self at: 2 * index)] " #(1 'fred' 2 'charlie' 3 'elmer') pairsDo: [:a :b | Transcript cr; show: b, ' is number ', a printString] "
</methods> <methods> Core.SequenceableCollection <category>squeak-converting</category>
reversed "Answer a copy of the receiver with element order reversed." "Example: 'frog' reversed" | n result src | n := self size. result := self species new: n. src := n + 1. 1 to: n do: [:i | result at: i put: (self at: (src := src - 1))]. ^ result
</methods> <methods> Core.SequenceableCollection <category>squeak-accessing</category>
seventh "Answer the seventh element of the receiver. Raise an error if there are not enough elements." ^ self checkedAt: 7
</methods> <methods> Core.SequenceableCollection <category>squeak-copying</category>
shuffled ^ self shuffledBy: Collection randomForPicking "Examples: ($A to: $Z) shuffled "
shuffledBy: aRandom | copy | copy := self shallowCopy. copy size to: 1 by: -1 do: [:i | copy swap: i with: ((1 to: i) atRandom: aRandom)]. ^ copy
</methods> <methods> Core.SequenceableCollection <category>squeak-accessing</category>
sixth "Answer the sixth element of the receiver. Raise an error if there are not enough elements." ^ self checkedAt: 6
</methods> <methods> Core.SequenceableCollection <category>squeak-enumerating</category>
with: otherCollection collect: twoArgBlock "Collect and return the result of evaluating twoArgBlock with corresponding elements from this collection and otherCollection." | result | otherCollection size = self size ifFalse: [self error: 'otherCollection must be the same size']. result := self species new: self size. 1 to: self size do: [:index | result at: index put: (twoArgBlock value: (self at: index) value: (otherCollection at: index))]. ^ result
withIndexCollect: elementAndIndexBlock "Just like with:collect: except that the iteration index supplies the second argument to the block." | result | result := self species new: self size. 1 to: self size do: [:index | result at: index put: (elementAndIndexBlock value: (self at: index) value: index)]. ^ result
withIndexDo: elementAndIndexBlock "Just like with:do: except that the iteration index supplies the second argument to the block." 1 to: self size do: [:index | elementAndIndexBlock value: (self at: index) value: index]
</methods> <methods> Core.Set class <category>squeak-instance creation</category>
newFrom: aCollection "Answer an instance of me containing the same elements as aCollection." | newCollection | newCollection := self new: aCollection size. newCollection addAll: aCollection. ^ newCollection " Set newFrom: #(1 2 2 3) #(1 2 2 3) as: Set "
</methods> <methods> Core.Object class <category>squeak-accessing instances and variables</category>
allSubInstances ^ self allGeneralInstances
</methods> <methods> Core.Object class <category>squeak-instance creation</category>
newFrom: aSimilarObject "Create an object that has similar contents to aSimilarObject. If the classes have any instance varaibles with the same names, copy them across. If this is bad for a class, override this method." ^ (self isVariable ifTrue: [self basicNew: aSimilarObject basicSize] ifFalse: [self basicNew] ) copySameFrom: aSimilarObject
</methods> <methods> Core.Object <category>squeak-error handling</category>
assert: aBlock "Throw an assertion error if aBlock does not evaluates to true." aBlock value ifFalse: [Squeak.AssertionFailure raiseRequestWith: thisContext errorString: 'Assertion failed']
</methods> <methods> Core.Object <category>squeak-accessing</category>
className "Answer a string characterizing the receiver's class, for use in list views for example" ^ self class name asString
</methods> <methods> Core.Object <category>squeak-copying</category>
clone <primitive: 532> "Actual Squeak code is : <primitive: 148>" self primitiveFailed
copyFrom: otherObject | mine his common comm | mine := self class allInstVarNames. his := otherObject class allInstVarNames. comm := mine size min: his size. 1 to: comm do: [:ind | (mine at: ind) = (his at: ind) ifTrue: [self instVarAt: ind put: (otherObject instVarAt: ind)]]. comm + 1 to: (mine size max: his size) do: [:ind | self instVarAt: ind put: nil]. common := self basicSize min: otherObject basicSize. 1 to: common do: [:ind | self basicAt: ind put: (otherObject basicAt: ind)]. common + 1 to: (self basicSize max: otherObject basicSize) do: [:ind | self basicAt: ind put: nil]
copySameFrom: otherObject "Copy to myself all instance variables named the same in otherObject. This ignores otherObject's control over its own inst vars." | myInstVars otherInstVars match | myInstVars := self class allInstVarNames. otherInstVars := otherObject class allInstVarNames. myInstVars doWithIndex: [:each :index | (match := otherInstVars indexOf: each) > 0 ifTrue: [self instVarAt: index put: (otherObject instVarAt: match)]]. 1 to: (self basicSize min: otherObject basicSize) do: [:i | self basicAt: i put: (otherObject basicAt: i)].
</methods> <methods> Core.Object <category>squeak-error handling</category>
deprecated: anExplanationString "Warn that the sending method has been deprecated." Transcript cr; show: thisContext sender printString, ' has been deprecated. ', anExplanationString; flush. Squeak.Preferences showDeprecationWarnings ifTrue: [Squeak.Deprecation raiseSignal: thisContext sender printString, ' has been deprecated. ', anExplanationString]
</methods> <methods> Core.Object <category>squeak-debugging</category>
flag: aSymbol "Send this message, with a relevant symbol as argument, to flag a message for subsequent retrieval. For example, you might put the following line in a number of messages: self flag: #returnHereUrgently Then, to retrieve all such messages, browse all senders of #returnHereUrgently."
</methods> <methods> Core.Object <category>squeak-printing</category>
fullPrintString "Answer a String whose characters are a description of the receiver." ^ String streamContents: [:s | self printOn: s]
</methods> <methods> Core.Object <category>squeak-accessing</category>
ifNotNilDo: aBlock "Evaluate the given block with the receiver as its argument." ^aBlock value: self
in: aBlock "Evaluate the given block with the receiver as its argument." ^ aBlock value: self
</methods> <methods> Core.Object <category>squeak-system primitives</category>
instVarNamed: aString "Return the value of the instance variable in me with that name. Slow and unclean, but very useful. " ^ self instVarAt: (self class allInstVarNames indexOf: aString asString)
instVarNamed: aString put: aValue "Store into the value of the instance variable in me of that name. Slow and unclean, but very useful. " ^ self instVarAt: (self class allInstVarNames indexOf: aString asString) put: aValue
</methods> <methods> Core.Object <category>squeak-testing</category>
isBlock ^false
isCollection ^false
isColor ^false
isFraction ^false
isNumber ^false
</methods> <methods> Core.Object <category>squeak-printing</category>
printStringLimitedTo: limit "Answer a String whose characters are a description of the receiver. If you want to print without a character limit, use fullPrintString." | limitedString | limitedString := String streamContents: [:s | self printOn: s] limitedTo: limit. limitedString size < limit ifTrue: [^ limitedString]. ^ limitedString , '...etc...'
</methods> <methods> Core.Object <category>squeak-accessing</category>
value ^self
</methods> <methods> Core.Stream <category>*seaside2</category>
closed ^false
</methods> <methods> Core.Stream <category>squeak-accessing</category>
nextInto: aCollection "Read the next elements of the receiver into aCollection. Return aCollection or a partial copy if less than aCollection size elements have been read." | sz | sz := self nextAvailable: aCollection size into: aCollection startingAt: 1. ^sz < aCollection size ifTrue: [ aCollection copyFrom: 1 to: sz ] ifFalse: [ aCollection ]
</methods> <methods> Core.Date <category>squeak-inquiries</category>
next "Answer the next day. For compatibility with Week, Month" ^ self addDays: 1
previous "Answer the previous day. For compatibility with Week, Month" ^ self subtractDays: 1
</methods> <methods> Core.Number <category>squeak-converting</category>
adaptToString: rcvr andSend: selector "If I am involved in arithmetic with a String, convert it to a Number." ^ rcvr asNumber perform: selector with: self
</methods> <methods> Core.Number <category>squeak-testing</category>
isNumber ^true
</methods> <methods> Core.Number <category>squeak-converting</category>
sign: aNumber "Return a Number with the same sign as aNumber" ^ aNumber positive ifTrue: [self abs] ifFalse: [self abs negated].
</methods> <methods> Core.MessageSend <category>squeak-evaluating</category>
valueWithArguments: anArray ^ receiver perform: selector withArguments: (self collectArguments: anArray)
valueWithPossibleArgs: anArray self numArgs = 0 ifTrue: [^self value]. self numArgs = anArray size ifTrue: [^self valueWithArguments: anArray]. self numArgs > anArray size ifTrue: [ ^self valueWithArguments: anArray, (Array new: (self numArgs - anArray size)) ]. ^self valueWithArguments: (anArray copyFrom: 1 to: self numArgs)
</methods> <methods> Core.OrderedCollection class <category>squeak-instance creation</category>
newFrom: aCollection "Answer an instance of me containing the same elements as aCollection." | newCollection | newCollection := self new: aCollection size. newCollection addAll: aCollection. ^newCollection " OrderedCollection newFrom: #(1 2 3) #(1 2 3) as: OrderedCollection #(4 2 7)as: SortedCollection "
</methods> <methods> Core.OrderedCollection <category>squeak-copying</category>
reversed "Answer a copy of the receiver with element order reversed. " | newCol | newCol := self species new. self reverseDo: [:elem | newCol addLast: elem]. ^ newCol "#(2 3 4 'fred') reversed"
</methods> <methods> Core.UndefinedObject <category>squeak-copying</category>
clone "Only one instance of UndefinedObject should ever be made, so answer with self."
</methods> <methods> Core.UndefinedObject <category>squeak-testing</category>
ifNotNilDo: aBlock "If the receiver is not nil, answer the evaluation of aBlock (with the receiver as its argument if it takes one), otherwise answer nil. Since the receiver is nil, aBlock is not evaluated and nil is returned. All other objects respond to this by evaluating aBlock with themself as an argument" ^self
isEmptyOrNil "Answer whether the receiver contains any elements, or is nil. Useful in numerous situations where one wishes the same reaction to an empty collection or to nil" ^ true
</methods> <methods> Core.Message <category>squeak-accessing</category>
argument "Answer the first (presumably sole) argument" ^args at: 1
</methods> <methods> Core.Time class <category>squeak protocol</category>
hour: hour minute: minute second: second "Answer a Time" ^self new hours: hour minutes: minute seconds: second
</methods> <methods> Core.Integer <category>squeak-converting</category>
asHexDigit ^'0123456789ABCDEF' at: self+1
asTwoCharacterString "Answer a two-character string representing the receiver, with leading zero if required. Intended for use with integers in the range 0 to 99, but plausible replies given for other values too" ^ (self >= 0 and: [self < 10]) ifTrue: ['0', self printString] ifFalse: [self printString copyFrom: 1 to: 2] " 2 asTwoCharacterString 11 asTwoCharacterString 1943 asTwoCharacterString 0 asTwoCharacterString -2 asTwoCharacterString -234 asTwoCharacterString "
</methods> <methods> Core.Integer <category>squeak-random numbers</category>
atRandom "Answer a random integer from 1 to self. This implementation uses a shared generator. Heavy users should their own implementation or use Interval>atRandom: directly." ^ self atRandom: Collection randomForPicking
atRandom: aGenerator "Answer a random integer from 1 to self picked from aGenerator." ^ aGenerator nextInt: self
</methods> <methods> Core.Integer <category>bit manipulation</category>
bitInvert32 "Answer the 32-bit complement of the receiver." ^ self bitXor: 16rFFFFFFFF
</methods> <methods> Core.Integer <category>printing</category>
printPaddedWith: aCharacter to: anInteger "(( 6 printPaddedWith: $0 to: 2 ))" ^self printPaddedWith: aCharacter to: anInteger base: 10
printPaddedWith: aCharacter to: anInteger base: aBase "(( 6 printPaddedWith: $0 to: 2 base: 10 ))" | aStream | aStream := String new writeStream. self printOn: aStream paddedWith: aCharacter to: anInteger base: aBase. ^aStream contents
printStringBase: base ^ String streamContents: [:strm | self printOn: strm base: base]
</methods> <methods> Kernel.CompiledCode <category>accessing</category>
sourceClass ^self mclass
</methods> <methods> Core.Behavior <category>accessing method dictionary</category>
sourceCodeAt: selector ifAbsent: aBlock ^[self sourceCodeAt: selector] on: KeyNotFoundError do: [:e | aBlock value].
theNonMetaClass ^self
</methods> <methods> Core.Symbol class <category>squeak-instance creation</category>
newFrom: aCollection "Answer an instance of me containing the same elements as aCollection." ^ (aCollection as: String) asSymbol " Symbol newFrom: #( $P $e $n) #( $P $e $n) as: Symbol "
</methods> <methods> Core.Symbol <category>squeak-converting</category>
asMutator "((( #path asMutator )))" ^ (self , ':') asSymbol
capitalized ^ self asString capitalized asSymbol
</methods> <methods> Core.Symbol <category>squeak-copying</category>
clone "Answer with the receiver, because Symbols are unique."
</methods> <methods> Core.Symbol <category>squeak-testing</category>
isUnary ^self numArgs isZero
</methods> <methods> Core.Symbol <category>squeak-evaluating</category>
value: anObject ^anObject perform: self.
value: anObject1 value: anObject2 ^ anObject1 perform: self with: anObject2
</methods> <methods> Kernel.SmalltalkCompiler <category>public access</category>
evaluate: aString in: aContext to: aReceiver "evaluate aString in the given context, and return the result. 2/2/96 sw" | result | result := self evaluate: aString in: aContext receiver: aReceiver notifying: nil ifFail: [^ #failedDoit]. ^ result
</methods> <methods> Core.Boolean <category>squeak-controlling</category>
and: block1 and: block2 "Nonevaluating conjunction without deep nesting. The receiver is evaluated, followed by the blocks in order. If any of these evaluates as false, then return false immediately, without evaluating any further blocks. If all return true, then return true." self ifFalse: [^ false]. block1 value ifFalse: [^ false]. block2 value ifFalse: [^ false]. ^ true
and: block1 and: block2 and: block3 "Nonevaluating conjunction without deep nesting. The receiver is evaluated, followed by the blocks in order. If any of these evaluates as false, then return false immediately, without evaluating any further blocks. If all return true, then return true." self ifFalse: [^false]. block1 value ifFalse: [^false]. block2 value ifFalse: [^false]. block3 value ifFalse: [^false]. ^true
</methods> <methods> Core.Boolean <category>squeak-converting</category>
asString ^self printString
</methods> <methods> Core.Boolean <category>squeak-copying</category>
clone "Receiver has two concrete subclasses, True and False. Only one instance of each should be made, so return self."
</methods> <methods> Core.Boolean <category>squeak-controlling</category>
or: block1 or: block2 "Nonevaluating alternation without deep nesting. The receiver is evaluated, followed by the blocks in order. If any of these evaluates as true, then return true immediately, without evaluating any further blocks. If all return false, then return false." self ifTrue: [^ true]. block1 value ifTrue: [^ true]. block2 value ifTrue: [^ true]. ^ false
</methods> <methods> Core.Interval class <category>squeak-instance creation</category>
newFrom: aCollection "Answer an instance of me containing the same elements as aCollection." | newInterval | newInterval := self from: aCollection first to: aCollection last by: (aCollection last - aCollection first)//(aCollection size - 1). aCollection ~= newInterval ifTrue: [self error: 'The argument is not an arithmetic progression']. ^newInterval " Interval newFrom: #(1 2 3) #(1 2 3) as: Interval #(33. 5. -22) as: Interval (an error) (-4 to: -12 by: -1) as: Interval "
</methods> <methods> Core.GenericException <category>squeak-printing</category>
asString "Return a textual description of the exception." | desc mt | desc := self class name asString. ^(mt := self messageText) == nil ifTrue: [desc] ifFalse: [desc, ': ', mt]
</methods> <methods> Core.GenericException <category>squeak-accessing</category>
receiver ^ self handlerContext receiver
signalerContext ^ self initialContext
</methods> <methods> Core.String class <category>squeak-instance creation</category>
crlf "Answer a string containing a carriage return and a linefeed." ^ self with: Character cr with: Character lf
</methods> <methods> Core.String class <category>squeak-utility</category>
findFirstInString: aString inSet: inclusionMap startingAt: start | i stringSize | "<primitive: 'primitiveFindFirstInString' module: 'MiscPrimitivePlugin'>---from Squeak" " self var: #aString declareC: 'unsigned char *aString'. self var: #inclusionMap declareC: 'char *inclusionMap'." inclusionMap size ~= 256 ifTrue: [ ^0 ]. i := start. stringSize := aString size. [ i <= stringSize and: [ (inclusionMap at: (aString at: i) asciiValue+1) = 0 ] ] whileTrue: [ i := i + 1 ]. i > stringSize ifTrue: [ ^0 ]. ^i
indexOfAscii: anInteger inString: aString startingAt: start | stringSize | "<primitive: 'primitiveIndexOfAsciiInString' module: 'MiscPrimitivePlugin'>---from Squeak" " self var: #aCharacter declareC: 'int anInteger'. self var: #aString declareC: 'unsigned char *aString'." stringSize := aString size. start to: stringSize do: [:pos | (aString at: pos) asciiValue = anInteger ifTrue: [^ pos]]. ^ 0
</methods> <methods> Core.String <category>squeak-converting</category>
+ arg ^ arg adaptToString: self andSend: #+
adaptToString: rcvr andSend: selector "If I am involved in arithmetic with a string, convert us both to numbers, and return the printString of the result." ^ (rcvr asNumber perform: selector with: self asNumber) printString
asHexString | stream | stream := WriteStream on: (String new: self size * 2). self do: [ :ch | stream nextPutAll: ch hex ]. ^stream contents
asInteger "Answer the Integer created by interpreting the receiver as the string representation of an integer. Answer nil if no digits, else find the first digit and then all consecutive digits after that" "Not the same implementation as in Squeak" ^self asNumber asInteger
</methods> <methods> Core.String <category>squeak-comparing</category>
beginsWith: prefix "Answer whether the receiver begins with the given prefix string. The comparison is case-sensitive." "Not the same implementation as in Squeak" | stream | self size < prefix size ifTrue: [^ false]. stream := self readStream. ^prefix allSatisfy: [:each | each = stream next]
</methods> <methods> Core.String <category>squeak-converting</category>
capitalized "Return a copy with the first letter capitalized" | cap | self isEmpty ifTrue: [ ^self copy ]. cap := self copy. cap at: 1 put: (cap at: 1) asUppercase. ^ cap
</methods> <methods> Core.String <category>squeak-comparing</category>
caseInsensitiveLessOrEqual: aString "Answer whether the receiver sorts before or equal to aString. The collation order is case insensitive." ^(self sameAs: aString) or: [self asUppercase < aString asUppercase]
</methods> <methods> Core.String <category>squeak-converting</category>
encodeForHTTP "change dangerous characters to their %XX form, for use in HTTP transactions" | encodedStream | encodedStream := WriteStream on: (String new: self size). self do: [ :c | c isSafeForHTTP ifTrue: [ encodedStream nextPut: c ] ifFalse: [ encodedStream nextPut: $%. encodedStream nextPut: (c asInteger // 16) asHexDigit. encodedStream nextPut: (c asInteger \\ 16) asHexDigit. ] ]. ^encodedStream contents.
</methods> <methods> Core.String <category>squeak-comparing</category>
endsWith: suffix "Answer whether the tail end of the receiver is the same as suffix. The comparison is case-sensitive." "Not the same implementation as in Squeak" | extra | (extra := self size - suffix size) < 0 ifTrue: [^ false]. ^ (self findString: suffix startingAt: extra + 1) = (extra + 1) " 'Elvis' endsWith: 'vis' "
</methods> <methods> Core.String <category>squeak-converting</category>
evaluateExpression: aString parameters: aCollection "private - evaluate the expression aString with aCollection as the parameters and answer the evaluation result as an string" | index | index := ('0' , aString) asNumber. index isZero ifTrue: [^ '[invalid subscript: {1}]' format: (Array with: aString)]. index > aCollection size ifTrue: [^ '[subscript is out of bounds: {1}]' format: (Array with: aString)]. ^ (aCollection at: index) asString
</methods> <methods> Core.String <category>squeak-accessing</category>
findDelimiters: delimiters startingAt: start "Answer the index of the character within the receiver, starting at start, that matches one of the delimiters. If the receiver does not contain any of the delimiters, answer size + 1." start to: self size do: [:i | delimiters do: [:delim | delim = (self at: i) ifTrue: [^ i]]]. ^ self size + 1
findTokens: delimiters "Answer the collection of tokens that result from parsing self. Return strings between the delimiters. Any character in the Collection delimiters marks a border. Several delimiters in a row are considered as just one separation. Also, allow delimiters to be a single character." | tokens keyStart keyStop separators | tokens := OrderedCollection new. separators := delimiters class == Character ifTrue: [Array with: delimiters] ifFalse: [delimiters]. keyStop := 1. [keyStop <= self size] whileTrue: [keyStart := self skipDelimiters: separators startingAt: keyStop. keyStop := self findDelimiters: separators startingAt: keyStart. keyStart < keyStop ifTrue: [tokens add: (self copyFrom: keyStart to: (keyStop - 1))]]. ^tokens
</methods> <methods> Core.String <category>squeak-converting</category>
format: aCollection "format the receiver with aCollection simplest example: 'foo {1} bar' format: {Date today}. complete example: '\{ \} \\ foo {1} bar {2}' format: {12. 'string'}. " | result stream | result := String new writeStream. stream := self readStream. [stream atEnd] whileFalse: [| currentChar | currentChar := stream next. currentChar == ${ ifTrue: [| expression | expression := self getEnclosedExpressionFrom: stream. result nextPutAll: (self evaluateExpression: expression parameters: aCollection)] ifFalse: [ currentChar == $\ ifTrue: [stream atEnd ifFalse: [result nextPut: stream next]] ifFalse: [result nextPut: currentChar]]]. ^ result contents
getEnclosedExpressionFrom: aStream "private - get the expression enclosed between '{' and '}' and remove all the characters from the stream" | result currentChar | result := String new writeStream. [aStream atEnd or: [(currentChar := aStream next) == $}]] whileFalse: [result nextPut: currentChar]. ^ result contents withBlanksTrimmed
</methods> <methods> Core.String <category>squeak-testing</category>
includesSubString: subString ^ (self findString: subString startingAt: 1) > 0
includesSubstring: aString caseSensitive: caseSensitive ^ (self findString: aString startingAt: 1 ignoreCase: caseSensitive not useWildcards: false) first > 0
</methods> <methods> Core.String <category>squeak-accessing</category>
indexOf: aCharacter startingAt: start ifAbsent: aBlock | ans | (aCharacter class == Character) ifFalse: [ ^ aBlock value ]. ans := String indexOfAscii: aCharacter asciiValue inString: self startingAt: start. ans = 0 ifTrue: [ ^ aBlock value ] ifFalse: [ ^ ans ]
indexOfAnyOf: aCharacterSet ifAbsent: aBlock "returns the index of the first character in the given set. Returns the evaluation of aBlock if none are found" ^self indexOfAnyOf: aCharacterSet startingAt: 1 ifAbsent: aBlock
indexOfAnyOf: aCharacterSet startingAt: start ifAbsent: aBlock "returns the index of the first character in the given set, starting from start" | ans | ans := String findFirstInString: self inSet: aCharacterSet byteArrayMap startingAt: start. ans = 0 ifTrue: [ ^aBlock value ] ifFalse: [ ^ans ]
</methods> <methods> Core.String <category>squeak-testing</category>
isAllSeparators "whether the receiver is composed entirely of separators" self do: [ :c | c isSeparator ifFalse: [ ^false ] ]. ^true
</methods> <methods> Core.String <category>squeak-internet</category>
isoToSqueak ^ self collect: [:each | each isoToSqueak]
</methods> <methods> Core.String <category>squeak-converting</category>
padded: leftOrRight to: length with: char leftOrRight = #left ifTrue: [^ (String new: (length - self size max: 0) withAll: char) , self]. leftOrRight = #right ifTrue: [^ self , (String new: (length - self size max: 0) withAll: char)].
</methods> <methods> Core.String <category>squeak-accessing</category>
skipDelimiters: delimiters startingAt: start "Answer the index of the character within the receiver, starting at start, that does NOT match one of the delimiters. If the receiver does not contain any of the delimiters, answer size + 1. Assumes the delimiters to be a non-empty string." start to: self size do: [:i | delimiters detect: [:delim | delim = (self at: i)] ifNone: [^ i]]. ^ self size + 1
</methods> <methods> Core.String <category>squeak-converting</category>
translated
withBlanksTrimmed "Return a copy of the receiver from which leading and trailing blanks have been trimmed." ^self trimBlanks
</methods> <methods> Core.String <category>squeak-internet</category>
withoutQuoting "remove the initial and final quote marks, if present" "'''h''' withoutQuoting" | quote | self size < 2 ifTrue: [ ^self ]. quote := self first. (quote = $' or: [ quote = $" ]) ifTrue: [ ^self copyFrom: 2 to: self size - 1 ] ifFalse: [ ^self ].
</methods> <methods> Core.String <category>squeak-converting</category>
withSeparatorsCompacted "replace each sequences of whitespace by a single space character" | out pos textEnd | self isEmpty ifTrue: [ ^self ]. out := WriteStream on: (String new: self size). pos := 1. "current position in a scan through aString" "handle the case of initial separators" self first isSeparator ifTrue: [ out nextPut: Character space. pos := self indexOfAnyOf: CSNonSeparators ifAbsent: [ self size + 1 ] ]. "central loop: handle a segment of text, followed possibly by a segment of whitespace" [ pos <= self size ] whileTrue: [ "handle a segment of text..." textEnd := self indexOfAnyOf: CSSeparators startingAt: pos ifAbsent: [ self size + 1 ]. textEnd := textEnd - 1. out nextPutAll: (self copyFrom: pos to: textEnd). pos := textEnd + 1. pos <= self size ifTrue: [ pos := self indexOfAnyOf: CSNonSeparators startingAt: pos ifAbsent: [ self size + 1 ]. out nextPut: Character space ] ]. ^out contents
</methods> <methods> Core.String <category>squeak-internet</category>
withSqueakLineEndings "assume the string is textual, and that CR, LF, and CRLF are all valid line endings. Replace each occurence with a single CR" | cr lf crlf inPos outPos outString lineEndPos newOutPos | cr := Character cr. lf := Character lf. crlf := Squeak.CharacterSet new. crlf add: cr; add: lf. inPos := 1. outPos := 1. outString := String new: self size. [ lineEndPos := self indexOfAnyOf: crlf startingAt: inPos ifAbsent: [0]. lineEndPos ~= 0 ] whileTrue: [ newOutPos := outPos + (lineEndPos - inPos + 1). outString replaceFrom: outPos to: newOutPos - 2 with: self startingAt: inPos. outString at: newOutPos-1 put: cr. outPos := newOutPos. ((self at: lineEndPos) = cr and: [ lineEndPos < self size and: [ (self at: lineEndPos+1) = lf ] ]) ifTrue: [ "CRLF ending" inPos := lineEndPos + 2 ] ifFalse: [ "CR or LF ending" inPos := lineEndPos + 1 ]. ]. "no more line endings. copy the rest" newOutPos := outPos + (self size - inPos + 1). outString replaceFrom: outPos to: newOutPos-1 with: self startingAt: inPos. ^outString copyFrom: 1 to: newOutPos-1
</methods> <methods> Core.Magnitude <category>squeak-converting</category>
asString ^self printString
</methods> <methods> Core.Dictionary class <category>squeak-instance creation</category>
newFrom: aDict "Answer an instance of me containing the same associations as aDict. Error if any key appears twice." | newDictionary | newDictionary := self new: aDict size. aDict associationsDo: [:x | (newDictionary includesKey: x key) ifTrue: [self error: 'Duplicate key: ', x key printString] ifFalse: [newDictionary add: x]]. ^ newDictionary " Dictionary newFrom: (Array with: 1->#a with: 2->#b with: 3->#c) (Array with: 1->#a with: 2->#b with: 3->#c) as: Dictionary "
</methods> <methods> Core.Dictionary <category>squeak-enumerating</category>
keysSortedSafely "Answer a SortedCollection containing the receiver's keys." | sortedKeys | sortedKeys := SortedCollection new: self size. sortedKeys sortBlock: [:x :y | "Should really be use <obj, string, num> compareSafely..." ((x isString and: [y isString]) or: [x isNumber and: [y isNumber]]) ifTrue: [x < y] ifFalse: [x class == y class ifTrue: [x printString < y printString] ifFalse: [x class name < y class name]]]. self keysDo: [:each | sortedKeys add: each]. ^ sortedKeys
</methods> <methods> Core.ArrayedCollection class <category>squeak-instance creation</category>
newFrom: aCollection "Answer an instance of me containing the same elements as aCollection." | newArray | newArray := self new: aCollection size. 1 to: aCollection size do: [:i | newArray at: i put: (aCollection at: i)]. ^ newArray " Array newFrom: #(1 2 3) #(1 2 3) as: Array #(1 2 3) as: ByteArray #($c $h $r) as: String #($c $h $r) as: Text "
with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject "Answer a new instance of ArrayedCollection, containing the five arguments as the elements." | newCollection | newCollection := self new: 5. newCollection at: 1 put: firstObject. newCollection at: 2 put: secondObject. newCollection at: 3 put: thirdObject. newCollection at: 4 put: fourthObject. newCollection at: 5 put: fifthObject. ^newCollection
</methods> <methods> Core.ArrayedCollection <category>squeak-sorting</category>
mergeFirst: first middle: middle last: last into: dst by: aBlock "Private. Merge the sorted ranges [first..middle] and [middle+1..last] of the receiver into the range [first..last] of dst." | i1 i2 val1 val2 out | i1 := first. i2 := middle + 1. val1 := self at: i1. val2 := self at: i2. out := first - 1. "will be pre-incremented" "select 'lower' half of the elements based on comparator" [(i1 <= middle) and: [i2 <= last]] whileTrue: [(aBlock value: val1 value: val2) ifTrue: [dst at: (out := out + 1) put: val1. val1 := self at: (i1 := i1 + 1)] ifFalse: [dst at: (out := out + 1) put: val2. i2 := i2 + 1. i2 <= last ifTrue: [val2 := self at: i2]]]. "copy the remaining elements" i1 <= middle ifTrue: [dst replaceFrom: out + 1 to: last with: self startingAt: i1] ifFalse: [dst replaceFrom: out + 1 to: last with: self startingAt: i2]
mergeSortFrom: startIndex to: stopIndex by: aBlock "Sort the given range of indices using the mergesort algorithm. Mergesort is a worst-case O(N log N) sorting algorithm that usually does only half as many comparisons as heapsort or quicksort." "Details: recursively split the range to be sorted into two halves, mergesort each half, then merge the two halves together. An extra copy of the data is used as temporary storage and successive merge phases copy data back and forth between the receiver and this copy. The recursion is set up so that the final merge is performed into the receiver, resulting in the receiver being completely sorted." self size <= 1 ifTrue: [^ self]. "nothing to do" startIndex = stopIndex ifTrue: [^ self]. self assert: [startIndex >= 1 and: [startIndex < stopIndex]]. "bad start index" self assert: [stopIndex <= self size]. "bad stop index" self mergeSortFrom: startIndex to: stopIndex src: self clone dst: self by: aBlock
mergeSortFrom: first to: last src: src dst: dst by: aBlock "Private. Split the range to be sorted in half, sort each half, and merge the two half-ranges into dst." | middle | first = last ifTrue: [^ self]. middle := (first + last) // 2. self mergeSortFrom: first to: middle src: dst dst: src by: aBlock. self mergeSortFrom: middle + 1 to: last src: dst dst: src by: aBlock. src mergeFirst: first middle: middle last: last into: dst by: aBlock
</methods> <methods> Core.PositionableStream <category>squeak-data get/put</category>
int16 "Answer the next signed, 16-bit integer from this (binary) stream." | n | n := self next. n := (n bitShift: 8) + (self next). n >= 16r8000 ifTrue: [n := n - 16r10000]. ^ n
</methods> <methods> Core.PositionableStream <category>squeak-accessing</category>
isBinary ^collection isKindOf: IntegerArray
next: anInteger putAll: aCollection "Store the next anInteger elements from the given collection." ^self next: anInteger putAll: aCollection startingAt: 1
</methods> <methods> Core.PositionableStream <category>squeak-data get/put</category>
nextInt32 "Read a 32-bit signed integer from the next 4 bytes" | s | s := 0. 1 to: 4 do: [:i | s := (s bitShift: 8) + self next]. (s bitAnd: 16r80000000) = 0 ifTrue: [^ s] ifFalse: [^ -1 - s bitInvert32]
</methods> <methods> Core.PositionableStream <category>squeak-accessing</category>
nextLittleEndianNumber: n "Answer the next n bytes as a positive Integer or LargePositiveInteger, where the bytes are ordered from least significant to most significant." | bytes s | bytes := self next: n. s := 0. n to: 1 by: -1 do: [:i | s := (s bitShift: 8) bitOr: (bytes basicAt: i) asInteger]. ^ s
nextLittleEndianNumber: n put: value "Answer the next n bytes as a positive Integer or LargePositiveInteger, where the bytes are ordered from least significant to most significant." | bytes | bytes := ByteArray new: n. 1 to: n do: [: i | bytes at: i put: (value digitAt: i)]. self nextPutAll: bytes
</methods> <methods> Core.PositionableStream <category>squeak-data get/put</category>
uint16 "Answer the next unsigned, 16-bit integer from this (binary) stream." | n | n := self next. n := (n bitShift: 8) + (self next). ^ n
</methods> <methods> Kernel.NameSpace <category>squeak-class names</category>
classNamed: className "className is either a class name or a class name followed by ' class'. Answer the class or metaclass it names" | meta baseName baseClass ns | ns := self whoDefinesClassNamed: className. ns isNil ifTrue: [^ nil]. (className endsWith: ' class') ifTrue: [meta := true. baseName := className copyFrom: 1 to: className size - 6] ifFalse: [meta := false. baseName := className]. baseClass := ns at: baseName asSymbol ifAbsent: [^ nil]. meta ifTrue: [^ baseClass class] ifFalse: [^ baseClass]
</methods> <methods> Kernel.NameSpace <category>squeak-memory space</category>
garbageCollect ObjectMemory garbageCollect
</methods> <methods> Kernel.NameSpace <category>squeak-class names</category>
hasClassNamed: aString "Answer whether there is a class of the given name, but don't intern aString if it's not alrady interned. 4/29/96 sw" Symbol hasInterned: aString ifTrue: [:aSymbol | | ns | ns := self whoDefinesClassNamed: aString. ^ ns notNil]. ^ false
whoDefinesClassNamed: aString self withAllNameSpacesDo: [:each | | binding | binding := each localBindingFor: aString. (binding notNil and: [binding value isKindOf: Class]) ifTrue: [^each]]. ^ nil.
</methods> <methods> Core.Metaclass <category>accessing</category>
theNonMetaClass ^thisClass
</methods> <methods> Core.Random <category>squeak-accessing</category>
nextInt: anInteger "Answer a random integer in the interval [1, anInteger]." ^ (self next * anInteger) truncated + 1
</methods> <methods> Core.SortedCollection <category>squeak-copying</category>
copyEmpty ^self species sortBlock: self sortBlock
</methods> <methods> Core.Collection class <category>squeak-accessing</category>
randomForPicking ^ RandomForPicking
</methods> <methods> Core.Collection class <category>squeak-instance creation</category>
with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject "Answer a new instance of a Collection containing the five arguments as the elements." | newCollection | newCollection := self new. newCollection add: firstObject. newCollection add: secondObject. newCollection add: thirdObject. newCollection add: fourthObject. newCollection add: fifthObject. ^newCollection
</methods> <methods> Core.Collection <category>squeak-enumerating</category>
anyOne "Answer a representative sample of the receiver. This method can be helpful when needing to preinfer the nature of the contents of semi-homogeneous collections." self emptyCheck. self do: [:each | ^ each]
</methods> <methods> Core.Collection <category>squeak-converting</category>
asByteArray "Answer a ByteArray whose elements are the elements of the receiver. Implementation note: Cannot use ''ByteArray withAll: self'' as that only works for SequenceableCollections which support the replacement primitive." | array index | array := ByteArray new: self size. index := 0. self do: [:each | array at: (index := index + 1) put: each]. ^ array
</methods> <methods> Core.Collection <category>squeak-enumerating</category>
associationsDo: aBlock "Evaluate aBlock for each of the receiver's elements (key/value associations). If any non-association is within, the error is not caught now, but later, when a key or value message is sent to it." self do: aBlock
</methods> <methods> Core.Collection <category>squeak-filter streaming</category>
contents ^self
</methods> <methods> Core.Collection <category>squeak-copying</category>
copyWithoutAll: aCollection "Answer a copy of the receiver that does not contain any elements equal to those in aCollection." ^ self reject: [:each | aCollection includes: each]
</methods> <methods> Core.Collection <category>squeak-enumerating</category>
count: aBlock "Evaluate aBlock with each of the receiver's elements as the argument. Answer the number of elements that answered true." | sum | sum := 0. self do: [:each | (aBlock value: each) ifTrue: [sum := sum + 1]]. ^ sum
detectSum: aBlock "Evaluate aBlock with each of the receiver's elements as the argument. Return the sum of the answers." | sum | sum := 0. self do: [:each | sum := (aBlock value: each) + sum]. ^ sum
difference: aCollection "Answer the set theoretic difference of two collections." ^ self reject: [:each | aCollection includes: each]
gather: aBlock ^ Array streamContents: [:stream | self do: [:ea | stream nextPutAll: (aBlock value: ea)]]
</methods> <methods> Core.Collection <category>squeak-testing</category>
includesAllOf: aCollection "Answer whether all the elements of aCollection are in the receiver." aCollection do: [:elem | (self includes: elem) ifFalse: [^ false]]. ^ true
includesAnyOf: aCollection "Answer whether any element of aCollection is one of the receiver's elements." ^aCollection anySatisfy: [:elem | self includes: elem]
</methods> <methods> Core.Collection <category>squeak-enumerating</category>
intersection: aCollection "Answer the set theoretic intersection of two collections." ^ self select: [:each | aCollection includes: each]
</methods> <methods> Core.Collection <category>squeak-testing</category>
isCollection "Return true if the receiver is some sort of Collection and responds to basic collection messages such as #size and #do:" ^true
isEmptyOrNil "Answer whether the receiver contains any elements, or is nil. Useful in numerous situations where one wishes the same reaction to an empty collection or to nil" ^ self isEmpty
</methods> <methods> Core.Collection <category>squeak-enumerating</category>
noneSatisfy: aBlock "Evaluate aBlock with the elements of the receiver. If aBlock returns false for all elements return true. Otherwise return false" self do: [:item | (aBlock value: item) ifTrue: [^ false]]. ^ true
</methods> <methods> Core.Collection <category>squeak-removing</category>
removeAllFoundIn: aCollection "Remove each element of aCollection which is present in the receiver from the receiver. Answer aCollection. No error is raised if an element isn't found. ArrayedCollections cannot respond to this message." aCollection do: [:each | self remove: each ifAbsent: []]. ^ aCollection
</methods> <methods> Core.Collection <category>squeak-enumerating</category>
sum "This is implemented using a variant of the normal inject:into: pattern. The reason for this is that it is not known whether we're in the normal number line, i.e. whether 0 is a good initial value for the sum. Consider a collection of measurement objects, 0 would be the unitless value and would not be appropriate to add with the unit-ed objects." | sum sample | sample := self anyOne. sum := self inject: sample into: [:accum :each | accum + each]. ^ sum - sample
</methods> <methods> Core.Delay class <category>squeak-testing</category>
anyActive "Return true if there is any delay currently active" ^ActiveDelay notNil
</methods> <methods> Core.Character class <category>squeak-accessing untypeable characters</category>
allCharacters ^ (0 to: 255) collect: [:v | Character value: v]
separators ^ #(32 "space" 13 "cr" 9 "tab" 10 "line feed" 12 "form feed") collect: [:v | Character value: v]
</methods> <methods> Core.Character <category>squeak-converting</category>
asciiValue "Answer the value of the receiver that represents its ascii encoding." ^self asInteger
asString ^ String with: self
asUnicode ^self asInteger
</methods> <methods> Core.Character <category>squeak-copying</category>
clone "Answer with the receiver, because Characters are unique."
</methods> <methods> Core.Character <category>squeak-printing</category>
hex ^ String with: ('0123456789ABCDEF' at: self asciiValue//16+1) with: ('0123456789ABCDEF' at: self asciiValue\\16+1)
</methods> <methods> Core.Character <category>squeak-converting</category>
isoToSqueak "Convert receiver from iso8895-1 (actually CP1252) to mac encoding. Does not do lf/cr conversion! Characters not available in MacRoman encoding have been remapped to their base characters or to $?." self asInteger < 128 ifTrue: [^ self]. ^ Character value: (#( 219 63 226 196 227 201 160 224 246 228 83 220 206 63 90 63 "80-8F" 63 212 213 210 211 165 208 209 247 170 115 221 207 63 122 217 "90-9F" 202 193 162 163 63 180 124 164 172 169 187 199 194 45 168 248 "A0-AF" 161 177 50 51 171 181 166 225 252 49 188 200 63 63 63 192 "B0-BF" 203 231 229 204 128 129 174 130 233 131 230 232 237 234 235 236 "C0-CF" 63 132 241 238 239 205 133 42 175 244 242 243 134 89 63 167 "D0-DF" 136 135 137 139 138 140 190 141 143 142 144 145 147 146 148 149 "E0-EF" 63 150 152 151 153 155 154 214 191 157 156 158 159 121 63 216 "F0-FF" ) at: self asInteger - 127)
</methods> <methods> Core.Character <category>squeak-testing</category>
isSafeForHTTP "whether a character is 'safe', or needs to be escaped when used, eg, in a URL" ^ self asInteger < 128 and: [self isAlphaNumeric or: ['.~-_' includes: self]]
</methods> <methods> Core.Character <category>squeak-converting</category>
to: aCharacter "Answer with a collection in ascii order -- $a to: $z" | start result | start := self asInteger. result := String new: (aCharacter asInteger - start + 1). self asInteger to: aCharacter asInteger do: [:eachValue | result at: eachValue - start + 1 put: (Character value: eachValue)]. ^result
</methods> <methods> Core.SmallInteger <category>squeak-copying</category>
clone
</methods> <methods> Core.Bag class <category>squeak-instance creation</category>
newFrom: aCollection "Answer an instance of me containing the same elements as aCollection." ^ self withAll: aCollection "Examples: Bag newFrom: #(1 2 3 3) #(1 2 3 3) as: Bag "
</methods> <methods> Core.Bag <category>squeak-accessing</category>
sortedCounts "Answer with a collection of counts with elements, sorted by decreasing count." | counts | counts := SortedCollection sortBlock: [:x :y | x >= y]. contents associationsDo: [:assn | counts add: (Association key: assn value value: assn key)]. ^ counts
</methods> <methods> UI.ValueHolder <category>squeak-unclassified</category>
contents ^ self value
contents: aValue self value: aValue
</methods> <methods> Kernel.BlockContext <category>squeak-evaluating</category>
ifError: errorHandlerBlock "Evaluate the block represented by the receiver, and normally return it's value. If an error occurs, the errorHandlerBlock is evaluated, and it's value is instead returned. The errorHandlerBlock must accept zero, one, or two parameters (the error message and the receiver)." "Examples: [1 whatsUpDoc] ifError: [:err :rcvr | 'huh?']. [1 / 0] ifError: [:err :rcvr | 'ZeroDivide' = err ifTrue: [Float infinity] ifFalse: [self error: err]] " ^ self on: Error do: [:ex | errorHandlerBlock valueWithPossibleArgs: (Array with: ex description with: ex receiver)]
</methods> <methods> Kernel.BlockContext <category>squeak-testing</category>
isBlock ^true
</methods> <methods> Kernel.BlockContext <category>squeak-accessing</category>
numArgs self halt "Answer the number of arguments that must be used to evaluate this block" "^nargs"
</methods> <methods> Kernel.BlockContext <category>squeak-evaluating</category>
value self halt. "Primitive. Evaluate the block represented by the receiver. Fail if the block expects any arguments or if the block is already being executed. Optional. No Lookup. See Object documentation whatIsAPrimitive." "<primitive: 81> ^self valueWithArguments: #()"
value: arg self halt. "Primitive. Evaluate the block represented by the receiver. Fail if the block expects other than one argument or if the block is already being executed. Optional. No Lookup. See Object documentation whatIsAPrimitive." "<primitive: 81> ^self valueWithArguments: (Array with: arg)"
valueWithArguments: anArray self halt. "Primitive. Evaluate the block represented by the receiver. The argument is an Array whose elements are the arguments for the block. Fail if the length of the Array is not the same as the the number of arguments that the block was expecting. Fail if the block is already being executed. Essential. See Object documentation whatIsAPrimitive." "<primitive: 82> self numArgs = anArray size ifTrue: [self error: 'Attempt to evaluate a block that is already being evaluated.'] ifFalse: [self error: 'This block accepts ' ,self numArgs printString, ' argument', (self numArgs = 1 ifTrue:[''] ifFalse:['s']) , ', but was called with ', anArray size printString, '.']"
</methods> <methods> Kernel.BlockContext <category>squeak-tiles</category>
valueWithPossibleArgs: anArray self numArgs = 0 ifTrue: [^self value]. self numArgs = anArray size ifTrue: [^self valueWithArguments: anArray]. self numArgs > anArray size ifTrue: [ ^self valueWithArguments: anArray, (Array new: (self numArgs - anArray size)) ]. ^self valueWithArguments: (anArray copyFrom: 1 to: self numArgs)
</methods> <methods> Kernel.BlockContext <category>squeak-evaluating</category>
valueWithPossibleArgument: anArg "Evaluate the block represented by the receiver. If the block requires one argument, use anArg, if it requires more than one, fill up the rest with nils." self numArgs = 0 ifTrue: [^ self value]. self numArgs = 1 ifTrue: [^ self value: anArg]. self numArgs > 1 ifTrue: [^ self valueWithArguments: (Array with: anArg) , (Array new: self numArgs - 1)]
</methods> <methods> Core.RunArray class <category>squeak-instance creation</category>
newFrom: aCollection "Answer an instance of me containing the same elements as aCollection." | newCollection | newCollection := self new. aCollection do: [:x | newCollection addLast: x]. ^newCollection " RunArray newFrom: #(1 2 2 3) #(1 $a $a 3) as: RunArray (#(1 $a $a 3) as: RunArray) values "
</methods> <methods> Core.Object <category>*seaside2</category>
mimeType ^Squeak.MIMEDocument defaultContentType.
</methods> <methods> Core.Collection <category>arithmetic</category>
+ arg ^ arg adaptToCollection: self andSend: #+
</methods> <methods> Core.Collection <category>adapting</category>
adaptToCollection: rcvr andSend: selector "If I am involved in arithmetic with another Collection, return a Collection of the results of each element combined with the scalar in that expression." rcvr isSequenceable & self isSequenceable ifFalse: [self error: 'Only sequenceable collections may be combined arithmetically']. ^ rcvr with: self collect: [:rcvrElement :myElement | rcvrElement perform: selector with: myElement]
</methods> <methods> Core.Object <category>converting</category>
as: aSimilarClass "Create an object of class aSimilarClass that has similar contents to the receiver." ^ aSimilarClass newFrom: self
</methods> <methods> Core.SequenceableCollection <category>private</category>
checkedAt: index index > self size ifTrue: [self error: 'not enough elements']. ^ self at: index
</methods> <methods> Core.SequenceableCollection <category>accessing</category>
second "Answer the second element of the receiver. Raise an error if there are not enough elements." ^ self checkedAt: 2
third "Answer the third element of the receiver. Raise an error if there are not enough elements." ^ self checkedAt: 3
</methods> <methods> Core.OrderedCollection <category>enumerating</category>
with: otherCollection collect: twoArgBlock "Collect and return the result of evaluating twoArgBlock with corresponding elements from this collection and otherCollection." | result | otherCollection size = self size ifFalse: [self error: 'otherCollection must be the same size']. result := self species new: self size. 1 to: self size do: [:index | result addLast: (twoArgBlock value: (self at: index) value: (otherCollection at: index))]. ^ result
</methods> <methods> Core.Integer <category>truncation and round off</category>
normalize ^ self compressed
</methods> <methods> Core.String <category>squeak-converting</category>
asDate "Many allowed forms, see Date>>#readFrom:" ^ Squeak.Date fromString: self
asDateAndTime "Convert from UTC format" ^ Squeak.DateAndTime fromString: self
asDuration "convert from [nnnd]hh:mm:ss[.nanos] format. [] implies optional elements" ^ Squeak.Duration fromString: self
asTime "Many allowed forms, see Time>>readFrom:" ^ Squeak.Time fromString: self.
asTimeStamp "Convert from obsolete TimeStamp format" ^ Squeak.TimeStamp fromString: self
</methods> <methods> Core.Number <category>squeak-converting</category>
asDuration ^ Squeak.Duration nanoSeconds: self asInteger
day ^ self sign days
days ^ Squeak.Duration days: self
hour ^ self sign hours
hours ^ Squeak.Duration hours: self
milliSecond ^ self sign milliSeconds
milliSeconds ^ Squeak.Duration milliSeconds: self
minute ^ self sign minutes
minutes ^ Squeak.Duration minutes: self
nanoSecond ^ self sign nanoSeconds
nanoSeconds ^ Squeak.Duration nanoSeconds: self
second ^ self sign seconds
seconds ^ Squeak.Duration seconds: self
week ^ self sign weeks
weeks ^ Squeak.Duration weeks: self
</methods> <methods> Core.Delay class <category>squeak-instance creation</category>
forDuration: aDuration ^ self forMilliseconds: aDuration asMilliSeconds
</methods> <methods> Squeak.StandardScriptingSystem class <category>resources</category>
iconCheckBoxOff "Tools.UIMaskEditor new openOnClass: self andSelector: #iconCheckBoxOff" <resource: #image> ^CachedImage on: (Image extent: 9@8 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryLightGray; at: 2 put: Graphics.ColorValue veryDarkGray; yourself)) usingBits: #[0 0 0 0 127 0 0 0 65 0 0 0 65 0 0 0 65 0 0 0 65 0 0 0 65 0 0 0 127 0 0 0])
iconCheckBoxOn "Tools.UIMaskEditor new openOnClass: self andSelector: #iconCheckBoxOn" <resource: #image> ^CachedImage on: (Image extent: 9@8 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryLightGray; at: 2 put: Graphics.ColorValue veryDarkGray; yourself)) usingBits: #[0 0 0 0 127 0 0 0 99 0 0 0 85 0 0 0 73 0 0 0 85 0 0 0 99 0 0 0 127 0 0 0])
iconDebug "Tools.UIMaskEditor new openOnClass: self andSelector: #iconDebug" <resource: #image> ^CachedImage on: (Image extent: 16@16 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryDarkGray; at: 2 put: Graphics.ColorValue veryLightGray; yourself)) usingBits: #[255 255 0 0 255 255 0 0 255 255 0 0 254 127 0 0 255 63 0 0 255 159 0 0 247 159 0 0 243 159 0 0 248 31 0 0 252 15 0 0 255 199 0 0 255 227 0 0 255 243 0 0 255 255 0 0 255 255 0 0 255 255 0 0])
iconDownArrow "Tools.UIMaskEditor new openOnClass: self andSelector: #iconDownArrow" <resource: #image> ^CachedImage on: (Image extent: 9@8 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryLightGray; at: 2 put: Graphics.ColorValue veryDarkGray; yourself)) usingBits: #[28 0 0 0 28 0 0 0 28 0 0 0 255 128 0 0 127 0 0 0 62 0 0 0 28 0 0 0 8 0 0 0])
iconPaint "Tools.UIMaskEditor new openOnClass: self andSelector: #iconPaint" <resource: #image> ^CachedImage on: (Image extent: 16@16 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryDarkGray; at: 2 put: Graphics.ColorValue veryLightGray; yourself)) usingBits: #[255 255 0 0 255 255 0 0 255 255 0 0 231 255 0 0 225 255 0 0 244 127 0 0 243 63 0 0 251 159 0 0 249 207 0 0 252 231 0 0 254 119 0 0 255 39 0 0 255 143 0 0 255 255 0 0 255 255 0 0 255 255 0 0])
iconRadioButtonOff "Tools.UIMaskEditor new openOnClass: self andSelector: #iconRadioButtonOff" <resource: #image> ^CachedImage on: (Image extent: 9@8 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryLightGray; at: 2 put: Graphics.ColorValue veryDarkGray; yourself)) usingBits: #[24 0 0 0 102 0 0 0 66 0 0 0 129 0 0 0 129 0 0 0 66 0 0 0 102 0 0 0 24 0 0 0])
iconRadioButtonOn "Tools.UIMaskEditor new openOnClass: self andSelector: #iconRadioButtonOn" <resource: #image> ^CachedImage on: (Image extent: 9@8 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryLightGray; at: 2 put: Graphics.ColorValue veryDarkGray; yourself)) usingBits: #[24 0 0 0 126 0 0 0 126 0 0 0 255 0 0 0 255 0 0 0 126 0 0 0 126 0 0 0 24 0 0 0])
iconTile "Tools.UIMaskEditor new openOnClass: self andSelector: #iconTile" <resource: #image> ^CachedImage on: (Image extent: 16@16 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryLightGray; at: 2 put: Graphics.ColorValue veryDarkGray; yourself)) usingBits: #[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 63 252 0 0 32 4 0 0 32 4 0 0 32 4 0 0 32 4 0 0 32 4 0 0 32 4 0 0 63 252 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0])
iconUpArrow "Tools.UIMaskEditor new openOnClass: self andSelector: #iconUpArrow" <resource: #image> ^CachedImage on: (Image extent: 9@8 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryLightGray; at: 2 put: Graphics.ColorValue veryDarkGray; yourself)) usingBits: #[8 0 0 0 28 0 0 0 62 0 0 0 127 0 0 0 255 128 0 0 28 0 0 0 28 0 0 0 28 0 0 0])
iconView "Tools.UIMaskEditor new openOnClass: self andSelector: #iconView" <resource: #image> ^CachedImage on: (Image extent: 16@16 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: ((Core.Array new: 2) at: 1 put: Graphics.ColorValue veryDarkGray; at: 2 put: Graphics.ColorValue veryLightGray; yourself)) usingBits: #[255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 248 31 0 0 227 7 0 0 210 11 0 0 176 13 0 0 216 27 0 0 228 39 0 0 248 31 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0 255 255 0 0])
</methods> <initialize> Squeak.ChronologyConstants </initialize> <initialize> Squeak.StandardScriptingSystem </initialize> <initialize> FileDirectory </initialize> <initialize> Squeak.Preferences </initialize> "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' <class> <name>Object</name> <environment>Core</environment> <super></super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class> <class> <name>Magnitude</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>Magnitude-General</category> <attributes> <package>Magnitude-General</package> </attributes> </class> <class> <name>Number</name> <environment>Core</environment> <super>Core.ArithmeticValue</super> <private>false</private> none <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class> <class> <name>Date</name> <environment>Core</environment> <super>Core.Magnitude</super> <private>false</private> none day year <imports></imports> <category>Magnitude-General</category> <attributes> <package>Magnitude-General</package> </attributes> </class> <class> <name>UndefinedObject</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class> <class> <name>Dialog</name> <environment>UI</environment> <super>Core.Object</super> <private>false</private> none parentVisual <imports></imports> <category>Interface-Dialogs</category> <attributes> <package>Interface-Dialogs</package> </attributes> </class> <class> <name>BlockContext</name> <environment>Kernel</environment> <super>Kernel.Context</super> <private>false</private> none <imports></imports> <category>Kernel-Methods</category> <attributes> <package>Kernel-Methods</package> </attributes> </class> <class> <name>Integer</name> <environment>Core</environment> <super>Core.Number</super> <private>false</private> none <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class> <class> <name>Behavior</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none superclass methodDict format subclasses <imports></imports> <category>Kernel-Classes</category> <attributes> <package>Kernel-Classes</package> </attributes> </class> <class> <name>Boolean</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>Kernel-Objects</category> <attributes> <package>Kernel-Objects</package> </attributes> </class> <class> <name>ColorValue</name> <environment>Graphics</environment> <super>Graphics.SimplePaint</super> <private>false</private> none red green blue <imports></imports> <category>Graphics-Support</category> <attributes> <package>Graphics-Support</package> </attributes> </class> <class> <name>Collection</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none <imports></imports> <category>Collections-Abstract</category> <attributes> <package>Collections-Abstract</package> </attributes> </class> <class> <name>Bag</name> <environment>Core</environment> <super>Core.Collection</super> <private>false</private> none contents <imports></imports> <category>Collections-Unordered</category> <attributes> <package>Collections-Unordered</package> </attributes> </class> <class> <name>SequenceableCollection</name> <environment>Core</environment> <super>Core.Collection</super> <private>false</private> none <imports></imports> <category>Collections-Abstract</category> <attributes> <package>Collections-Abstract</package> </attributes> </class> <class> <name>GenericException</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none messageText originator initialContext firstUnwindContext handlerContext parameter proceedBlock isResumable signal searchContext notifierString <imports></imports> <category>Kernel-Exception Handling</category> <attributes> <package>Kernel-Exception Handling</package> </attributes> </class> <class> <name>HaltInterrupt</name> <environment>Core</environment> <super>Core.ControlInterrupt</super> <private>false</private> none <imports></imports> <category>Kernel-Exception Handling</category> <attributes> <package>Kernel-Exception Handling</package> </attributes> </class> <class> <name>OrderedCollection</name> <environment>Core</environment> <super>Core.SequenceableCollection</super> <private>false</private> objects firstIndex lastIndex <imports></imports> <category>Collections-Sequenceable</category> <attributes> <package>Collections-Sequenceable</package> </attributes> </class> <class> <name>ClassDescription</name> <environment>Core</environment> <super>Core.Behavior</super> <private>false</private> none instanceVariables organization <imports></imports> <category>Kernel-Classes</category> <attributes> <package>Kernel-Classes</package> </attributes> </class> <class> <name>SortedCollection</name> <environment>Core</environment> <super>Core.OrderedCollection</super> <private>false</private> objects sortBlock <imports></imports> <category>Collections-Sequenceable</category> <attributes> <package>Collections-Sequenceable</package> </attributes> </class> <class> <name>Metaclass</name> <environment>Core</environment> <super>Core.ClassDescription</super> <private>false</private> none thisClass <imports></imports> <category>Kernel-Classes</category> <attributes> <package>Kernel-Classes</package> </attributes> </class> <class> <name>CompiledCode</name> <environment>Kernel</environment> <super>Core.Object</super> <private>false</private> objects bytes <imports> private Kernel.OpcodePool.* </imports> <category>Kernel-Methods</category> <attributes> <package>Kernel-Methods</package> </attributes> </class> <class> <name>Warning</name> <environment>Core</environment> <super>Core.Exception</super> <private>false</private> none <imports></imports> <category>Kernel-Exception Handling</category> <attributes> <package>Kernel-Exception Handling</package> </attributes> </class> <class> <name>Dictionary</name> <environment>Core</environment> <super>Core.Set</super> <private>false</private> objects <imports></imports> <category>Collections-Unordered</category> <attributes> <package>Collections-Unordered</package> </attributes> </class> <class> <name>WeakDictionary</name> <environment>Core</environment> <super>Core.IdentityDictionary</super> <private>false</private> objects executors accessLock <imports></imports> <category>Collections-Unordered</category> <attributes> <package>Collections-Unordered</package> </attributes> </class> <class> <name>Character</name> <environment>Core</environment> <super>Core.Magnitude</super> <private>false</private> immediate <imports></imports> <category>Magnitude-General</category> <attributes> <package>Magnitude-General</package> </attributes> </class> <class> <name>Stream</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none <imports> private IOConstants.* </imports> <category>Collections-Streams</category> <attributes> <package>Collections-Streams</package> </attributes> </class> <class> <name>Random</name> <environment>Core</environment> <super>Core.Stream</super> <private>false</private> none seed <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class> <class> <name>PositionableStream</name> <environment>Core</environment> <super>Core.PeekableStream</super> <private>false</private> none collection position readLimit writeLimit policy <imports></imports> <category>Collections-Streams</category> <attributes> <package>Collections-Streams</package> </attributes> </class> <class> <name>Message</name> <environment>Core</environment> <super>Core.Object</super> <private>false</private> none selector args <imports></imports> <category>Kernel-Methods</category> <attributes> <package>Kernel-Methods</package> </attributes> </class> <class> <name>MessageSend</name> <environment>Core</environment> <super>Core.Message</super> <private>false</private> none receiver <imports></imports> <category>Kernel-Methods</category> <attributes> <package>Kernel-Methods</package> </attributes> </class> <class> <name>ExternalReadWriteStream</name> <environment>OS</environment> <super>OS.ExternalReadStream</super> <private>false</private> none <imports> private OS.IOConstants.* </imports> <category>OS-Streaming</category> <attributes> <package>OS-Streaming</package> </attributes> </class> <class> <name>Fraction</name> <environment>Core</environment> <super>Core.Number</super> <private>false</private> none numerator denominator <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class> <class> <name>ArrayedCollection</name> <environment>Core</environment> <super>Core.SequenceableCollection</super> <private>false</private> none <imports></imports> <category>Collections-Abstract</category> <attributes> <package>Collections-Abstract</package> </attributes> </class> <class> <name>String</name> <environment>Core</environment> <super>Core.CharacterArray</super> <private>false</private> none <imports></imports> <category>Collections-Text</category> <attributes> <package>Collections-Text</package> </attributes> </class> <class> <name>Symbol</name> <environment>Core</environment> <super>Core.String</super> <private>false</private> none <imports></imports> <category>Collections-Text</category> <attributes> <package>Collections-Text</package> </attributes> </class> <class> <name>NameSpace</name> <environment>Kernel</environment> <super>Kernel.GeneralNameSpace</super> <private>false</private> none parent name <imports></imports> <category>System-Name Spaces</category> <attributes> <package>System-Name Spaces</package> </attributes> </class> <class> <name>SmallInteger</name> <environment>Core</environment> <super>Core.Integer</super> <private>false</private> immediate minVal maxVal maxBits maxBytes <imports></imports> <category>Magnitude-Numbers</category> <attributes> <package>Magnitude-Numbers</package> </attributes> </class> <class> <name>ValueHolder</name> <environment>UI</environment> <super>UI.ValueModel</super> <private>false</private> none value <imports></imports> <category>Interface-Support</category> <attributes> <package>Interface-Support</package> </attributes> </class> <class> <name>SmalltalkCompiler</name> <environment>Kernel</environment> <super>Core.Object</super> <private>false</private> none sourceStream requestor class targetClass environment context methodClass allowSelfReferences allowClassVariableReferences <imports></imports> <category>System-Compiler-Public Access</category> <attributes> <package>System-Compiler-Public Access</package> </attributes> </class> <class> <name>WriteStream</name> <environment>Core</environment> <super>Core.InternalStream</super> <private>false</private> none <imports></imports> <category>Collections-Streams</category> <attributes> <package>Collections-Streams</package> </attributes> </class>