AI
Animation
CGI
Compression
Console
Database
Debug
Dialects
Dialogs
Editor
Email
Encryption
Extension
External Library
File
File Handling
Files
Financial
FTP
Game
Games
Graphics
GUI
HTML
HTTP
Internet
LDC
Markup
Math
Module
Network
Networking
None
Other - Net
Parse
Patch
Printing
Protocol
Rebol
Scheme
Scientific
SDK
Security
Shell
Sound
SQL
TCP
Testing
Text
Text Processing
UI
User Interface
Util
Utility
VID
Visualization
Web
Win API
X-File
XML
REBOL [
    Title: "Hash Table"
    Date: 12-Nov-2002/12:17:35+1:00
    Version: 1.0.2
    File: %hashtable.r
    Author: "Gregory Pecheret"
    Purpose: "Very simple Hashtable object, but usefull!"
    Email: gregory.pecheret@free.fr
    library: [
        level: 'intermediate 
        platform: 'all 
        type: 'tool 
        domain: 'database 
        tested-under: none 
        support: none 
        license: none 
        see-also: none
    ]
]


hashtable!: make object! [
data: copy []

addvalue: func [key value /local k] [
    inserted: false

    foreach k data [
        if key == first k [
            append second k value
            inserted: true
        ]
    ]

    if not inserted [
        append data compose/deep [[(key) [(value)]]]
    ]


]


getKeys: func [/local k ret] [
    ret: copy []
    foreach k data [
        append ret first k
    ]
    return ret
]

getValue: func [key /local k ret] [
    ret: none
    foreach k data [
        if key == first k [
            ret: second k
        ]
    ]
    return ret
]


getValues: func [] [
    ret: copy []
    foreach key getKeys [
        append ret getValue key
    ]
    unique ret
]
]


{
; sample
; values added with the same key are put in a list
addValue "ghg" "ofgfg"
addValue "ghg" "hjhkh"
addValue "aaaa" "popop"
probe getKeys
probe getValue "ghg"
probe getValue "aaaa"
probe getValues
}
                                                                     
                                                                          

            
            
        
Copyright © 2018 Rebol Software Foundation