--- a/ArrayedCollection.st Sat Jan 23 07:23:05 2016 +0000
+++ b/ArrayedCollection.st Tue Jan 26 09:27:00 2016 +0000
@@ -11,6 +11,8 @@
"
"{ Package: 'stx:libbasic' }"
+"{ NameSpace: Smalltalk }"
+
SequenceableCollection subclass:#ArrayedCollection
instanceVariableNames:''
classVariableNames:''
@@ -55,13 +57,13 @@
Therefore, you SHOULD rewrite any application that does this,
to make use of OrderedCollections or any other collection which can grow fast.
- To remind you of that, a warning message is sent to the
- standard error whenever such an operation is performed (see #grow).
+ To remind you of that, a warning message is sent to stdErr,
+ whenever such an operation is performed (see #grow).
Also note, that some other Smalltalk systems do NOT allow
fix size collection to change their size, and that future
- ST/X versions may be changed to trigger an error (instead of a
- warning) in those situations.
+ ST/X versions may be changed to trigger an error
+ (instead of a warning) in those situations.
[author:]
Claus Gittinger
@@ -502,10 +504,10 @@
!ArrayedCollection class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ArrayedCollection.st,v 1.69 2014-12-11 17:08:43 cg Exp $'
+ ^ '$Header$'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/ArrayedCollection.st,v 1.69 2014-12-11 17:08:43 cg Exp $'
+ ^ '$Header$'
! !
--- a/Integer.st Sat Jan 23 07:23:05 2016 +0000
+++ b/Integer.st Tue Jan 26 09:27:00 2016 +0000
@@ -1135,9 +1135,10 @@
"return the bitwise-and of the receiver and the argument, anInteger.
Same as bitAnd: - added for compatibility with Dolphin Smalltalk.
Notice:
- please do not use ^ for integers in new code; it makes the code harder
- to understand, as it may be not obvious, whether a boolean or a bitWise or is intended.
- For integers, use bitAnd: to make the intention explicit."
+ PLEASE DO NOT USE & for integers in new code; it makes the code harder
+ to understand, as it may be not obvious, whether a boolean-and a bitWise-and is intended.
+ For integers, use bitAnd: to make the intention explicit.
+ Also, consider using and: for booleans, which is does not evaluate the right part if the left is false."
^ self bitAnd:aNumber
@@ -1229,9 +1230,10 @@
"return the bitwise-or of the receiver and the argument, anInteger.
Same as bitOr: - added for compatibility with Dolphin Smalltalk.
Notice:
- please do not use | for integers in new code; it makes the code harder
- to understand, as it may be not obvious, whether a boolean or a bitWise or is intended.
- For integers, use bitOr: to make the intention explicit."
+ PLEASE DO NOT USE | for integers in new code; it makes the code harder
+ to understand, as it may be not obvious, whether a boolean-or a bitWise-or is intended.
+ For integers, use bitOr: to make the intention explicit.
+ Also, consider using or: for booleans, which is does not evaluate the right part if the left is true."
^ self bitOr:aNumber
--- a/LargeInteger.st Sat Jan 23 07:23:05 2016 +0000
+++ b/LargeInteger.st Tue Jan 26 09:27:00 2016 +0000
@@ -5547,12 +5547,28 @@
even
"return true if the receiver is even"
-%{
+%{ /* NOCONTEXT */
#ifdef __SCHTEAM__
return context._RETURN( ((STLargeInteger)self).isEven() ? STObject.True : STObject.False);
+#else
+ OBJ digits = __INST(digitByteArray);
+
+ if (__isByteArray(digits)){
+ if (__byteArraySize(digits) > 0) {
+ unsigned char b = __ByteArrayInstPtr(digits)->ba_element[0];
+ RETURN( (b & 1) ? false : true );
+ }
+ }
#endif
%}.
^ (digitByteArray at:1) even
+
+ "
+ 16r100000000000000000001 even
+ 16r100000000000000000001 odd
+ 16r100000000000000000000 even
+ 16r100000000000000000000 odd
+ "
!
negative
@@ -5569,9 +5585,18 @@
odd
"return true if the receiver is odd"
-%{
+%{ /* NOCONTEXT */
#ifdef __SCHTEAM__
return context._RETURN( ((STLargeInteger)self).isEven() ? STObject.False : STObject.True);
+#else
+ OBJ digits = __INST(digitByteArray);
+
+ if (__isByteArray(digits)){
+ if (__byteArraySize(digits) > 0) {
+ unsigned char b = __ByteArrayInstPtr(digits)->ba_element[0];
+ RETURN( (b & 1) ? true : false );
+ }
+ }
#endif
%}.
^ (digitByteArray at:1) odd
--- a/OrderedCollection.st Sat Jan 23 07:23:05 2016 +0000
+++ b/OrderedCollection.st Tue Jan 26 09:27:00 2016 +0000
@@ -42,9 +42,9 @@
In addition, they provide all indexing access protocol
and bulk copying (much like Arrays).
- Insertion and removal at both ends is possible and also fast
+ Insertion and removal at both ends is possible and also usually fast
- therefore they can be used for queues and stacks.
-
+
[Instance variables:]
contentsArray <Array> the actual contents
@@ -53,11 +53,19 @@
lastIndex <SmallInteger> index of last valid element
[performance hint:]
- Although insertion and removal of inner elements is possible and supported,
- it may be slow, because remaining elements have to be copied to make space in the middle.
- If many elements have to be removed out of the middle of a big OC,
- it is often faster to create a new OC from scratch or to use another collection class
- (see SegmentedOrderedCollection) which is specialized for this kind of usage.
+ They overallocate a few slots to make insertion at either end often O(1),
+ but sometimes O(n), where n is the current size of the collection
+ (i.e. they have reallocate the underlying element buffer and therefore copy the
+ elements into a new one. However, this reallocation is not done on every insert,
+ and if elements are deleted and others reinserted, the buffer is usually already able
+ to hold the new element)
+
+ Insertion in the middle is O(n), and therefore slower, because elements have to be
+ shuffled towards either end, in order to make space for the new element.
+ Therefore, it is often cheaper, to instantiate a new object, and copy over the
+ elements.
+ see SegmentedOrderedCollection for a collection, which is specialized for this
+ kind of usage with many elements.
[beginners bug hint:]
notice that:
@@ -80,6 +88,14 @@
OBJ-HEADER + (3 * ptr-size)
+ (size-roundedUpToNextPowerOf2 * ptr-size)
+ [complexity:]
+ access by index: O(1)
+ insertion at either end: mostly O(1)
+ removal at either end: O(1)
+ insertion in the middle: O(n)
+ searching: O(n)
+ min/max: O(n)
+
[see also:]
Array
@@ -307,7 +323,6 @@
"
! !
-
!OrderedCollection methodsFor:'accessing'!
at:anInteger
@@ -1622,7 +1637,6 @@
! !
-
!OrderedCollection methodsFor:'private'!
initContents:size
--- a/OrderedDictionary.st Sat Jan 23 07:23:05 2016 +0000
+++ b/OrderedDictionary.st Tue Jan 26 09:27:00 2016 +0000
@@ -65,7 +65,7 @@
I am a subclass of Dictionary whose elements (associations) are ordered in a
similar fashion to OrderedCollection.
That is, while being filled via #at:put: messages (or similar Dictionary protocol),
- the order in which associations are added is remembered and accessable via the #atIndex:
+ the order in which associations are added, is remembered and accessable via the #atIndex:
or #order messages.
I have one instance variable:
@@ -73,6 +73,13 @@
order <OrderedCollection> Ordered collection of keys reflecting the order of
associations in the dictionary.
+ [complexity:]
+ access by index: O(1)
+ access by key: O(1)
+ searching: O(n)
+ insertion: mostly O(1)
+ removal: mostly O(N) (because order will have O(n) behavior)
+
[author:]
Ifor Wyn Williams <ifor@uk.ac.man.cs>
Changed by: exept
@@ -1115,10 +1122,10 @@
!OrderedDictionary class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/OrderedDictionary.st,v 1.48 2015-06-08 19:22:21 cg Exp $'
+ ^ '$Header$'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/OrderedDictionary.st,v 1.48 2015-06-08 19:22:21 cg Exp $'
+ ^ '$Header$'
! !
--- a/Stream.st Sat Jan 23 07:23:05 2016 +0000
+++ b/Stream.st Tue Jan 26 09:27:00 2016 +0000
@@ -214,7 +214,6 @@
^ ChunkSeparator
! !
-
!Stream methodsFor:'Compatibility-Dolphin'!
display:someObject
@@ -224,8 +223,6 @@
self nextPutAll: someObject asString.
! !
-
-
!Stream methodsFor:'accessing'!
contents
@@ -3529,6 +3526,72 @@
"Created: / 26-09-2012 / 18:21:06 / cg"
!
+printf:format with:argument
+ "C-style printing into a stream"
+
+ format printf:{argument} on:self.
+
+ "
+ Transcript printf:'%05x\n' with:12345
+ "
+!
+
+printf:format with:argument1 with:argument2
+ "C-style printing into a stream"
+
+ format printf:{argument1 . argument2} on:self.
+
+ "
+ Transcript printf:'%05x %3s\n' with:12345 with:'abc'
+ "
+!
+
+printf:format with:argument1 with:argument2 with:argument3
+ "C-style printing into a stream"
+
+ format printf:{argument1 . argument2 . argument3} on:self.
+
+ "
+ Transcript printf:'%05x %3s %09s\n' with:12345 with:'abc' with:'abc'
+ Transcript printf:'%05x %3s %9s\n' with:12345 with:'abc' with:'abc'
+ "
+!
+
+printf:format with:argument1 with:argument2 with:argument3 with:argument4
+ "C-style printing into a stream"
+
+ format printf:{argument1 . argument2 . argument3 . argument4} on:self.
+
+ "
+ Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4
+ Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4
+ Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4
+ "
+!
+
+printf:format with:argument1 with:argument2 with:argument3 with:argument4 with:argument5
+ "C-style printing into a stream"
+
+ format printf:{argument1 . argument2 . argument3 . argument4 . argument5} on:self.
+
+ "
+ Transcript printf:'%02x %02x %02x %02x\n' with:1 with:2 with:3 with:4
+ Transcript printf:'%2x %2x %2x %2x\n' with:1 with:2 with:3 with:4
+ Transcript printf:'%-2x %-2x %-2x %-2x\n' with:1 with:2 with:3 with:4
+ "
+!
+
+printf:format withAll:arguments
+ "C-style printing into a stream"
+
+ format printf:arguments on:self.
+
+ "
+ Transcript printf:'%05x %d %f %o\n' withAll:{ 123. 234*5. 1.234. 8r377 }
+ Transcript printf:'%03d %03d %03d\n' withAll:{ 1. 2. 3 }
+ "
+!
+
println
"for those used to Java/Javascript, a compatibility message.
Most useful inside expecco"
--- a/UninterpretedBytes.st Sat Jan 23 07:23:05 2016 +0000
+++ b/UninterpretedBytes.st Tue Jan 26 09:27:00 2016 +0000
@@ -81,28 +81,28 @@
"
UninterpretedBytes provides the common protocol for byte-storage
containers; concrete subclasses are
- ByteArray (which store the bytes within the Smalltalk object memory)
- String (knows that the bytes represent characters)
+ ByteArray (which store the bytes within the Smalltalk object memory)
+ String (knows that the bytes represent characters)
and
- ExternalBytes (which store the bytes in the malloc-heap).
+ ExternalBytes (which store the bytes in the malloc-heap).
UninterpretedBytes itself is abstract, so no instances of it can be created.
[See also:]
- ByteArray String ExternalBytes
+ ByteArray String ExternalBytes
[author:]
- Claus Gittinger
+ Claus Gittinger
[Notice:]
- Notice the confusion due to multiple methods with the same
- functionality (i.e. 'xxxx:MSB:' vs. 'xxxx:bigEndian:').
- The reason is that at the time this class was written,
- ST80 sid not offer protocol to specify the byteOrder, and
- ST/X provided methods ending in 'MSB:' for this.
- In the meanwhile, VW added protocol ending in 'bigEndian:',
- which has been added here for compatibility.
- (certainly a point, where an ansi-standard will help)
+ Notice the confusion due to multiple methods with the same
+ functionality (i.e. 'xxxx:MSB:' vs. 'xxxx:bigEndian:').
+ The reason is that at the time this class was written,
+ ST80 did not offer protocol to specify the byteOrder, and
+ ST/X provided methods ending in 'MSB:' for this.
+ In the meanwhile, VW added protocol ending in 'bigEndian:',
+ which has been added here for compatibility.
+ (certainly a point, where an ansi-standard will help)
"
! !