JNI (Java Native Interface) allows implementing methods in C/C++, and use them in Java.
class JNIExample {
// Native method, no body.
# -------- | |
# Hardware | |
# -------- | |
# Opcode - operational code | |
# Assebly mnemonic - abbreviation for an operation | |
# Instruction Code Format (IA-32) | |
# - Optional instruction prefix | |
# - Operational code |
/** | |
* Educational Stack-based VM. | |
* | |
* See also: | |
* - More complex example with recursion: https://gist.github.com/DmitrySoshnikov/afda459222e96e6002ac | |
* - Register-based VM example: https://gist.github.com/DmitrySoshnikov/6407781 | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* http://dmitrysoshnikov.com | |
* MIT Stye License (C) 2015 |
/** | |
* Shunting yard algorithm | |
* See: http://en.wikipedia.org/wiki/Shunting_yard_algorithm | |
* | |
* Converts infix notation to postfix notation | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style License | |
* | |
* (C) 2011, updated on 2020 |
/** | |
* LL(1) parser. Building parsing table, part 1: First and Follow sets. | |
* | |
* NOTICE: see full implementation in the Syntax tool, here: | |
* https://github.com/DmitrySoshnikov/syntax/blob/master/src/sets-generator.js | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style License | |
* | |
* An LL(1)-parser is a top-down, fast predictive non-recursive parser, |
/** | |
* Depth-first and Breadth-first graph traversals. | |
* | |
* In this diff we implement non-recursive algorithms for DFS, | |
* and BFS maintaining an explicit stack and a queue. | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style license | |
*/ |
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
/** | |
* Educational "Free-list" memory allocator. | |
* | |
* Maintains explicit list of free memory blocks, reuses blocks on free. | |
* Implements "first-fit" strategy. Uses pre-allocated heap of 64 bytes, | |
* with 32-bit machine word size. | |
* | |
* TODO: | |
* | |
* - Implement "best-fit" strategy |
/** | |
* Writing a Mark-Sweep Garbage Collector in C++. | |
* | |
* This is a source code for the Lecture 9 from the | |
* Essentials of Garbage Collectors course: | |
* | |
* http://dmitrysoshnikov.com/courses/essentials-of-garbage-collectors/ | |
* | |
* See full details in: | |
* |
let offset = 20000; | |
let chunk_size = 10000; | |
// File handle: | |
let mut handle = BufReader::new(File::open("data.bin").await?); | |
// Set cursor to needed chunk: | |
let mut chunk_stream = handle | |
.bytes() | |
.skip(offset) |