[squeak-dev] The Trunk: Collections-laza.428.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Feb 26 10:31:48 UTC 2011


Alexander Lazarević uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-laza.428.mcz

==================== Summary ====================

Name: Collections-laza.428
Author: laza
Time: 26 February 2011, 11:31:16.656 am
UUID: f943155d-9f78-844d-9db4-9ae5396da757
Ancestors: Collections-ul.427

Some minor recats

=============== Diff against Collections-ul.427 ===============

Item was changed:
+ ----- Method: String>>endsWith: (in category 'testing') -----
- ----- Method: String>>endsWith: (in category 'comparing') -----
  endsWith: suffix
  	"Answer whether the tail end of the receiver is the same as suffix.
  	The comparison is case-sensitive."
  	
  	| extra |
  	(extra := self size - suffix size) < 0 ifTrue: [^ false].
  	^ (self findString: suffix startingAt: extra + 1) > 0
  "
    'Elvis' endsWith: 'vis'
  "!

Item was changed:
+ ----- Method: String>>endsWithAColon (in category 'testing') -----
- ----- Method: String>>endsWithAColon (in category 'system primitives') -----
  endsWithAColon 
  	"Answer whether the final character of the receiver is a colon"
  
  	^ self size > 0 and: [self last == $:]
  
  "
  #fred: endsWithAColon
  'fred' endsWithAColon
  "!

Item was changed:
+ ----- Method: String>>endsWithAnyOf: (in category 'testing') -----
- ----- Method: String>>endsWithAnyOf: (in category 'comparing') -----
  endsWithAnyOf: aCollection
  	aCollection do:[:suffix|
  		(self endsWith: suffix) ifTrue:[^true].
  	].
  	^false!

Item was changed:
+ ----- Method: String>>endsWithDigit (in category 'testing') -----
- ----- Method: String>>endsWithDigit (in category 'accessing') -----
  endsWithDigit
  	"Answer whether the receiver's final character represents a digit.  3/11/96 sw"
  
  	^ self size > 0 and: [self last isDigit]!

Item was changed:
+ ----- Method: String>>findSubstring:in:startingAt:matchTable: (in category 'accessing') -----
- ----- Method: String>>findSubstring:in:startingAt:matchTable: (in category 'system primitives') -----
  findSubstring: key in: body startingAt: start matchTable: matchTable
  	"Answer the index in the string body at which the substring key first occurs, at or beyond start.  The match is determined using matchTable, which can be used to effect, eg, case-insensitive matches.  If no match is found, zero will be returned."
  	| index c1 c2 |
  	matchTable == nil ifTrue: [
  		key size = 0 ifTrue: [^ 0].
  		start to: body size - key size + 1 do:
  			[:startIndex |
  			index := 1.
  				[(body at: startIndex+index-1)
  					= (key at: index)]
  					whileTrue:
  					[index = key size ifTrue: [^ startIndex].
  					index := index+1]].
  		^ 0
  	].
  
  	key size = 0 ifTrue: [^ 0].
  	start to: body size - key size + 1 do:
  		[:startIndex |
  		index := 1.
  		[c1 := body at: startIndex+index-1.
  		c2 := key at: index.
  		((c1 leadingChar = 0 and: [ c1 asciiValue < matchTable size ]) 
  			ifTrue: [ matchTable at: c1 asciiValue + 1 ]
  			ifFalse: [ c1 asciiValue + 1 ]) = 
  			((c2 leadingChar = 0 and: [ c2 asciiValue < matchTable size ])
  				ifTrue: [ matchTable at: c2 asciiValue + 1 ]
  				ifFalse: [c2 asciiValue + 1 ]) ]
  			whileTrue:
  				[index = key size ifTrue: [^ startIndex].
  				index := index+1]].
  	^ 0!

Item was changed:
+ ----- Method: String>>includesSubString: (in category 'testing') -----
- ----- Method: String>>includesSubString: (in category 'accessing') -----
  includesSubString: subString
  	^ (self findString: subString startingAt: 1) > 0!

Item was changed:
+ ----- Method: String>>includesSubstring:caseSensitive: (in category 'testing') -----
- ----- Method: String>>includesSubstring:caseSensitive: (in category 'accessing') -----
  includesSubstring: aString caseSensitive: caseSensitive
  	
  	^ (self findString: aString startingAt: 1 caseSensitive: caseSensitive) > 0!

Item was changed:
+ ----- Method: String>>lastSpacePosition (in category 'accessing') -----
- ----- Method: String>>lastSpacePosition (in category 'testing') -----
  lastSpacePosition
  	"Answer the character position of the final space or other separator character in the receiver, and 0 if none"
  	self size to: 1 by: -1 do:
  		[:i | ((self at: i) isSeparator) ifTrue: [^ i]].
  	^ 0
  
  "
  'fred the bear' lastSpacePosition
  'ziggie' lastSpacePosition
  'elvis ' lastSpacePosition
  'wimpy  ' lastSpacePosition
  '' lastSpacePosition
  "!

Item was changed:
+ ----- Method: String>>numArgs (in category 'accessing') -----
- ----- Method: String>>numArgs (in category 'system primitives') -----
  numArgs 
  	"Answer either the number of arguments that the receiver would take if considered a selector.  Answer -1 if it couldn't be a selector.  Note that currently this will answer -1 for anything begining with an uppercase letter even though the system will accept such symbols as selectors.  It is intended mostly for the assistance of spelling correction."
  
  	| firstChar numColons excess start ix |
  	self size = 0 ifTrue: [^ -1].
  	firstChar := self at: 1.
  	(firstChar isLetter or: [firstChar = $:]) ifTrue:
  		["Fast reject if any chars are non-alphanumeric
  		NOTE: fast only for Byte things - Broken for Wide"
  		self class isBytes
  			ifTrue: [(self findSubstring: '~' in: self startingAt: 1 matchTable: Tokenish) > 0 ifTrue: [^ -1]]
  			ifFalse: [2 to: self size do: [:i | (self at: i) tokenish ifFalse: [^ -1]]].
  		"Fast colon count"
  		numColons := 0.  start := 1.
  		[(ix := self indexOf: $: startingAt: start) > 0]
  			whileTrue:
  				[numColons := numColons + 1.
  				start := ix + 1].
  		numColons = 0 ifTrue: [^ 0].
  		firstChar = $:
  			ifTrue: [excess := 2 "Has an initial keyword, as #:if:then:else:"]
  			ifFalse: [excess := 0].
  		self last = $:
  			ifTrue: [^ numColons - excess]
  			ifFalse: [^ numColons - excess - 1 "Has a final keywords as #nextPut::andCR"]].
  	firstChar isSpecial ifTrue:
  		[self size = 1 ifTrue: [^ 1].
  		2 to: self size do: [:i | (self at: i) isSpecial ifFalse: [^ -1]].
  		^ 1].
  	^ -1.!

Item was changed:
+ ----- Method: String>>startsWithDigit (in category 'testing') -----
- ----- Method: String>>startsWithDigit (in category 'accessing') -----
  startsWithDigit
  	"Answer whether the receiver's first character represents a digit"
  
  	^ self size > 0 and: [self first isDigit]!

Item was changed:
+ ----- Method: String>>string (in category 'converting') -----
- ----- Method: String>>string (in category 'accessing') -----
  string
  	^self!




More information about the Squeak-dev mailing list