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

mruby/c Array class More...

#include "mrubyc.h"
#include "_autogen_class_array.h"
Include dependency graph for c_array.c:

Go to the source code of this file.

Functions

mrbc_value mrbc_array_new (struct VM *vm, int size)
void mrbc_array_delete (mrbc_value *ary)
int mrbc_array_resize (mrbc_value *ary, int size)
int mrbc_array_set (mrbc_value *ary, int idx, mrbc_value *set_val)
mrbc_value mrbc_array_get (const mrbc_value *ary, int idx)
mrbc_valuemrbc_array_get_p (const mrbc_value *ary, int idx)
int mrbc_array_push (mrbc_value *ary, mrbc_value *set_val)
int mrbc_array_push_m (mrbc_value *ary, mrbc_value *set_val)
mrbc_value mrbc_array_pop (mrbc_value *ary)
int mrbc_array_unshift (mrbc_value *ary, mrbc_value *set_val)
mrbc_value mrbc_array_shift (mrbc_value *ary)
int mrbc_array_insert (mrbc_value *ary, int idx, mrbc_value *set_val)
mrbc_value mrbc_array_remove (mrbc_value *ary, int idx)
void mrbc_array_clear (mrbc_value *ary)
int mrbc_array_compare (const mrbc_value *v1, const mrbc_value *v2)
void mrbc_array_minmax (mrbc_value *ary, mrbc_value **pp_min_value, mrbc_value **pp_max_value)
mrbc_value mrbc_array_dup (struct VM *vm, const mrbc_value *ary)
mrbc_value mrbc_array_divide (struct VM *vm, mrbc_value *src, int pos)
int mrbc_array_index (const mrbc_value *ary, const mrbc_value *val)
mrbc_value mrbc_array_uniq (struct VM *vm, const mrbc_value *ary)
int mrbc_array_uniq_self (mrbc_value *ary)

Detailed Description

mruby/c Array 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_array_new()

 (destructor)
    mrbc_array_delete()

 (setter)
  --[name]-------------[arg]---[ret]-------------------------------------------
    mrbc_array_set()     *V     int
    mrbc_array_push()    *V     int
    mrbc_array_push_m()  *V     int
    mrbc_array_unshift() *V     int
    mrbc_array_insert()  *V     int

 (getter)
  --[name]-------------[arg]---[ret]---[note]----------------------------------
    mrbc_array_get()    idx      V      Data remains in the container
    mrbc_array_get_p()  idx     *V      Data remains in the container
    mrbc_array_pop()             V      Data does not remain in the container
    mrbc_array_shift()           V      Data does not remain in the container
    mrbc_array_remove() idx      V      Data does not remain in the container

 (finder)
    mrbc_array_index()
    mrbc_array_include()

 (others)
    mrbc_array_size()
    mrbc_array_resize()
    mrbc_array_clear()
    mrbc_array_compare()
    mrbc_array_minmax()
    mrbc_array_dup()
    mrbc_array_divide()
    mrbc_array_uniq()
    mrbc_array_uniq_self()

Definition in file c_array.c.

Function Documentation

◆ mrbc_array_clear()

void mrbc_array_clear ( mrbc_value * ary)

clear all

Parameters
arypointer to target value

Definition at line 420 of file c_array.c.

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

◆ mrbc_array_compare()

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

compare

Parameters
v1Pointer to mrbc_value
v2Pointer to another mrbc_value
Return values
0v1 == v2
plusv1 > v2
minusv1 < v2

Definition at line 443 of file c_array.c.

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

◆ mrbc_array_delete()

void mrbc_array_delete ( mrbc_value * ary)

destructor

Parameters
arypointer to target value

Definition at line 113 of file c_array.c.

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

◆ mrbc_array_divide()

mrbc_value mrbc_array_divide ( struct VM * vm,
mrbc_value * src,
int pos )

divide into two parts

Parameters
vmpointer to VM.
srcsource
posdivide position
Returns
divided array
Note
src = [0,1,2,3] ret = divide(src, 2) src = [0,1], ret = [2,3]

Definition at line 529 of file c_array.c.

Here is the call graph for this function:

◆ mrbc_array_dup()

mrbc_value mrbc_array_dup ( struct VM * vm,
const mrbc_value * ary )

duplicate (shallow copy)

Parameters
vmpointer to VM.
arysource
Returns
result

Definition at line 497 of file c_array.c.

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

◆ mrbc_array_get()

