Sort by TStringList, how does sorting work?

I'm just curious, as I have seen using Hashmaps in Java recently and am wondering if the Delphi Sorted String list is generally similar.

Does the TStringList object create a hash to use as an index for each item? And how does a search string get checked for a list of strings through the Find function?

I use Sorted TStringLists very often, and I just would like to understand that a little more is happening.

Suppose I don’t know how a hash map works, because I don’t :)

thank

+3
source share
6 answers

I interpret this question, as a rule, as a request for an overview of lists and dictionaries.

  • , , , .
  • -, - , . .

L D.

. , . , - .

, . V I, , L[I]=V. . , , . - .

<Key,Value>. , : D[Key]. , , - L[I], I.

Delphi . . .

Delphi TDictionary, , . , , , .

, : , , . .

+5

TStringList .

"" , (Sorted property = false), QuickSort.

, Sorted true.

Find ( IndexOf, find) (Sorted property = false, , Sorted ), , .

Find (Sorted property = true), (. http://en.wikipedia.org/wiki/Binary_search ).

, , , .

- , . , , , Sorted back to true, .

, .

EDIT: -, TDictionary Generics.Collections

+4

, Delphi. Ctrl- "" .

-Unicode Delphi Unicode . . , Delphi, , , , Unicode . / , - .

, , ( Objects). - , . , ( "2" "1", "19" )

+1

THashedStringList, ( Delphi).

+1

BTW, Unicode TStringList . TStringList.CompareStrings, Ansi (, , ), Ansi. TStringList, , 4 , TStringList / .

0

Delphi ( Delphi ) , Delphi. THashedStringList , . , , , , .

, , . , , , .

, , .

0

Source: https://habr.com/ru/post/1794603/


All Articles