How would one efficiently implement a nested structure containing arrays of other nested structures in a language that doesn't support them? -
structure
this main structure need build, creating type tparent
(pseudocode, ()
array declaration):
type ne { single d() dword dc single b single v single d } type l { ne ns() dword nc } type tparent { l la() dword lc single lr } tparent ntest // accessed ntest.la(0).ns(0).b = 42 ...
however, proprietary language has used not feature "arrays of user defined types". nesting supported, apart ()
array declarations in types above, code valid.
question
what efficient way - algorithmically speaking - implement structure. thought expanding subtypes arrays, , accessing them using second array holds offsets, doubt efficient in way.
all can suggest create array of byte , work work memory in assembly languages. can hide complexity of memory access behind accessor methods like
single typename_fieldname_get(byte arr(), int offset) { return convertfombytetosingle( arr(offset+offset_of_field_name + 0), arr(offset+offset_of_field_name + 1), arr(offset+offset_of_field_name + 2), .... ); }
Comments
Post a Comment