mrbc_value mrbc_array_get ( const mrbc_value * ary,
int idx )

getter

Parameters
arypointer to target value
idxindex
Returns
mrbc_value data at index position or Nil.

Definition at line 216 of file c_array.c.

Here is the caller graph for this function:

◆ mrbc_array_get_p()

mrbc_value * mrbc_array_get_p ( const mrbc_value * ary,
int idx )

getter

Parameters
arypointer to target value
idxindex
Returns
pointer to mrbc_value or NULL.

Definition at line 234 of file c_array.c.

◆ mrbc_array_index()

int mrbc_array_index ( const mrbc_value * ary,
const mrbc_value * val )

index

Parameters
arytarget array.
valsearch object.
Returns
index value or -1 if not found.

Definition at line 556 of file c_array.c.

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

◆ mrbc_array_insert()

int mrbc_array_insert ( mrbc_value * ary,
int idx,
mrbc_value * set_val )

insert a data

Parameters
arypointer to target value
idxindex
set_valset value
Returns
mrbc_error_code

Definition at line 348 of file c_array.c.

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

◆ mrbc_array_minmax()

void mrbc_array_minmax ( mrbc_value * ary,
mrbc_value ** pp_min_value,
mrbc_value ** pp_max_value )

get min, max value

Parameters
arypointer to target value
pp_min_valuereturns minimum mrbc_value
pp_max_valuereturns maxmum mrbc_value

Definition at line 463 of file c_array.c.

Here is the call graph for this function:

◆ mrbc_array_new()

mrbc_value mrbc_array_new ( struct VM * vm,
int size )

constructor

Parameters
vmpointer to VM.
sizeinitial size
Returns
array object

Definition at line 82 of file c_array.c.

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

◆ mrbc_array_pop()

mrbc_value mrbc_array_pop ( mrbc_value * ary)

pop a data from tail.

Parameters
arypointer to target value
Returns
tail data or Nil

Definition at line 299 of file c_array.c.

◆ mrbc_array_push()

int mrbc_array_push ( mrbc_value * ary,
mrbc_value * set_val )

push a data to tail

Parameters
arypointer to target value
set_valset value
Returns
mrbc_error_code

Definition at line 252 of file c_array.c.

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

◆ mrbc_array_push_m()

int mrbc_array_push_m ( mrbc_value * ary,
mrbc_value * set_val )

push multiple data to tail

Parameters
arypointer to target value
set_valset value (array)
Returns
mrbc_error_code

Definition at line 274 of file c_array.c.

Here is the call graph for this function:

◆ mrbc_array_remove()

mrbc_value mrbc_array_remove ( mrbc_value * ary,
int idx )

remove a data

Parameters
arypointer to target value
idxindex
Returns
mrbc_value data at index position or Nil.

Definition at line 397 of file c_array.c.

◆ mrbc_array_resize()

int mrbc_array_resize ( mrbc_value * ary,
int size )

resize buffer

Parameters
arypointer to target value
sizesize
Returns
mrbc_error_code

Definition at line 155 of file c_array.c.

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

◆ mrbc_array_set()

int mrbc_array_set ( mrbc_value * ary,
int idx,
mrbc_value * set_val )

setter

Parameters
arypointer to target value
idxindex
set_valset value
Returns
mrbc_error_code

Definition at line 178 of file c_array.c.

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

◆ mrbc_array_shift()

mrbc_value mrbc_array_shift ( mrbc_value * ary)

removes the first data and returns it.

Parameters
arypointer to target value
Returns
first data or Nil

Definition at line 327 of file c_array.c.

◆ mrbc_array_uniq()

mrbc_value mrbc_array_uniq ( struct VM * vm,
const mrbc_value * ary )

removes duplicate elements and return allocated new mrbc_value

Parameters
vmpointer to VM.
arysource
Returns
result

Definition at line 573 of file c_array.c.

Here is the call graph for this function:

◆ mrbc_array_uniq_self()

int mrbc_array_uniq_self ( mrbc_value * ary)

removes duplicate elements

Parameters
arytarget
Returns
num of deleted

Definition at line 588 of file c_array.c.

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

◆ mrbc_array_unshift()

int mrbc_array_unshift ( mrbc_value * ary,
mrbc_value * set_val )

insert a data to the first.

Parameters
arypointer to target value
set_valset value
Returns
mrbc_error_code

Definition at line 315 of file c_array.c.

Here is the call graph for this function: