I'm making an indexOfReverse utility function in my C++ program, and I have caught a bit of a snag. Implementing the offset and maxOffset in my indexOf was very intuitive to me.. These start from the beginning of the string (+offset), and go forth to the end of the string (or maxOffset if given).
While implementing offsets for the indexOfReverse, though, I was wondering what the most logical way to do this is? Should the offset be from the beginning of the string, or end of the string? Is there an established norm for this I am missing somewhere? I tried explaining it to my duck, but he just looked at me funny. I'm leaning towards thinking of it from the beginning, because of its ease-of-use being more valuable to me than its counter-intuitiveness.. considering the offset from the end just makes things harder to think about in my head.
I have looked at how it's done in a string library for C++, PHP, and Python, and what seems common in the description of each is finding the last of occurrence of a string where the offset is considered from the beginning, rather than doing true reverse-string searching... But I desire true reverse-string searching rather than last occurrence ofs. Is there a most logical way to consider this, though, so I can move on?