|
-
Jul 26th, 2017, 01:14 AM
#11
Re: Simple and fast, lightweight HashList-Class (no APIs)
 Originally Posted by loquat
Can u help make KeyByIndex property to be editable?
Why do you need that (I ask, because the need for something like that was near zero in the scenarios I've encountered over the last two decades).
I mean, there is some scenarios where it is needed, but these I usually cover with DBs and SQL.
 Originally Posted by loquat
I have and these codes to cHashD, but can not make it.
Code:
Private Declare Function VariantCopyLng Lib "oleaut32" Alias "VariantCopy" (Dst As Long, Src As Long) As Long
Public Property Let KeyByIndex(ByVal IndexZeroBased As Long, RHS)
If IndexZeroBased < 0 Or IndexZeroBased >= mCount Then Err.Raise 9
Select Case mKeyMode
Case eUseStrings:
RHS = CStr(RHS)
VariantCopyLng ByVal VarPtr(mKeys(IndexZeroBased)), ByVal VarPtr(RHS)
Case eUseIntegers:
VariantCopyLng ByVal VarPtr(mCurs(IndexZeroBased)), ByVal VarPtr(RHS)
Case eUseDoubles:
VariantCopyLng ByVal VarPtr(mDbls(IndexZeroBased)), ByVal VarPtr(RHS)
End Select
End Property
There's no need to overcomplicate things with API-calls in this case -
simple Value-assignments would be enough, like: mKeys(IndexZeroBased) = CStr(RHS)
But with something like that, you're only "halfway-there", because the old Key you have just overriden,
will still link to the old Index-Position of Keys and Value (when doing a Hash-based search), -
and for the new Key no such Hash-Link exists yet.
So in general, such requirements are solved, by removing the old Pair (OldKey and OldItemValue) completely from the List -
followed by adding the new Pair (NewKey/OldItemValue) over the normal Add-mechanism.
Olaf
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|