/## Copyright 2021-2022 Kyle Gunger Dual licensed under the CDDL 1.0 and BSD 3-Clause licenses. This file may only be used in accordance with one of the two licenses. You should have received a copy of each license with the source code. In the event that you did not recieve a copy of the licenses, they may be found at the following URLs: CDDL 1.0: https://opensource.org/licenses/CDDL-1.0 BSD 3-Clause: https://opensource.org/licenses/BSD-3-Clause THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE EXPRESS OR IMPLIED #/ ;enum TEXT_ENCODING [uint] { UTF_8, UN7_1, ASCII } ;struct String extends Vector(uint8) { uint encoding } /; method String # Returns index of first difference, or -1 if there is no difference /; diff_index (String str) [int] ;uint l = math.mint(uint, str.length, self.length) /; loop (uint i = 0; i < l) [i++] /; if (self{i} != str{i}) ;return i [int] ;/ ;/ /; if () ;/ ;return -1 ;/ /; override operator == (String str) [bool] /; if (self.encoding != str.encoding || self.length != str.length) ;return false ;/ ;return diff_index(str) == -1 ;/ ;/