instruction
stringlengths
71
71.9k
This code finds the probabilities of the various scores in Poker. It uses a Monte Carlo approach, in which, two million (\$2 \times 10^{6}\$) hands are simulated and evaluated, not an exhaustive search. According to Wikipedia, my results are accurate. I strived to avoid over-engineering, where the only tricky part is p...
The following code transforms multi-line input into the the Brainfuck equivalent. One line turns into one program. The resulting programs are split by newlines for readability. Brainf.cpp #include "Brainf.hpp" int main() { std::vector<std::string> userInput; std::string currentLine = " "; // do not start empty...
The following code is designed to load and refresh JavaScript code from an external file sandbox.js and allow it to be refreshed dynamically and executed without reloading the entire page. The sandbox.js file is assumed to contain a function sandbox() which may contain arbitrary JavaScript code. As the title within the...
This is my first crack at a identity monad and a maybe monad in Elixir: defmodule Monad do @doc "v is value to be wrapped as monadic value" def return(v), do: fn -> v end @doc "m is monad function, mv is monadic value" def bind(m, mv), do: m.(mv.()) end #Simple identity monad id = fn ...
I'm working to get some practice with SQL functions which are often used in a financial setting, and I created this simple table with products, prices and tax rates basically. I then wrote a query to simulate a purchase invoice type of result set (I realize things like that are most often done at application level, or ...
The algorithm gets the number associated with each char, then adds a random number to it and saves the numbers it added. I plan to make an Encrypter class later. Here is the entire project: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using Sys...
To learn F#, I've implemented this very simple inventory system. While I'm proud that that it's my first program, and that it works, there are still a few areas that I'd like tips on, namely these: I don't like how I'm using a for ... in ... loop in Inventory.ChangeSelectedItem to find the length of Inventory.Items. I...
I am using Java with SQLite and I am wondering if I am in the right track onto writing good code i.e. more or less reusable: SQL scheme: CREATE TABLE Pessoa ( CPF VARCHAR(11) NOT NULL , telefone INTEGER , celular INTEGER , nome VARCHAR(255) , PRIMARY KEY(CPF)); CREATE TABLE Mecanico ( Pessoa_CP...
I'm playing around with RAII a bit lately and I wan't to know if/how I can improve this (quite simple but very helpful) class. A word to two decisions I've made and why: No error handling in construct. I don't think throwing a exception would be appropriate so it's up to the user to check valid(). No copy constructor....
I have a large image of an L-shaped painting on one page. I created divs over parts of the painting I want to explain. When the page loads, I want it to scroll down the length of the image, and then move to the left of the image, stopping at each div for a few seconds. I understand how to get the page to scroll down on...
I was trying to implement the algorithm specified in this research paper (please ignore the math, since it's irrelevant to the question). This algorithm is very basic in formal concept analysis. The input is supposed to be an NxM matrix and a list of lists or array of lists as you can see in the paper section 3.1. In f...
I am solving a simple problem that checks whether a graph is two-colourable (bipartite graph). I am using BFS for this approach using C++ STL. I've replaced cin and cout with scanf and printf as suggested by fellow programmers but still the judge reports TLE. #include<iostream> #include<list> #include<cstring> #include...
The program this function was written for is a Windows forms program. This function downloads videos from the internet one after the other. It runs in a separate thread (so the user can drag the form around or whatever), but otherwise the form is disabled, so no more instances can be created without doing so explicitly...
I have made this little program which allows you to play a slot machine: import random import time import os print() print('''Welcome to the Slot Machine You'll start with £50. You'll be asked if you want to play. Answer with yes/no. you can also use y/n There is no case sensitivity, type it however you like! To win y...
My current condition is written as follows: .Where(m => Math.Round((m.DateAndTime - DateTime.Now).TotalMinutes, 0) <= 30 && Math.Round((m.DateAndTime - DateTime.Now).TotalMinutes, 0) > 0) which basically says where the rounded value is less than or equal to 30 and the rounded value is greater than 0. Is there a neat...
Problem Find (a^b)%M, where a = Nth non-fibonacci number b = Nth fibonacci number modulo M M = 1000000007 Consider fibonacci series 1,1,2,3,..... INPUT First line contains T , the number of test cases. Each next T lines contains a number N. OUTPUT Print T lines of output where each line corresponds to the required an...
I've implemented the well known Luhn Algorithm in Python. It's a simple one, so it's good for beginners. import random from math import ceil def Luhn(digits): if digits >= 2: num = random.randrange(10**(digits-2),10**(digits-1)) num_digits = list(str(num)) for i in range(0,digits-1): ...
I am trying to extract the data from input file and store it for plotting. I have tested this code for a few files of same format. I am not sure if the code works correctly with the little change in input file (like more blank spaces in between). I might have also done some terrible mistakes which I cannot find out whi...
I have some tasks that I'd like to memoize because they connect to a rather slow network and have to wait for the data. Unfortunately this network can be a little finnicky and we get occasional connection issues. Thus I'd like if my memoizer could know to retry a certain number of times. import functools # Python 3....
Here is the task: Create several classes of flowers that extend abstract flower. all fields -- random. make a bunch of 20 different flowers calculate the price of the bunch sort bunch by freshness of flowers find flowers with stalks in a certain range find average level of freshness of the bunch Solution: publi...
I need to parse only valid timestamp formats: Hours followed by minutes followed by seconds: t=1h2m3s Minutes followed by seconds: t=2m3s Only hours: t=3h Only minutes: t=4m Only seconds: t=5s and escape other timestamp formats like t=2m1h or t=3s2m or t=3s1h2m. To get the hours, minutes and seconds, I use this Regex...
I'm working on a Rails application that has a lot of logic in the controller that should be in the model. In the app/controllers/customers_controller.rb#create there is logic to create stripe cc info for the customer. I think this should be in the model. How can I move this logic into the model and still handle any exc...
In angular, I have an input field for a user's full name. And a function called splitName which extracts the first / last name from the field. Is there a way to improve this logic? <input type="text" name="fullName" ng-model="data.full_name" /> On the backend, on form submit I do a POST which requires both a first_nam...
Can you assess source code of my client-server program? I would like to get an advice about design, code security etc. Thank you very much. The program does the following: Show files in directories; Download and upload files (for now, only one file at a time). Syntax: ./client <Server IP> <Server PORT> dir <PATH> ...
I wrote a piece of code that creates an array of objects based on the array of dictionaries. The problem is that my solution uses multiple loops imperatively. Let's consider the following case. There is a class called Drug: class Drug { var name:String var dosage:[(dose:String,time:String)] init(name:String){ se...
A coworker and I want to get feedback on our respective implementations of a JavaScript function. Both seem fast, but we're wondering which is better stylistically. Both functions handle what icons appear in a control panel when navigating between sections inside of an administrator dashboard. The first function funct...
I've used PyLint to harden the styling according to PEP8 as much as I could but looking for feedback on anything I've missed. Also some questions below: Passing argparse values directly to other functions helped me cut down on the number of local variables in main(). Is this a good practice regarding argparse? Should ...
I am trying to read a file using pandas and then process it. For opening the file I use the following function: import os import pandas as pd def read_base_file(data_folder, base_file): files = map(lambda x: os.path.join(data_folder, x), os.listdir(data_folder)) if base_file in files: try: ...
This is my first bit of significant code in Common Lisp, an implementation of insertion sort. Being new to Lisp in general, I'm wondering if this code follows best Lisp practices in regards to program design. ;;; Return a portion of a list (defun slice (elements from-index to-index) (cond ((= from-index to-index)...
I came up with the below code to improve the peformance of pinging a large number of machines. At present it's fairly basic, but thought I should see what people thought before proceeding further. NB: This is my first time playing with workflows, so I've probably committed a few faux-pas there. cls workflow Test-Connec...
I have written a simple application to monitor whether a couple of Java EE 6 web applications deployed to Glassfish 3.1.2.2 are accessible. My intent is to demonstrate to our operations team that the applications are intermittently inaccessible. package monitoring; import java.io.BufferedReader; import java.io.IOExcep...
I have recently started learning Clojure, and decided to write a number-guessing-game as an exercise. The game works as follows: User enters minimum and maximum values Computer generates a number between those two values (inclusive) User has to guess the number (the computer always tells him, whether his guess is bigg...
I have been learning Scala for a couple months and want to get a more concrete understanding of proper oop practice. I find it difficult to optimally use traits, abstract classes and inheritance. import scala.util.Random class Position(posX: Int, posY: Int){ val x = (posX + 16) % 16 val y = (posY + 16) % 16 ...
class Names: def __init__(self,name): self.name = name self.numname = name for letter in name: self.numname = re.sub(letter, rosetta[letter] + ",", self.numname) self.numname = self.numname.split(',')[:-1] Essentially what this does is creates an attribute for the object...
With Delphi 7 I need to create a TStream variable and use/free it in another part of the code. Unfortunately it cannot be passed as "normal" parameter. I created a simple application for testing what I need, using some examples I found on Google and some help from SOF (I am not used to pointers). Here is what I got so ...
This code has one public method. ProcMonDebugOutput(). It will sent a string of text to Process Monitor that process monitor will display. I'm basically ported this file. I don't have a 64 bit version of office to test this on, but I think I used all the LongPtr right. My two big concerns are: * Are the Win32 API call...
I'm written the following code to calculate the position of a motor during each timestep, the result of which will be compared with feedback from a quadrature encoder and subjected to a PID algorithm. The trajectory will follow a trapezoidal profile. i.e. Accelerate to a maximum velocity, coast and then decelerate to t...
I have written a program that divides an geographical area up in cells with size 0.002 degrees longitude by 0.001 degrees latitude, and check every cell whether it's a land area or a sea area. I've done this to effectively to get all the sea area of that area. This is probably insane from a GIS standpoint. Please revie...
First time implementing a adjacency list. Is the use of exceptions correct? If anyone could test/read the code and give some advice on improvments I would appreciate it. #include <iostream> #include <vector> #include <exception> #include <list> class VertexInvalidArg : public std::invalid_argument { public: Vertex...
I'm working on a class to download some data from an external server and feed it into my data model. I'm new to both HttpClient and async methods in C#, so I'm not sure of a few things. Is my placement of new SearchResultSet() reasonable? It's a little contrived, true, but I'm trying to get an example of how async c...
I have written an abstract View Model which all my other View Models inherit when I write any apps in Silverlight, WinRT, WPF etc. The class was written to attempt to address an issue I have run into frequently. That is, after refactoring code, all my property names are wrong and I often forget to rename them. Debuggin...
I recently posted my Hangman game, and got some amazing feedback! The main thing suggested was to create a word generator that could read JSON files so that my hangman brain class didn't have to generate the word used on top of handling gameplay. To do this, I created the HangmanWordGenerator class that parses JSON and...
Approach 1: Repeated division-modulus operations: long num = 123456789; int count = 0; while(num > 0) { int digit = num % 10; if(digit == 1) count ++; num /= 10; } Approach 2: Convert it into an String and get the characters at the position: long num = 123456789; int count = 0; String s = String.valueOf(num); for...
Let me start off by saying I am not new to PHP or PDO, but very new to OO PHP, and have been struggling to get a firm idea of best practices in my head regarding dependency injection and structuring my classes and their methods. The code I am providing will clearly be built on once I know I am doing things the correct ...
I have project where I will need to create lots of immutable strings. If I am using std::string, which has huge overhead - about 60-70% against const char *. On a 64-bit machine, the current implementation uses 8 bytes for the class + the const char * size. This is the same size as it would be with plain C. I will also...
This code is a chunk of big project, so I am sorry in advance for not adding everything as it's just not possible. [DataContract] public class Companionship { [DataMember] public int ID; [DataMember] public string ClientID; [DataMember] public string UserSID; [DataMember] public string R...
I created a function that truncates an incomplete UTF-8 character at the end of std::string in C++. C++'s Standard Library does not yet support character based substr on UTF-8 characters and does substr by number of bytes only. Because of that, in the example below, substr causes a weird broken character to appear in t...
Current code (ES6): getSelectedItem() { let result; return ((result = this.getItems().map((s) => { return Util.isItemSelected(s.toJSON()) ? s.toJSON() : false; }).filter(Boolean)) && result.length) ? result[0] : null; }, s is a Backbone.js Model (hence the need to .toJSON() on it). Apart from a ver...
I was in the mood for doing some GUI coding, and eventually I came with this simple program: you enter a date, press the button, and the program tells you temporal difference in days between the input date and current date. package net.coderodde.gui.date; import java.awt.Dimension; import java.awt.GridLayout; import ...
The method length() in File returns the length of a file in Bytes, this code transforms that into b/kb/mb as can be seen in the Windows Explorer I ended up with the code below, let me know if it can be optimized or the logic can be improved. public static String getFileSize(File file) { String modifiedFileSize = nu...
Let me know if the given code can be improved or optimized: public static String getFileNameWithoutExtensiotn(File file) { String fileName = null; if (file.getName().startsWith(".")) {//if starts with "." like .htaccess fileName = file.getName(); } else { try { fileName = file.ge...
I need to sort files by the type of the File. To accomplish the task I first wrote the code below: private static Comparator SortByFileType() { return Comparator.comparing((File f) -> { String probeContentType = null; try { probeContentType = Files.probeContentType(f.toPath()); ...
I have a very basic version of a media player built using JavaFX. The project is well segregated and has a different packages for controllers, utils and supporter classes. My project follows the MVC pattern and it contains the following important parts: All the views are in FXML files. These views have dedicated contr...
I have an array of objects where each object has a datetime key/value pair: var original = [ { datetime: '2015-07-22 09:00:00' }, { datetime: '2015-07-22 11:00:00' }, { datetime: '2015-07-23 10:00:00' } ] I need to transform them into a new array with objects where the first key/value pair of e...
Here's the challenge: Once upon a time in a strange situation, people called a number ugly if it was divisible by any of the one-digit primes (\$2\$, \$3\$, \$5\$ or \$7\$). Thus, \$14\$ is ugly, but \$13\$ is fine. \$39\$ is ugly, but \$121\$ is not. Note that \$0\$ is ugly. Also note that negative numbers can also b...
This code downloads a list of images, each in a different thread. I have some questions about this code: I don't know how to get information about correcting downloading (sometimes thread just stopped and doesn't do anything: no error, nothing and only part of image has been downloaded). I use the next mechanism for f...
I am looking for advice on my input component. There is no real problem with it yet, but I am just getting started on everything and want to know if there is any obvious problems with it, plus I was looking for advice on a design question of it. The design question refers to whether or not I should treat alt, ctrl, an...
Below is my implementation of the dynamic programming solution to the sequence alignment problem in C++11: #include <iostream> #include <string> #include <vector> using namespace std; const size_t alphabets = 26; /* * Returns the Needleman-Wunsch score for the best alignment of a and b * and stores the aligned s...
Context I have a node.js application that uses many other modules and libraries. Some of these modules pull details from process environment variables, such as URL's for databases, credentials, and so on. In particular, because this node app is running in Bluemix, there's a large JSON variable called VCAP_SERVICES that...
Lately, I've been part of a team working on a utility library for iOS called Thundercats (on Github). We're about to start working on some changes and upgrades in preparation for a 2.0 release, so we figured it might be a good time to get some of our code publicly reviewed. The library is written in Objective-C and is...
I wanted to know if my A* algorithm is well-implemented and if it could be optimized in any way. #include <iostream> #include <cmath> #include <list> #include <vector> #include <algorithm> class Vector2 { int x, y; public: Vector2(int _x, int _y) : x(_x), y(_y) {} Vector2() = default; Vector2 operator ...
In my version of the Partition Problem, I have a set of weights that are all powers of three (1, 3, 9, 27 etc.). I only have one of each weight. There is some object (the weight of this object is input) on the left side of a scale and I need to add weights to either side to balance it. I can choose not to use a weight ...
This question is a follow-up to this question. This is a year later, but it has the same context: I wanted new reviews for the updated code from the original question, but this time I wrote the code from scratch. I did this, not because the project is of any value or interest to me any more, as much as I wanted to comp...
My code reads a .csv file, looks for a couple values to create its key, and then wraps up the data based on a few business rules I have. I'm trying to learn "the right way", so I'd really appreciate some tips and hints. import csv import sys # add DictReader with open(sys.argv[1], 'rbU') as csvinfile: myreader = c...
NOTE: I'm only including the snake class (only one file) here because the rest of the code doesn't need reviewing. If you need to see the complete code for whatever reason, it is available on GitHub here (unless I delete it). I decided, since I never seem to finish my own original projects, that I would create a Snake ...
I need to test a specialized input stream class that takes input from a TCP/IP network connection. I particularly need to ensure that the blocking and availability behavior is correct. To help me with this, I wrote this "white box" input stream so that test scenarios can provide the necessary test conditions to exercis...
Given a strings like 'param1.param2.param3' and a value that should be set on the last parameter, is there a better way than the following to dynamically create an Object and reuse the function to create more parameters on the Object, some which may share a parent parameter? This function also assumes every parameter o...
This is a follow-on to my previous question: Enforcing set environment variables While learning more about JavaScript, node, and the bluemix environment, I have been using the loading of process environment variables as a starting point for understanding how the systems work. This part of the system checks to see if a ...
I decided that I wanted to add some spice to my bland looking city maps, so I created a couple of algorithms to add water to the map. I also added a "marshlands" setting that would just randomly sprinkle water throughout the map. Here is an example of the river generation: Here is the world generation method in its en...
I am learning how to implement Bootstrap modals in AngularJS. I can do it when the modal code (the actual popup window code) is on the main page, but I want to be able to display external files so that my SPA isn't super-cluttered. I am implementing this on a much larger scale, but for simplicity's sake I'll keep the ...
I have worker code that looks like this: class VerificationWorker include Sidekiq::Worker def perform(panel_id) members = MembersAPI.members.fetch members.each do |member| survey = Survey.find_by(number: member.data_number) next if survey.nil? if survey.id != member.data['survey_id'] ...
Any suggestions, corrections and advice would be very nice and much appreciated. public class Download { public event EventHandler<DownloadStatusChangedEventArgs> DownloadStatusChanged; public event EventHandler<DownloadProgressChangedEventArgs> DownloadProgressChanged; public event EventHandler DownloadCom...
The first revision is available here and the code is available on GitHub. I modified the method reversePairs and added mSize to convert my singly linked list to an array. Now my main question is the following: do I test all possible types of input for this problem? SinglyLinkedList package com.reversell; public class...
I'm working on a class to parse RSS feeds using SyndicationFeed. (related to Downloading data using HttpClient). I'm trying to write this so it can be unit-tested, but there's an awful lot of boring setup boilerplate before I get to the important stuff. My data source sometimes sends invalid RSS XML according to XmlRe...
I wrote a function that generates an image like: The function is as follows: /** Draws a texture wherein are spots of "heat" where a pixel's spotColor is of highest alpha, fading as distance from heat * spots increases. * @param width * @param height * @param spotColor The color of the spots, i...
I have made a basic program using AngularJS that displays data from a JSON file, and filters it according to the user's selection (specifically FIFA 15 chemistry cards). I did plenty of CSS work to it; mainly to test myself as I have barely used it. I have done some (minimal) work to make certain aspects respond to dif...
I had perceived an uptick in new reviewers around here, and I wanted to see if the data backed that observation up. It's been a while since I've written any SQL, so this was a nice little exercise in using the Stack Exchange Data Explorer. The query finds the first question and first answer from every user, and then gr...
I was practicing working with classes and the static property included with them and came up with a simple ID counter and max number list. I also added a quick debug error throw if it goes over. Here's what I came up with: #include <iostream> // A class that has static variables to save information for the ID's of its...
I recently had an interview question: Write a method that counts all comments in a single external file. It was a timed question and I wanted to know if this is the best way to accomplish the task. I'm also open to improvements, advice, etc. (I didn't pass the interview.) class Program { static void Main(string[]...
I'm an advanced beginner Haskell programmer. I implemented a set data type in Haskell and I wanted to find out if I made correct choices when writing it. Would there be a way to improve some of the algorithms like intersection etc. data SET a = E | Add(a, SET a) deriving (Eq, Ord, Read, Show) --test data setx = listT...
This is a programming challenge I set for myself a while back to create an AI that starts with no knowledge of anything whatsoever, and learns as you talk to it. (It can learn stuff like your name, how to say hello, goodbye, etc.) I tried to use the least amount of hard-coded responses as possible. I'm happy that it wo...
I am building a Metro-themed WPF application with MVVM approach using Prism and MahApps.Metro. I have to show a custom dialog from view model. Currently, I am using InteractionRequest and a custom TriggerAction to accomplish it, but I don't know if this is a good way. MainWindow.xaml <Controls:MetroWindow x:Class="...
I have a scenario to find the CategoryId which all have the mentioned Mode values. The schema of the table ModeTester: CREATE TABLE ModeTester ( ModeId INT IDENTITY(1, 1) NOT NULL, CategoryId INT, Mode CHAR(1), ModeValue VARCHAR (20) ) The dummy values: INSERT INTO ModeTester (CategoryI...
I'm learning about algorithms and have been recently experimenting with insertion sort via recursion in Python. My code works fine, but I was wondering if there are any possible improvements that can be made. I am especially interested in ways to reduce the actual content of the code (i.e. make it shorter) or improve ...
Given a list of numeric intervals in the form of (a,b), where a and b are integers, it finds a set of disjoint intervals that cover the same numbers by splitting the original intervals at the points where they intersect. For example: disjoint [(1,2),(1,3),(1,3),(30,31)] gives [(1,2),(2,3),(30,31)]. Please help me make...
Is there a way to make my code simpler? Given three int values, (a, b, c) return their sum. However, if any of the values is a teen -- in the range 13..19 inclusive -- then that value counts as 0, except 15 and 16 do not count as a teens. Write a separate helper (def fix_teen(n)) that takes in an int value and ...
The aim of this class is to set rules for including navigational properties on Configuration level and then apply where needed in the code. I've decided to store expressions in the list for different entities and then invoke System.Data.Entity.QueryableExtensions Include method to get proper JOINs for my navigational p...
I'm trying to work out a way to create a combination of OR and AND filters in RxJava. Here's what I've done so far: public interface IFilter<T> extends Transformer<T, Boolean> {} public class OrFilter implements IFilter<T> { private final Observable<IFilter<T>> filters; public OrFilter(Iterable<IFilter<T>>...
I have been programming a maths quiz that can be used for teachers and I have have been trying to make the code as short as possible so it is easier to understand. If there is any way I could make it more concise, please tell me and explain the programming behind it. import sys import random def get_bool_input(prompt=...
I have been programming a maths quiz that can be used for teachers an I have have been trying to make the code as short as possible so it is easier to understand. If you have seen my previous post you maybe be wondering why I am re-posting as I already have received feedback, when trying to act on this feedback I seeme...
I have this piece of code which given a list returns another list which combines every element with every other element (without repetitions) using a given function as a combiner. I came up with three different version (2 of them listed below, fastest to slowest), and now I'm asking for help to optimize it/them even fu...
Parent has list of Children. I only have access to the list of children. I need to get list of unique parents from the List of Children. Is there a better/faster/more efficient way of doing it than this? var temp = new HashSet<Parent>( (from child in program.Children sele...
Given a C# string which is a set of hexadecimal numbers such as: string HexString = "202048656c6c6f20576f726c64313233212020"; Where those hexadecimal numbers represent the ASCII text: " Hello World123! " I need to convert the HexString to a String and I have the following code which works, but looks so excessive! s...
I have a utility called ZipFileCombiner that combines zip archives into a single archive. Part of the implementation is using an Enum called CollisionStrategy to deal with entry collisions. It's a nested Enum. It seems kind of ugly to me. It feels like embedding that much code within the Enum seems wrong. I could cr...
See the next iteration. I designed and implemented this adaptive heap sort in Java. It works as follows: Copy the range to be sorted into auxiliary array \$A\$ Create an empty run heap \$H\$ Scan \$A\$ from beginning to the end and whenever we have counted a longest possible run (a run is a longest ascending or descen...
I've been reading Item 6 from Scott Meyers' Effective Modern C++ and noticed that he mentioned a technique called expression templates. I've decided to give it a try and implemented a vector that supports addition and subtraction: #include <iostream> #include <vector> template<typename T> class Vec { public: std::...
With the help of some nice folks at Stack Overflow, I wrote an algorithm that will give a user three buttons: option a neither option b Clicking on a button will add one to the score of a object, and it will systematically go through each match-up to get an equal amount of questions for each character. Here's the meat ...
I feel like there must be a better way to do the following. I would really appreciate any feedback/pointers so that I can improve my code and skills (or lack thereof!). The goal is to allow users to query our imapala database using a python script, so that they don't have to learn SQL. I'd like to take the following ...
Lately, I've been part of a team working on a utility library for iOS called Thundercats (on Github). We're about to start working on some changes and upgrades in preparation for a 2.0 release, so we figured it might be a good time to get some of our code publicly reviewed. The library is written in Objective-C and is...
A few years ago there was a need to add a FIFO queue between 2 threads into my project. At that time I've got some interesting idea how to do that without any atomics and locks. (There was a discussion about this algorithm but it is in Russian.) The idea is the following: We have 2 threads: writer and reader. Queue cla...