The PackWord 구조

The PackWord 구조

이 구조는 부호 없는 워드(word)를 바이트 문자열로 패킹/언패킹하는 연산을 제공해요. packed 표현은 시스템이 네트워크 바이트 순서(빅엔디안)로 저장하는 것을 가정해요.

출처: 문서

본문

시놉시스 (Synopsis)

signature PACK_WORD (* OPTIONAL *)
structure PackWord<N>Big :> PACK_WORD (* OPTIONAL *)
structure PackWord<N>Little :> PACK_WORD (* OPTIONAL *)

인터페이스 (Interface)

val bytesPerElem : int
val isBigEndian : bool
val subVec : Word8Vector.vector * int -> LargeWord.word
val subVecX : Word8Vector.vector * int -> LargeWord.word
val subArr : Word8Array.array * int -> LargeWord.word
val subArrX : Word8Array.array * int -> LargeWord.word
val update : Word8Array.array * int * LargeWord.word
-> unit

설명 (Description)

val bytesPerElem : int

pack은 word를 byte 벡터로, unpack은 byte 벡터를 word로 변환해요. subupdate 함수는 바이트 문자열의 지정 위치에서 접근/갱신해요.

val isBigEndian : bool

구조가 데이터를 빅엔디안 관점(최상위 바이트 먼저)으로 구현하면 true예요. 그렇지 않으면 구조는 리틀엔디안 관점(최하위 바이트 먼저)으로 구현돼요.

subVec (vec, i)

subVecX (vec, i)

이 함수들은 벡터 vec의 부분 벡터를 추출해 구조의 엔디안 방식에 따라 word로 변환해요. subVecX 버전은 부분 벡터를 word로 변환할 때 부호 비트(최상위 비트)를 확장해요. i가 0보다 작거나 Word8Vector.length vec < bytesPerElem * (i + 1)이면 Subscript 예외를 발생시켜요.

vec[bytesPerElem*i..bytesPerElem*(i+1)-1]

subArr (arr, i)

subArrX (arr, i)

이 함수들은 배열 arr의 부분 배열을 추출해 구조의 엔디안 방식에 따라 word로 변환해요. subArrX 버전은 부분 배열을 word로 변환할 때 부호 비트(최상위 비트)를 확장해요. i가 0보다 작거나 Word8Array.length arr < bytesPerElem * (i+1)이면 Subscript 예외를 발생시켜요.

arr[bytesPerElem*i..bytesPerElem*(i+1)-1]

update (arr, i, w)

구조의 엔디안 방식에 따라 word w의 하위 bytesPerElem개 바이트를 배열 arr의 bytesPerElemi번째부터 bytesPerElem(i+1)-1번째 바이트에 저장해요. i가 0보다 작거나 Word8Array.length arr < bytesPerElem * (i+1)이면 Subscript 예외를 발생시켜요.

더 알아보기 (Learn more)

  • [ Top | Parent | Contents | Index | Root ] Generated April 12
  • 2004 Last Modified May 29
  • 2000 Comments to John Reppy. This document may be distributed freely over the internet as long as the copyright notice and license terms below are prominently displayed within every machine-readable copy. Copyright © 2004 AT&T and Lucent Technologies. All rights reserved. Permission is granted for internet users to make one paper copy for their own personal use. Further hardcopy reproduction is strictly prohibited. Permission to distribute the HTML document electronically on any medium other than the internet must be requested from the copyright holders by contacting the editors. Printed versions of the SML Basis Manual are available from Cambridge University Press. To order
  • please visit www.cup.org (North America) or www.cup.cam.ac.uk (outside North America).