This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
struct jintArray | |
{ | |
int size; | |
int *elements; | |
}; | |
struct env_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
def sqrt_calc | |
sqrt_hash = integer_sqrt_hash # instantiating hash table | |
n = 30000000 # number of test cycles to benchmark | |
Benchmark.bm do |x| | |
x.report do | |
n.times do | |
rgb_val = rand(1..255); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test | |
my_array = [1,2,3,4] | |
my_array.each do |i| | |
return i | |
end | |
end | |
puts test | |
# 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python | |
def my_func(arg_1 = []): | |
arg_1.append(1) | |
print arg_1 | |
my_func() | |
my_func() | |
# $ python test.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cc test.c -o test | |
my_var : 15 | |
my_ptr : 15 | |
my_ptr_ptr : 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
// struct with a common interface for varying data types | |
struct poly_struct | |
{ | |
void (*value)(); | |
void (*print)(struct poly_struct); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ptr_sample() | |
{ | |
int my_var = 15; | |
int *my_ptr = &my_var; | |
int **my_ptr_ptr = &my_ptr; | |
printf("my_var : %i\n", my_var); | |
printf("my_ptr : %i\n", *my_ptr); | |
printf("my_ptr_ptr : %i\n", **my_ptr_ptr); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(int argc, char const *argv[]) | |
{ | |
struct jintArray jvm_array; | |
jvm_array = create_jintArray(5); | |
struct env_type env_struct = create_env_structure(); | |
struct env_type *env_ptr = &env_struct; | |
struct env_type **env = &env_ptr; | |
int *native_array; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct jintArray create_jintArray(int size) | |
{ | |
struct jintArray jvm_array; | |
jvm_array.size = size; | |
jvm_array.elements = malloc(size * sizeof(int)); | |
for (int i = 0; i < (jvm_array.size); i ++){ | |
jvm_array.elements[i] = i; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int *ReleaseIntArrayElementsFunc(struct jintArray jvm_array, int *native_array) | |
{ | |
free(jvm_array.elements); | |
return 0; | |
} |
NewerOlder