instruction
stringlengths
71
71.9k
I need to first filter items for an array of objects {type: 'genre', value: '123'} and after combine in a string content for property value only. Any suggestions on how to improve the following code? this.flattenCategories = function () { // flatten in a single string all categories so to be easily visaulised in th...
I have to generate random number which differs from the number generated last time. Which of these two variants is better? Or maybe you can suggest better implementation. int generateRandom() { int randomNumber; do { randomNumber = random.nextInt(UPPER_BOUND); } while (randomNumber == lastRandomNumb...
This is a solution to CodeEval's SkyScrapers challenge. You are given a list of triples \$(l, h, r)\$. Each triple represents an axis-aligned rectangle, with top-left corner at \$(l, h)\$ and bottom-right corner at \$(r, 0)\$. You can imagine these rectangles as buildings against a skyline. The task is to "draw" the sk...
I just finished studying immutable objects and their advantages so I thought I'd create one of my own. Here is my employee class that extends a person class. It is not mutable since I have getters to my mutable date objects. package objects.objects; import java.util.Date; public class Person { private final Stri...
I know I can use Sieves to make this faster, but I wondered if there's anything I'm missing with this implementation of the "naive" algorithm. On my PC running the command (first million primes): g++ -std=c++11 -Wall -Wextra -Ofast primes.cpp -o primes && time ./primes 15485863 this takes approximately 9.3 secs. #inc...
Background Kind of a follow up - slightly related to my other SO question. I thought that if somehow I find a way in VBA to pass a single column to .NET and convert it to a native .NET type then I could finally overcome the mystery of explicitly looping on objects via COM (which is super slow as we all know). I'd then ...
I've just started to write jQuery and have just written my first code using Ajax calls. I'm fetching data from the pokeapi and am using it to random generate new Pokemon. I have refactored it as much as possible, but I really think there must be a way to abstract the Ajax call into a function and only use one whilst st...
This is the first program I have ever written outside of what I am learning in class. I am in my first programming class (ever) in college and I'd like to know if this is any good or if I'm making glaringly bad habits and mistakes. I am aware that some of the code I've written is redundant, but I don't think I've qui...
The goal of this code is to create drop-down menu where there are 14 options on the list. Those 14 options are the dates that an RSS feed were last updated. The URLs for the feed have the query &issue=2014/10/14, but the trick is that it's set so that if a date is entered when the feed wasn't updated, it returns the mo...
I've been working on this mini project to teach myself how to better use the graphical functions and nested loops in Java. I have achieved my basic goal with this project to be able to draw on a screen pixel by pixel in blocks and diagonally. The basic idea is that it draws on the screen pixel by pixel in two different...
This is a multiplayer bowling simulator in Ruby. It allows for variable skill levels, and produces weighted random results for each player's rolls based on those skill settings. This is a complete rewrite of code I first posted for review here. My first solution was entirely procedural (all methods, no classes). I got ...
This is a custom MyActivity class with two custom views (bar and a ball): public class MyActivity extends Activity { // set class variables RelativeLayout content; public Ball view; Bar bar; Handler handler; BounceLoop thread; @Override protected void onCreate(Bundle savedInstanceState...
This is my JavaScript Rational class, similar to other languages' BigFraction class, but with one major difference: This class doesn't support arbitrarily large rational numbers: i.e. new Rational(Number.MAX_VALUE + 1) may fail. However, it supports arbitrarily precise numbers i.e. new Rational(1, 10).add(new Rationa...
Here is what I have currently working. I would like to make it look more aesthetically pleasing, so not finish words in mid word. Also not have the two previews be so much larger than the other. Ideally there would be a preview of two on the right (shorter) and then the one on the left (most recent) would show as m...
Creating a textual version of an int to save as a C string to a buffer that is all ready allocated and maximum allowable size is determined seems common. Thought I'd make a function to fulfill that. If the destination size is too small or destination is NULL, return NULL. Your critique of functionality, style, use, et...
I was tasked by my teacher with making a linked list by myself, so I could understand the concept better. Here is the MyLinkedList class: public class MyLinkedList<T>{ private Node<T> lastNode; private int nodeCount; public MyLinkedList(){ this.lastNode = null; this.nodeCount = 0; } ...
Implementation: IEnumerable<BigInteger> Fibs() { BigInteger a = 0; BigInteger b = 1; while(true) { b = a + (a = b); yield return a; } } Usage: void Main() { // take first 100 fib numbers var fibs = Fibs().Take(100); } How can I improve this?
I am just starting out with golang. I implemented the merge sort algorithm just to practice. Any suggestions or criticisms regarding the coding style? package main import ( "fmt" ) func main() { A := []int{3, 5, 1, 6, 1, 7, 2, 4, 5} fmt.Println(sort(A)) } // top-down approach func sort(A []int) []int { ...
I implemented the following function: the ruler function 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, . . . where the nth element in the stream (assuming the first element corresponds to n = 1) is the largest power of 2 which evenly divides n I'm giving it a vague name in the event that students try to cheat and s...
Context I'm working on a little project that consists in a series of Microsoft Excel add-ins (.xlam). The code being submitted for review here, is located in the Reflection project: Feel free to comment on the project architecture, but I'm mostly interested in the Reflection.LinqEnumerable class. Linq? Ok not exactly...
I am an amateur programmer and have just written a simple Capacitor Identifier mostly to practice. I have not had many people review my coding and thought this would be a good time to start. It is completed and works. Is there a better way I should have went about it? What should I look at in what and how I am writing ...
I wrote a program to find the greatest common divisor between two numbers. How do I improve this program? #include<iostream> using namespace std; int main() { int first_number; cout<<"Enter First Number : "; cin>>first_number; if(first_number < 0) cout << "Please enter a positive number" << endl; cin >> first_number...
After trying a couple different HTML5 frameworks, I've always found pure JS the most appealing. However, I am uncertain about the way I'm structuring it. var titlescreen = new Titlescreen(); var fps = new FPSTracker(); var input = new Input(); var background = new Background(); var shops = new Shops(); var chunkh...
I need a graph-search algorithm that is enough in our application of robot navigation and I chose Dijkstra's algorithm. We are given the gridmap which contains free, occupied and unknown cells where the robot is only permitted to pass through the free cells. The user will input the starting position and the goal posit...
Source code with some test: assert = require('assert') compile_csv_search = (text, lookupKey)-> [header, body...]= text.split('\n').filter(Boolean).map((el)-> el.split(',') ) col = header.indexOf(lookupKey) assert(col isnt -1) lookupIndex = body.reduce( (acc, row, i)-> ...
I'm creating a C++14 header-only JSON library for fun, learning experience and to use it in my personal projects. I'm looking for feedback on: Its API/interface: since I'm using modern C++, I want the API to be as expressive and easy to write/read as possible. I also want it to be terse. Its implementation: I'm tryin...
I came across a problem in my NodeJS app, which I solved by creating a method called groupBy. The purpose of this method is simple: take an array, and a function which will select a field from an element in the array. Each element in the array should then be grouped based on this field and returned as an object with th...
Prospero is a URI scheme. There you have fields and values. Could you check this code and give common suggestions or even test cases for JUnit tests? (The documentation is in German.) /** * Gibt einen Prospero-Parameter aus der URL zurück. Dabei wird nur der Prospero-Part geprüft. * * @param url Die URL, darf nicht...
The first part of code is for me very unreadable. I tried to write in another way but I'm open to your suggestion! return ViewData.ModelState.FirstOrDefault(x => x.Key.Equals(parameterName)).Value != null && ViewData.ModelState.FirstOrDefault(x => x.Key.Equals(parameterName)).Value.Errors.Any(x => !string.IsNullOrEmpty...
I am trying to write a procedure that finds the power set of a list, that is, the set of 2n subsets (where n is the number of elements in the list). I simply quite find all the subsets. I feel my code is a lot more work than it should be. (define (element-of-set? x set) (cond ((null? set) false) ((not(pair? s...
I wonder if I can reduce the code to optimize it better? $(document).ready(function () { $('#menu-1, #menu-event-1').hover(function () { $('#menu-deco-1').stop().animate({ right: 0 }, 'fast'); }, function () { $('#menu-deco-1').stop().animate({ right: -280 ...
I can't decide whether my method that returns an IEnumerable<T> should itself be lazy or whether it should build a list and return that. I often opt for the latter so I can be sure the enumeration of each value isn't performed multiple times. For example: public IEnumerable<UserProfile> GetUsers() { var allDepartme...
I know some things are a bit over the top (such as the hashmap use, but it was needed to use some sort of collection class) - but are there anything else that sticks out as a sore thumb in my code? I'll add comments to all my code eventually. I was also told to make it as object oriented as I could. Have I achieved it?...
I am writing a simple Django project which has no authentication at all. It's going to be used as the basis of a tutorial I'm writing, on the full authentication lifecycle (create account, login, change/reset password, delete account, etc.), where testing will be emphasized at every step. Beyond testing, the goal of th...
Implementation: void ReverseArray<T>(T[] a) { ReverseArray(a,0,a.Length-1); } void ReverseArray<T>(T[] a,int lo,int hi) { if(lo >= hi) return; // swap var temp = a[lo]; a[lo] = a[hi]; a[hi] = temp; ReverseArray(a,lo+1,hi-1); } Usage: int[] arr = {1,2,3,4,5,6,7,8}; ReverseArray(arr); // ...
The Skyline problem from UVa Online Judge is as follows: You are to design a program to assist an architect in drawing the skyline of a city given the locations of the buildings in the city. A building is specified by an ordered triple \$ (L_i,H_i,R_i) \$ where \$ L_i \$ and \$ R_i \$ are left and right coordinates, r...
I am trying to have a Backbone.Model which is a singleton and I wish to instantiate it lazily. I only need to support modern browsers so please do not worry about the use of ES5 getter. Is this the simplest way of achieving my goal? var LazySingleton = function(){ var _LazySingleton = Backbone.Model.extend({ ...
I currently have the following working code. I am looking for some suggestion with best practices and perhaps a better way to accomplish my goal. Goal: - in short - Have a generic data interface as a single data access point to different data sources. Concern: My current code is working fine but I have to call GetRepo...
Could you please advise on the code and its design? Is there any way I can apply object oriented principles to make the design robust yet flexible? public class RouteFinder{ /** Used to compute shortest distance from source station to all other station in a given network. * @param source source station from w...
I'm working on a LinqEnumerable class (reviewable here), and I'm no Big-O expert and I'm pretty bad with algorithms, so I wonder what the complexity is for what I've implemented here, and whether it could be improved. Join Correlates the elements of two sequences based on matching keys. Private encapsulated As New Coll...
I need a function call(f, args...) which calls the "function" f with the arguments args.... It should be compatible with the following "functions": Normal function pointers functors, lambdas, ... (= "callables"), call syntax: f(args...) Member function pointers, call syntax: (object.*f)(args...) and (ptr->*f)(args...)...
I need some help with this beginner C++ program (it's an assignment). How can I use a single variable and make the program get the six inputs I need instead of using a variable for each input? #include <iostream> using namespace std; int main() { double grade1,grade2,grade3,grade4,grade5,grade6; double totalGrade; c...
Implementation: static void ReverseMatrix<T>(T[,] matrix) { int width = matrix.GetLength(1); int height = matrix.GetLength(0); int startRow = 0; int startCol = 0; int endRow = height-1; int endCol = width-1; while (true) { if (startRow == height-1 || endRow == 0) return; ...
I took the idea from Reversing a matrix in C# and decided to write my own matrix-reversing code. Is there anything that I can do to make it even better? static void Main(string[] args) { var matrix = new[,] { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; ...
I've written a simple multithreaded queue manager in JavaScript which will be seeing some pretty heavy usage at a later point in the project I'm working on. I think it's pretty solid, but I wouldn't mind hearing some other opinions on it. Any potential problems? For convenience, here's a JSBin example of the queue. fun...
I have implemented some basic multithreading in my 2D mining game that I asked about in a previous question. The first part is working out great (creating the initial object instances in the background while displaying a loading screen rather than just having a black screen while they load). However, implementing mul...
I'm pretty new to linked lists - I understand the concept and how they work - but coding them is a bit more...complicated. I have some code below that I'm using for homework - essentially we're to create a struct containing data for a football player, and then create a linked list and add the struct to it. I'm not 10...
I have a NodeJS package, staticize, which takes an object of HTTP routes -> file locations, then serves them dynamically on each request. Could I get some feedback on the latest rewrite of the main file? (Also available on GitHub here) var fs = require('fs'); var mime = require('mime'); module.exports = function(app, ...
I am currently learning C and playing around with the rand() and if/else statement. This code looks long, just curious if there is another way to make the code shorter? The code below works fine, it's just randomize the output every time someone answers the question incorrectly. while(input != c){ srand(time(NULL))...
The following code computes: The longest common subsequence between two strings, where a subsequence of a sequence does not have to consist of contiguous elements of the sequence. The longest subsequence in a string that is a palindrome. All suggestions are welcome (more idiomatic f#, optimizations, styling, etc..)....
I have myself a little challenge tonight. I've tried to come up with the shortest code for the problem below (the code is pretty self explanatory, except determinGrade there which follows the rule A - 90-100% B - 80-89% C - 70-79% D - 60-69% F - Below 60% The code has to be PEP8 complient and no impor...
This is a simple C++ program I had to write for class. It prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits. How do I improve this? For example: Input: 3456 Output: 3 4 5 6 Sum of all digits: 19 Input: 1234 Output: 1 2 3 4 Sum of all digits: 10 ...
My partner and I are beginning to believe there could be a desync possibility in the lock free queue we have written, but we would like some fresh eyes on the subject. What are your thoughts on our design? // nolockqueue.hpp: #ifndef NOLOCKQUEUE_HPP #define NOLOCKQUEUE_HPP template<typename T> class noLockQueue { publ...
The Collatz's Conjecture states that any number can either be halved (if it is even) or multiplied by three and added one to (if it is odd) and eventually reach 1. I was wondering if there was a more efficient way to work out the series that a number takes to get to one and the amount of steps it takes. The Python (3....
The original problem is: Define the height of a binary tree to be the number of nodes in the longest path from the root to a leaf. The empty tree is considered to have height 0. A node is k-balanced if its left and right subtrees differ in height by at most k. A tree is k-balanced if all of its nodes are k-bal...
I created this to count points in an area. $(document).ready(function () { var area = [ [4, 4], [4, -4], [-4, -4], [-2, -2], [-2, 2], [-4, 4], [4, 4] ]; var points = [ [2, 1], [1, 2], [5, 3] ]; var res = countPoints(area...
Whenever I write a loop, I always use closure if it's appropriate by way of a self-executing anonymous function. I will typically write my searching loops as follows: var i = 0, length = myArr.length, fe = null; for (; i < length; i++) { if ((function (el) { if (el.searchCondition) { ...
I have written this Matrix class after posting an answer to Malachi's rags-to-riches question. The initial purpose had been to reverse a matrix represented by a 2D array. I have changed it to a more object-orientated version. Just for fun, I have added the ability to sum two Matrix objects: public class Matrix { pr...
For an online contest whose problem is here, I wrote some code. In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the punctuation marks ' (apostrophe), . (full stop), , (comma), ; (semicolon), : (colon) and white space characters (blank, newl...
I've written this scala code and I cannot work out how/if it is possible to remove the asInstance in the definition of class Problem. The basic idea is that there are two hierarchies Problem SpecificProblem ConcreteSpecificProblem and SolutionFinder SpecificSolutionFinder ConcreteSpecificSolutionFinder These hierarc...
I'm trying to solve the following problem : You are given two integers, X and Y. Calculate the number of bits that will be changed in order to convert integer X to integer Y. Here is my solution function findNumberOfBits(x, y){ var bitCount = 0; var z = x ^ y; //XOR x and y while (z !== 0){ ...
I'm creating a internet connection utility and below is the code I have used. Is there any better way of check for proxy and internet connection etc? /// <summary> /// Check the Internet connection using the url passed into it /// Network Adapter Check - TRUE /// Proxy Settings Check - TRUE /// ...
I am developing an Android Library which will be distributed to other developers. The library itself is a wrapper of the industry specific one. This makes the API development a bit less flexible. The main goal is to provide an easy and understandable API to the external developers. For now I've selected an asynchronous...
My colleague created this SQL to handle certain user selections which are based on an on/off bit flag. The goal is to identify those individual bit flags with a specific integer which will be used in a later SQL to group specific types which the flags relate to. What would be a more elegant way of doing this on SQL-Se...
Just looking for some feedback for one of my models I have for a project. I'm pretty happy with it but I was wondering if anyone had any optimization suggestions. class ContactModel { public function __construct($db) { try { $this->db = $db; } catch (PDOException $e) { ex...
How can I improve the following for loop (wannabe function) to create harmonic sizes for headers based on a specific ratio? var base = 16; var goldenRatio = 1.618; var list = ""; for(var i=6; i>0; i--){ list = "\nh" + i + " { font-size: " + base + "px; }" + list; base *= Math.round(base*goldenRatio); } conso...
I come from Python, with a bit a FORTRAN and Matlab some years ago. I'm trying to learn C. My first attempt at a program is one to merge all the files in a directory with a specified extension /* MERGE: Merges text files. Gives the ability to all files in a directory with specified extension. */ #include <stdio.h> #i...
This was a previous homework assignment I was required to do. While I did the assignment and turned it in for credit, I am not completely satisfied with the result I have. The rule for the assignment is it HAS to use backtracking and HAS to let the user pick a point which they want to start. It works well enough for bo...
I want to make sure that the code I have for encrypting and decrypting a serializable object makes sense and is proper. Does it look right too? Here's what I have so far: public static void encrypt(Serializable object, String path) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, Inva...
I have written the following function in order to normalize a container of double, so that it sums up to 1.0: /** * @brief This function normalizes a container so that it sums to 1.0. * * @param begin The beginning of the range to normalize. * @param end The end of the range to normalize. * @param out The beginnin...
A little while back, I wrote in a review of a Ruby bowling sim that I might try my hand at modelling the game myself, focussing on the funky "deferred scores" system. Since a2bfay, who posted the original question, has since posted a thoroughly updated piece of code, I figured I'd better get mine finished, especially s...
I'm unit testing some webpages and I'm trying to figure out how to best isolate the portions that need to be tested. There are two goals: Don't impose on the webpage's content or format, and be as clear as possible to the webpage editors what's going on, so they don't inadvertently break the tests. I've come up with so...
Background: I'm trying to synchronize order information between Oracle and SQL-Server databases and allow users to be able to track any changes between what has been replicated via an ASP.NET web page. Users will be able to select which line items they want to be able to work on via this page and the remainder will be...
I wrote this small example piece of OOP being implemented in pure C. I wanted it to be reviewed for the following points: Portability Performance And especially Usability "How does it look" Implementation: typedef char XCFString; struct XCFStringStatic { void *(*initWithCString)(const char *); }; struct XCF...
In my application, I have a message dispatcher. Each message gets relayed to a dispatcher thread. In some scenarios, I can get two responses from the third party in the same millisecond: An "I received your message" ACKnowledgement "My response to your message" RESPONSE When I get both messages at the same time, thi...
I am working on creating some libraries for a project at work and I wanted to make sure I have this pattern correct. Assuming that the GetWidgets() method is what I am going to be exposing, which is the preferred method for this? Is there any fundamental difference between these two methods? The first uses async/await ...
The following class implements a buffer which captures fast changing datapoints or frequently raised events and dispatches them in batches. It will asynchronously call a processing function for the buffered items under any of the following conditions: A configurable timeout has expired since the last time an item was ...
I'm a student currently studying computing/programming at school and am a beginner and would like some help understanding how to shorten down my code. I know some basic Python and can program relatively simple programs such as the one I need help with.My task/homework was to create a metric-imperial and vice-versa conv...
I'm implementing a communications protocol in an embedded system and the protocol uses a subset of the ASN.1 BER (Basic Encoding Rules). In a nutshell, this class simply represents a TLV triplet (Tag, Length, Value) in which the Tag is some label identifying the type of data, the Length is the length of the Value (in ...
I have recently been refactoring some code in an effort to improve the exception handling, particularly to aid in improving the level of information given to developers during development. However I am worried that I have started down the wrong path. For example we were getting complaints that the following code threw ...
I'm trying to account for the fact that my program will contain calculations such as: v(t) = w ∗ v(t−1)+ c1∗r1∗( pBest − x(t −1)) + c2∗r2∗(gBest − x(t−1)) where v, x, pBest, gBest are vectors (std::arrays). I'm a little worried if I make correct use of the move semantics. Here's the relevant snippet: template<class T...
Currently, in a utility class I have methods like so: public static String getNextAvailableNumber(List<MyObject> currentObjects) { int nextNumber = UtilClass.getNextAvailableNumberAsInteger(currentObjects, null); return UtilClass.formatNumber(nextNumber); //formats number as string } public static int getNextA...
That's Last Week, Month-to-Date, Season-to-Date, and Year-to-Date sales. I have a table-valued function for each one, that takes a date and returns all CalendarDate values for the interesting time span: dbo.CalendarDatesLW dbo.CalendarDatesMTD dbo.CalendarDatesSTD dbo.CalendarDatesYTD So I have a CTE for selecting YT...
I recently made a linked list for myself, the code of which was posted here, if anyone would be interested. Now, as the next task, I had to make an Iterator for my list, which is working properly. public Iterator<T> iterator() { final MyLinkedList<T> list = this; return new Iterator<T>() { final Node<T>...
I'm learning C# as a web developer rather than a C# developer learning web development. I've gotten the hang of creating models and controllers (or so I think) for a web project, and I've read some tutorials on general C# and I'm just putting it all together. I'd like to know how I can best refactor this code. Let's s...
I wrote the following suffixes function. Given a list, it returns the list + all sub-lists. suffixes [1,2,3,4] == [[1,2,3,4], [2,3,4], [3,4], [4], []] Please critique my implementation. suffixes :: [a] -> [[a]] suffixes [] = [] : [] suffixes xxs@(_:xs) = xxs : suffixes xs
I was bored the other day and wrote the following little script to attempt to find insecure passwords for WordPress blog owners so they could be notified of how easy it would be to crack their WP admin password. I am mainly a Perl/PHP developer, so I want to make sure any Python work I do sticks to being Pythonic and n...
Following is the code for a logger facade that I have created, which can be used to log via any of the standard and configurable loggers like log4net, BitFactory, currently I have just integrated these two. Salient features are: Logger can be changed at runtime, every iteration can use a different logger (I know that ...
You have to write a C++ program that reads in the employee hierarchy of a company and computes a statistic called 'salary budget' for all employees. For this problem, the 'salary budget' of any employee is defined as follows: For employees who are not managers, the salary budget is same as their salary For man...
Question Description: Given a number n, return True if n is in the range 1..10, inclusive. Unless outsideMode is True, in which case return True if the number is less or equal to 1, or greater or equal to 10. in1to10(5, False) → **True** in1to10(11, False) → **False** in1to10(11, True) → **True** The link to the p...
This is for my intro level C++ class. This is the assignment: Write a program that displays a takeout menu from which a user can place an order. The program begins by displaying the menu and prompting the user to enter a choice. If the user enters 1, 2, or 3, the program responds by asking for quantity (of piz...
I have a very simple helper class to validate credentials. Sometimes the domain has a value, sometimes not. Depending on this, a different constructor for PrincipalContext must be used. PrincipalContext is disposable, so I am using using. It looks ugly, and recommendations? public class LDAPManager : ILDAPManager { ...
# Alex Grattan # 17/10/14 message = input("Enter your message to have it printed backwards:") split_message = list(message.split()) reverse_message_list = [] reverse_message = "" for i in range(len(split_message)): reverse_message_list.append(split_message.pop()) reverse_message_list = [x + ' ' for x in reverse_...
This is a GUI-based random password generator, which supports internationalization. It consists of 6 small classes: Main classes: Application - entry point GUI - self-explanatory PassGen - class responsible for generating the password ExceptionReporter - utility class for displaying the critical error messages to the ...
Gives advice to the user on which trains to take to reach a destination public class TripAdvisor { private Station source; private Station destination; private double cost; /** * * @param path the shortest path returned by the shortestPath method implementation ...
I have some efficient methods that recursively creates a tree structure (NSTreeNode) of by looping recursively over a directory structure. The result is displayed in a NSOutlineView. This works well with one exception where I have to non-concurrently update a NSMutableDictionary that holds the structure of the tree. Th...
I'm writing a program that makes heavy use of std::bitset's and occasionally needs to read/write these to file. std::bitset does overload the << & >> operators, but using these will result in an ASCII encoded file (i.e. {0,1} = 1 byte), which is ~8x bigger than it would be if using a bit-for-bit encoding. I've seen a f...
This is a binary tree using classes. What can be improved upon? ClassTree.h #pragma once class Node{ private: int id; Node *left; Node *right; static int count; public: Node(); Node * first(Node *root); void search(Node *root, int digit); Node * insert(Node *root, int digit); voi...
Are there any other more exotic ways ... or is this one just good? void strdev (char *str, long from, long to) { char *part1 = malloc(strlen(str) - strlen(&str[from])); long i; part1[from] = '\0'; //for(i=0; i<from; i++) part1[i] = str[i]; // Old copying memmove(part1, str, from); // New copying ...
Here is AlarmService for setting up notifications on my phone. Currently, the code works and is functional. However, I noticed my code looks different than a few examples I found online. Should I be using Notification Compact builder instead? Also, any advice on how to make it better/cleaner would be great. import and...