{"record":{"id":"5f39f189ed4fc076","repo":"egametang/ET","slug":"sortedset-lowervaluegreaterthanuppervalue","errorCode":null,"errorMessage":"SortedSet_LowerValueGreaterThanUpperValue","messagePattern":"SortedSet_LowerValueGreaterThanUpperValue","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.core/Scripts/Core/Share/Collection/SortedSet.cs","lineNumber":1666,"sourceCode":"\n                return current.Item;\n            }\n        }\n\n        public IEnumerable<T> Reverse()\n        {\n            Enumerator e = new Enumerator(this, reverse: true);\n            while (e.MoveNext())\n            {\n                yield return e.Current;\n            }\n        }\n\n        public virtual SortedSet<T> GetViewBetween(T lowerValue, T upperValue)\n        {\n            if (Comparer.Compare(lowerValue, upperValue) > 0)\n            {\n                throw new ArgumentException(SR.SortedSet_LowerValueGreaterThanUpperValue, nameof(lowerValue));\n            }\n            return new TreeSubSet(this, lowerValue, upperValue, true, true);\n        }\n\n#if DEBUG\n        /// <summary>\n        /// debug status to be checked whenever any operation is called\n        /// </summary>\n        /// <returns></returns>\n        internal virtual bool versionUpToDate()\n        {\n            return true;\n        }\n#endif\n\n        void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) => GetObjectData(info, context);\n\n        protected virtual void GetObjectData(SerializationInfo info, StreamingContext context)","sourceCodeStart":1648,"sourceCodeEnd":1684,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/Collection/SortedSet.cs#L1648-L1684","documentation":"Thrown by SortedSet<T>.GetViewBetween(T lowerValue, T upperValue) when the comparer reports lowerValue as strictly greater than upperValue. The library enforces the contract that the view's lower bound must not exceed its upper bound, because a backwards range cannot map to any subtree. It surfaces as an ArgumentException on the lowerValue parameter.","triggerScenarios":"Calling GetViewBetween(a, b) where Comparer.Compare(a, b) > 0; e.g. GetViewBetween(10, 5) with the default int comparer, or passing arguments in the wrong order. Also triggered by a custom IComparer<T> whose Compare returns an unexpected sign for equal or inverted inputs.","commonSituations":"Swapping min/max arguments by mistake; building bounds from user/sorted input that is not pre-validated; using a reverse or culture-specific comparer where the order surprises the caller; off-by-one when deriving bounds from an index.","solutions":["Validate (or swap) bounds before calling: if (Comparer.Compare(lo, hi) > 0) (lo, hi) = (hi, lo);","Check that your custom IComparer<T>.Compare returns 0 for equal items and a consistent ordering.","Unit-test GetViewBetween with lo == hi (allowed) and lo > hi (must throw) to lock the contract."],"exampleFix":"// before\nvar view = set.GetViewBetween(max, min); // throws if max > min\n\n// after\nif (set.Comparer.Compare(min, max) > 0) (min, max) = (max, min);\nvar view = set.GetViewBetween(min, max);","handlingStrategy":"validation","validationCode":"// Validate before GetViewBetween\nT lo = min, hi = max;\nif (set.Comparer.Compare(lo, hi) > 0) (lo, hi) = (hi, lo);\nvar view = set.GetViewBetween(lo, hi);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize bound-pair construction in one helper that always orders lo<=hi.","Lock the contract with tests for lo==hi (ok) and lo>hi (throws).","Double-check custom IComparer<T>.Compare sign conventions."],"tags":["sortedset","argument-validation","collection","csharp"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}