eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'FourByteString':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: FourByteString


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--ArrayedCollection
            |
            +--UninterpretedBytes
               |
               +--CharacterArray
                  |
                  +--FourByteString
                     |
                     +--Unicode32String

Package:
stx:libbasic2
Category:
Collections-Text
Version:
rev: 1.21 date: 2022/07/28 15:13:50
user: stefan
file: FourByteString.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


FourByteStrings are like strings, but storing 32bits per character.
The integration of them into the system is not completed ....

copyright

COPYRIGHT (c) 2004 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

initialization
o  initialize
initialize the class - private

Usage example(s):

     FourByteString initialize

instance creation
o  basicNew: anInteger
return a new empty string with anInteger characters

o  uninitializedNew: anInteger
return a new empty string with anInteger number of characters

Usage example(s):

        self uninitializedNew:10


Instance protocol:

accessing
o  basicAt: index
return the character at position index, an Integer
- reimplemented here since we return 32-bit characters

o  basicAt: index put: aCharacter
store the argument, aCharacter at position index, an Integer.
Returns aCharacter (sigh).
- reimplemented here since we store 32-bit characters

o  intValAt: index
return the int32 at position index, an Integer

filling and replacing
o  from: start to: stop put: aCharacter
fill part of the receiver with aCharacter.
- reimplemented here for speed

Usage example(s):

     (Unicode16String new:10) from:1 to:10 put:$a
     (Unicode16String new:20) from:10 to:20 put:$b
     (Unicode16String new:20) from:1 to:10 put:$c
     (Unicode16String new:20) from:1 to:10 put:$c
     (Unicode16String new:100) from:2 to:99 put:$c

     (Unicode16String new:10) from:0 to:9 put:$a
     (Unicode16String new:10) from:1 to:11 put:$a

o  replaceFrom: start to: stop with: aString startingAt: repStart
replace the characters starting at index start, anInteger and ending
at stop, anInteger with characters from aString starting at repStart.
Return the receiver.

- reimplemented here for speed

Usage example(s):

     'hello world' asUnicode32String replaceFrom:1 to:5 with:'123456' startingAt:2
     'hello world' asUnicode32String replaceFrom:1 to:5 with:'123456' asUnicode16String startingAt:2
     'hello world' asUnicode32String replaceFrom:1 to:5 with:'123456' asUnicode32String startingAt:2
     'hello world' asUnicode32String replaceFrom:1 to:0 with:'123456' startingAt:2
     'hello' asUnicode32String replaceFrom:1 to:6 with:'123456' startingAt:2
     'hello world' asUnicode32String replaceFrom:1 to:1 with:'123456' startingAt:2

queries
o  bitsPerCharacter
return the number of bits each character has.
Here, 32 is returned (storing quad byte characters).

o  bytesPerCharacter
return the number of bytes each character has.
Here, 4 is returned (storing quad byte characters).

o  isWideString
true if I require more than one byte per character

o  occurrencesOf: aCharacter
count the occurrences of the argument, aCharacter in myself
- reimplemented here for speed

Usage example(s):

     'hello world' asUnicode32String occurrencesOf:$a
     'hello world' asUnicode32String occurrencesOf:$w
     'hello world' asUnicode32String occurrencesOf:$l
     'hello world' asUnicode32String occurrencesOf:$x
     'hello world' asUnicode32String occurrencesOf:1

     Time millisecondsToRun:[
	|s|

	s := 'abcdefghijklmn' asUnicode32String.
	1000000 timesRepeat:[ s occurrencesOf:$x ]
     ]. 60 60 60 70 (untuned: 690 760 670)

testing
o  isSingleByteCollection
return true, if the receiver has access methods for bytes;
i.e. #at: and #at:put: accesses a byte and are equivalent to #byteAt: and byteAt:put:
and #replaceFrom:to: is equivalent to #replaceBytesFrom:to:.
false is returned here since at: returns 4-byte characters and not bytes
- the method is redefined from UninterpretedBytes.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 22 Dec 2024 03:05:45 GMT