Skip to content

Instantly share code, notes, and snippets.

Rodion Efremov coderodde

Block or report user

Report or block coderodde

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@coderodde
coderodde / Arrays.java
Last active Jun 17, 2019
Gist for net.coderodde.util.Arrays.sort(byte[])
View Arrays.java
package net.coderodde.util;
import java.util.Random;
/**
* This class contains static methods for sorting {@code byte} arrays.
*
* @author Rodion "rodde" Efremov
* @version 1.6 (Apr 24, 2019)
*/
View Long.java
package net.coderodde.util;
import java.util.Random;
/**
* This class contains a method for converting {@code long} values to strings.
*
* @author Rodion "rodde" Efremov
* @version 1.6 (May 13, 2019)
*/
@coderodde
coderodde / semaphore_impl.cpp
Created Jan 11, 2019
Windows port for a semaphore data type.
View semaphore_impl.cpp
#include "semaphore_impl.h"
#include <windows.h>
static const char* CLASS = "net/coderodde/util/concurrent/WindowsSemaphoreImpl";
static const char* FIELD = "semaphoreHandle";
static HANDLE get_semaphore_handle(JNIEnv* env, jobject obj)
{
jclass clazz = env->FindClass(CLASS);
jfieldID fid = env->GetFieldID(clazz, FIELD, "J");
View dt_tag_entry.cpp
#include "dt_tag_entry.hpp"
#include <string>
#include <utility>
namespace net {
namespace coderodde {
namespace dt2 {
TagEntry::TagEntry(std::string const& tag,
std::string const& directory)
@coderodde
coderodde / war.py
Last active Jun 9, 2018
Researching war scheduling algorithms.
View war.py
import copy
import random
import time
from heapq import heappush, heappop
class Country:
def __init__(self, name, resources):
self.name = name
@coderodde
coderodde / main.c
Last active Jan 22, 2018
Parallel for loop construct in C - follow-up
View main.c
#include "parallel_for.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#if defined(__APPLE__) || defined(__linux__)
#define POSIX
#endif
#if defined(POSIX)
@coderodde
coderodde / main.c
Last active Jan 21, 2018
Parallel for loop construct for C
View main.c
#include "parallel_for.h"
#include <stdio.h>
#include <stdlib.h>
#if defined(__APPLE__)
#include <sys/time.h>
#elif defined(__linux__)
#include <sys/time.h>
#elif defined(_WIN32)
#include <windows.h>
#else
@coderodde
coderodde / Benchmark.java
Created Dec 1, 2017
CR for boundary entries.
View Benchmark.java
package net.coderodde.boundaries;
import java.util.ArrayList;
import java.util.Random;
/**
* This class implements a benchmark for the boundary algorithms.
*
* @author Rodion "rodde" Efremov
* @version 1.6 (Dec 1, 2017)
@coderodde
coderodde / IntegerPatternMatching.java
Created Oct 31, 2017
IntegerPatternMatching.java
View IntegerPatternMatching.java
package net.coderodde.util;
import java.util.Random;
public class IntegerPatternMatching {
public static int getSubArrayIndex(int[] parentArr, int[] subArr) {
boolean found = false;
for (int i = 0; i <= parentArr.length - subArr.length; i++) {
if (parentArr[i] == subArr[0]) {
@coderodde
coderodde / TupleIterable.java
Created Oct 6, 2017
Tuple iterator in Java
View TupleIterable.java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
public final class TupleIterable<T> implements Iterable<List<T>> {
You can’t perform that action at this time.