We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
So, if it doesn't find the opening part of the tag in the format of "something.tag" (meaning it is a sub-tag) in the first line (so pos==string::npos), that means this is the primary tag, so it resests it to nothing (tag_preamble="").
If it does find the tag in that format ("something.tag"), that means this is a sub-tag, so it erases the ".tag" part (leaving only the "something", which will be retained through future line iterations, as it is declared outside of the main for-loop), removing it from the pathway hierarchy for future elements when they are added to the map.
The elements are added to the map based on the string generated from tag_preamble. This is how they are pulled for printing later. So any final values would have the correct, full, corresponding index "pathway" via the [string] (tab_preamble) used to access the map.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Attribute Parser
You are viewing a single comment's thread. Return to all comments →
Yes, it still works. Because it resets "tag_preamble" when the closed tag is encountered:
So, if it doesn't find the opening part of the tag in the format of "something.tag" (meaning it is a sub-tag) in the first line (so pos==string::npos), that means this is the primary tag, so it resests it to nothing (tag_preamble="").
If it does find the tag in that format ("something.tag"), that means this is a sub-tag, so it erases the ".tag" part (leaving only the "something", which will be retained through future line iterations, as it is declared outside of the main for-loop), removing it from the pathway hierarchy for future elements when they are added to the map.
The elements are added to the map based on the string generated from tag_preamble. This is how they are pulled for printing later. So any final values would have the correct, full, corresponding index "pathway" via the [string] (tab_preamble) used to access the map.