3 ms·
"* On the other hand, it does more work since it also decodes attributes (O(1) access time), saving a lot of time to the caller of the library" This part I did
by roel_v 16y ago
"* On the other hand, it does more work since it also decodes attributes (O(1) access time), saving a lot of time to the caller of the library"
This part I didn't understand. Does he mean transforming the document's encoding into the platform's native encoding? How can the access time of a list of attributes be in constant time? I mean, there needs to be some form of lookup from the name of the attribute to its value. And how do the two relate to each other?
- Nitramp 16y agoThe trick is that through their mapping, they have an array of "attributes" for every element, with a specific offset for each attribute with a certain name. During construction, they build that array according to the names, so they do the lookup once during construction.
- roel_v 16y agoBut then how do you reference the attributes? I get the code to parse my xml document, then afterward I want to access a certain attribute (by name). The library would still need to look up the index of that attribute, at O(n) complexity, right?
- lincolnq 16y agono, quoting from grandparent: "a specific offset for each attribute with a certain name" -- e.g., for all <image> element, 'width' is always at attributes[0] and 'height' is at attributes[1], presumably regardless of whether that particular image has a width and height attribute.
- roel_v 16y agoOh I see, thanks.