



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of arrays, their accessing methods, and storage representation in the context of the cmsc430 spring 2007 course. It covers topics like multidimensional arrays, array accessing equations, dope vectors, and slices. The document also touches upon associative arrays and structs in c.
Typology: Study notes
1 / 7
This page cannot be seen from the preview
Don't miss anything!




CMSC430 Spring 2007 (^1)
CMSC430 Spring 2007 (^2)
CMSC430 Spring 2007 (^3)
Rewriting access equation: L-value(A[I,J]) = α - d1L1 - d2L2 +Id1 + Jd Set I = 0; J= 0; L-value(A[0,0]) = α - d1L1 - d2L2 +0d1 + 0d L-value(A[0,0]) = α - d1L1 - d2L2, which is a constant.
CMSC430 Spring 2007 (^4)
To create arrays:
CMSC430 Spring 2007 (^7)
CMSC430 Spring 2007 (^8)
Given array : A[L1:U1, L2:U2]: Give d1, d2, and VO for vector:
Dope vector A[I,] = B[L2:U2] VO = L-value(A[I,L2]) - d2L M1 = eltsize = d
Dope vector A[,J] = B[L1:U1] VO = L-value(A[L1,J]) - d1L M1 = rowsize = d
Create new dope vector that accesses original data
CMSC430 Spring 2007 (^9)
VO = L-value(A[L1,L2])
CMSC430 Spring 2007 (^10)
Access information by name without having a predefined ordering or enumeration:
Associative array: Use Name as index: CLASS[name] will be grade.
Problem: Do not know enumeration before obtaining data so dope vector method of accessing will not work.
Implemented in Perl and in SNOBOL4 (as a table)
CMSC430 Spring 2007 (^13)
type PayType=(Salaried, Hourly); var Employee:record ID: integer; Dept: array[1..3] of char; Age: integer; case PayClass: PayType of Salaried:(MonthlyRate:real; StartDate:integer); Hourly:(HourRate:real; Reg:integer; Overtime:integer) end
CMSC430 Spring 2007 (^14)
Tagged union type - Pascal variant records type whichtype = (inttype, realtype, chartype); type uniontype = record case V: whichtype of inttype: (X: integer); realtype: (Y: real); chartype: (Z: char4); Assumes string of length 4 end But can still subvert tagging: var P: uniontype P.V = inttype; P.X = 142; P.V = chartype; What is P.V value now?