Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FindNodeByKey()

int System.Data.Index.FindNodeByKey ( object originalKey)
inlineprivate

Definition at line 449 of file Index.cs.

450 {
451 if (_indexFields.Length != 1)
452 {
453 throw ExceptionBuilder.IndexKeyLength(_indexFields.Length, 1);
454 }
455 int num = _records.root;
456 if (num != 0)
457 {
458 DataColumn column = _indexFields[0].Column;
459 object value = column.ConvertValue(originalKey);
460 num = _records.root;
461 if (_indexFields[0].IsDescending)
462 {
463 while (num != 0)
464 {
465 int num2 = column.CompareValueTo(_records.Key(num), value);
466 if (num2 == 0)
467 {
468 break;
469 }
470 num = ((num2 >= 0) ? _records.Right(num) : _records.Left(num));
471 }
472 }
473 else
474 {
475 while (num != 0)
476 {
477 int num2 = column.CompareValueTo(_records.Key(num), value);
478 if (num2 == 0)
479 {
480 break;
481 }
482 num = ((num2 <= 0) ? _records.Right(num) : _records.Left(num));
483 }
484 }
485 }
486 return num;
487 }
readonly IndexField[] _indexFields
Definition Index.cs:34
IndexTree _records
Definition Index.cs:42
K Key(int nodeId)
Definition RBTree.cs:1407
int Right(int nodeId)
Definition RBTree.cs:1377
int Left(int nodeId)
Definition RBTree.cs:1382
readonly DataColumn Column
Definition IndexField.cs:7

References System.Data.Index._indexFields, System.Data.Index._records, System.Data.IndexField.Column, System.Data.ExceptionBuilder.IndexKeyLength(), System.Data.RBTree< K >.Key(), System.Data.RBTree< K >.Left(), System.Data.RBTree< K >.Right(), System.Data.RBTree< K >.root, and System.value.

Referenced by System.Data.Index.FindRecordByKey(), System.Data.Index.FindRecords(), and System.Data.Index.IsKeyInIndex().