mruby/c VM Source Code release 3.4
Loading...
Searching...
No Matches
c_hash.c File Reference

mruby/c Hash class More...

#include "mrubyc.h"
#include "_autogen_class_hash.h"
Include dependency graph for c_hash.c:

Go to the source code of this file.

Functions

mrbc_value mrbc_hash_new (struct VM *vm, int size)
void mrbc_hash_delete (mrbc_value *hash)
mrbc_valuemrbc_hash_search (const mrbc_value *hash, const mrbc_value *key)
mrbc_valuemrbc_hash_search_by_id (const mrbc_value *hash, mrbc_sym sym_id)
int mrbc_hash_set (mrbc_value *hash, mrbc_value *key, mrbc_value *val)
mrbc_value mrbc_hash_get (const mrbc_value *hash, const mrbc_value *key)
mrbc_valuemrbc_hash_get_p (const mrbc_value *hash, const mrbc_value *key)
mrbc_value mrbc_hash_remove (mrbc_value *hash, const mrbc_value *key)
mrbc_value mrbc_hash_remove_by_id (mrbc_value *hash, mrbc_sym sym_id)
void mrbc_hash_clear (mrbc_value *hash)
int mrbc_hash_compare (const mrbc_value *v1, const mrbc_value *v2)
mrbc_value mrbc_hash_dup (struct VM *vm, mrbc_value *src)

Detailed Description

mruby/c Hash class

 Copyright (C) 2015- Kyushu Institute of Technology.
 Copyright (C) 2015- Shimane IT Open-Innovation Center.

 This file is distributed under BSD 3-Clause License.


Function summary

(constructor)
   mrbc_hash_new()

(destructor)
   mrbc_hash_delete()

(setter)
 --[name]------------------[arg]--[ret]-[note]------------------------
   mrbc_hash_set()          *K,*V   int

(getter)
 --[name]------------------[arg]--[ret]-[note]------------------------
   mrbc_hash_get()           *K      V  Data remains in the container
   mrbc_hash_get_p()         *K     *V  Data remains in the container
   mrbc_hash_search()        *K     *K  Data remains in the container
   mrbc_hash_search_by_id() SymID  *K   Data remains in the container
   mrbc_hash_remove()        *K      V  Data does not remain in the container
   mrbc_hash_remove_by_id() SymID   V   Data does not remain in the container

(iterator)
 --[name]------------------[arg]--[ret]-[note]------------------------
   mrbc_hash_iterator_new() *V     I
   mrbc_hash_i_has_next()   *I     bool
   mrbc_hash_i_next()        *I     *V  Getter. Data remains in the container

(others)
   mrbc_hash_size()
   mrbc_hash_resize()
   mrbc_hash_clear()
   mrbc_hash_compare()
   mrbc_hash_dup()

 

Definition in file c_hash.c.

Function Documentation

◆ mrbc_hash_clear()

void mrbc_hash_clear ( mrbc_value * hash)

clear all

Parameters
hashpointer to target hash

Definition at line 276 of file c_hash.c.

Here is the call graph for this function:

◆ mrbc_hash_compare()

int mrbc_hash_compare ( const mrbc_value * v1,
const mrbc_value * v2 )

compare

Parameters
v1Pointer to mrbc_value
v2Pointer to another mrbc_value
Return values
0v1 == v2
1v1 != v2

Definition at line 292 of file c_hash.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_hash_delete()

void mrbc_hash_delete ( mrbc_value * hash)

destructor

Parameters
hashpointer to target value

Definition at line 108 of file c_hash.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_hash_dup()

mrbc_value mrbc_hash_dup ( struct VM * vm,
mrbc_value * src )

duplicate

Parameters
vmpointer to VM.
srcpointer to target hash.

Definition at line 313 of file c_hash.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_hash_get()

mrbc_value mrbc_hash_get ( const mrbc_value * hash,
const mrbc_value * key )

getter

Parameters
hashpointer to target hash
keypointer to key value
Returns
mrbc_value data at key position or Nil.

Definition at line 197 of file c_hash.c.

Here is the call graph for this function:

◆ mrbc_hash_get_p()

mrbc_value * mrbc_hash_get_p ( const mrbc_value * hash,
const mrbc_value * key )

getter

Parameters
hashpointer to target hash
keypointer to key value
Returns
pointer to mrbc_value or NULL

Definition at line 211 of file c_hash.c.

Here is the call graph for this function:

◆ mrbc_hash_new()

mrbc_value mrbc_hash_new ( struct VM * vm,
int size )

constructor

Parameters
vmpointer to VM.
sizeinitial size
Returns
hash object

Definition at line 77 of file c_hash.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_hash_remove()

mrbc_value mrbc_hash_remove ( mrbc_value * hash,
const mrbc_value * key )

remove a data

Parameters
hashpointer to target hash
keypointer to key value
Returns
removed data or Nil

Definition at line 225 of file c_hash.c.

Here is the call graph for this function:

◆ mrbc_hash_remove_by_id()

mrbc_value mrbc_hash_remove_by_id ( mrbc_value * hash,
mrbc_sym sym_id )

remove a data by symbol ID.

Parameters
hashpointer to target hash
sym_idsymbol ID
Returns
removed data.
TT_EMPTY, if not found.
Note
for use with OP_KARG.

Definition at line 253 of file c_hash.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_hash_search()

mrbc_value * mrbc_hash_search ( const mrbc_value * hash,
const mrbc_value * key )

search by key

Parameters
hashpointer to target hash
keypointer to key value
Returns
pointer to found key or NULL(not found).

Definition at line 123 of file c_hash.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_hash_search_by_id()

mrbc_value * mrbc_hash_search_by_id ( const mrbc_value * hash,
mrbc_sym sym_id )

search by symbol ID

Parameters
hashpointer to target hash
sym_idsymbol ID
Returns
pointer to found key or NULL(not found).
Note
for use with OP_KEY_P.

Definition at line 145 of file c_hash.c.

Here is the caller graph for this function:

◆ mrbc_hash_set()

int mrbc_hash_set ( mrbc_value * hash,
mrbc_value * key,
mrbc_value * val )

setter

Parameters
hashpointer to target hash
keypointer to key value
valpointer to value
Returns
mrbc_error_code

Definition at line 168 of file c_hash.c.

Here is the call graph for this function:
Here is the caller graph for this function: