Results 1 to 1 of 1

Thread: How get Pointer and bucketsize of cHash?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    55
    Posts
    1,554
    Rep Power
    174

    How get Pointer and bucketsize of cHash?

    The idea is to fill in 2-d-array to virtual listview so i start with a string-array,

    DIM sData(Rows, Columns) As String
    Enum Columns 
     col_Index
     col_Name
     col_Alias
     col_GUID
     col_GeneralClassificationGroup
     col_SpecificSubgroup 
    ' ...
    End Enum
    
    the columns will contain different properties generic like Index, Name, Alias, Group etc.
    The order remains by index (1st column) and i have a couple of different property-types but some as the group here will appear multiple times and i have all the groups ( maybe one hundred) that are readable groupnames separate from the actual data stored in a hash-class where an abbreviation is the key for the groups name and the target-array currently holds all the abbreviations.
    So it is with all the other groupy-thing, category, types that all come to a separate column of my listviews that's why i want to put it all together into the virtual listview upon an array that has bit more than a million elements in first dimension (=rows)

    i think to fill in the real groups names instead of creating a lookup-table for the user to check what is "AXr", what stands "PSC" for - what does "UNR" mean?
    it were more user-friendly to let the listview show complete names and not torturing users to point on anything they want to read .

    More tables next to this one were an overkill also so the columns should hold all information without the need to lookup somewhere else again.

    Now to fill in all strings to the array would blow up the used memory to an ernormus number if every little 3-char-abbrev becomes the 5 to 35 chars that it stands for in thousands of rows

    Butthe names are present in strings and this listview is strictly a lookup-table - nothing will be changed by the user - i thought if i manipulate the pointers that all with the abbrev "AXr" is read as the content from the hash-bucket thats key is "AXr" so internally i will memorize the original value in StrPtr(sData(row, column)) and overwrite the original that it points the hash-bucket .
    I remember from - meanwhile deprecated - dictionary-module that these buckets were equal to BString preceeded by a dword , telling how many bytes in the bucket.
    So the buckets pointer was a perfect replacement for a stringpointer

    But cHash does not expose its pointer, and it were great if would not need store the length in front as
    htGeneralGroup.Add( sKey, mkdwd$(Lenf(sValue)) & sValue )
    
    'htGeneralGroupt is 1 hashtable of 8 or 9 tables  containing all possible names for a certain column
    
    that without knowing the pointer is pretty useless - where couldd i peek my dword now to know the length ?
    So i need to copy the content of the bucket and that kills the advantage of a fast working hash-table
    i need to allocate a local buffer just to "measure" the content of every bucket. (=Len).
    For a search-query different than with a key also - if i know the table content is UTF8 encoded and what i search has at least 10 cyrillic chars: i would not need to pull objects from the shelf with less than 20 bytes.

    Need Bucket-Ptr and perfection is when previous to a pointer a 32 bit integer-value holds the size of content at Ptr.



    btw. Did you know:
    actually the advantage of utf8 is not to detect for a programmer - as the danger in UTF16 :
    to stay on the safe side for any kind of encoding you must
    pre-allocate 4 bytes per char
    when you intend to store zero-terminated or fixed as String * number
    UTF16 (Wide) is as UTF8 varying in size. It can be 2 or 4 bytes per char (surrogates)
    Last edited by ReneMiner; 15-11-2024 at 06:09.
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. How to convert a pointer to an UDT ?
    By kcvinu in forum thinBasic General
    Replies: 4
    Last Post: 10-04-2021, 23:16
  2. Pointer to Variant
    By mike lobanovsky in forum Tips and Tricks
    Replies: 5
    Last Post: 17-12-2013, 11:35
  3. when it's time to use a pointer?
    By largo_winch in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 3
    Last Post: 01-12-2011, 20:16
  4. Pointer methods
    By Richard in forum Real world situations and solutions using thinBasic
    Replies: 1
    Last Post: 05-02-2010, 00:48
  5. File deletion when EXE chash
    By ErosOlmi in forum thinBundle bugs report
    Replies: 2
    Last Post: 05-06-2008, 13:28

Members who have read this thread: 4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •