This is quite plain vanilla, but I'm hoping for Objective-C specific feedback. Also I'd be interested in what folks think about sorting in Objective-C vs. doing all sorting in C or C++ (and which?) even in an app.
- (NSMutableArray *) quickSort: (NSMutableArray *)toSort{
int intLength = toSo...
This code hasn't been tested. Unless the user's intent is to sort the object in the array based on their memory address, this code doesn't work as intended. — nhgrif1 min ago
@SimonAndréForsberg ^
(I can't fathom why anyone would want to do what the code posted actually does.)
I accidentally said something in the review queue "looks okay", but I really think it should be deleted. Is there a way I can take that "looks okay" back?
That example should definitely break the code in the question.
2015-07-20 19:16:43.747 test[10087:1115211] (
a,
e,
d,
c,
b
)
2015-07-20 19:16:43.748 test[10087:1115211] (
a,
b,
c,
d,
e
)
2015-07-20 19:16:43.748 test[10087:1115211] (
z,
b,
c,
d,
e
)
There's a ton of code here. For the purposes of this review, I'll be focusing on the HangmanBrain class (I've ignored everything else for this answer). This class seems to be the core, so it's a good place to start.
private struct Words {
static let Easy: [String] = ["fireplace","apple"...
So say for example I need a class variable, in Java I would do this:
public class SudokuBox {
private int[][] box;
public SudokuBox(int length, int width, int defaultValue) {
box = new int[length][width];
// fill with defaultValue
}
}
However, when I do this in a he...
You're on Stack Overflow and you've found a question that isn't about coding. It's about design or something squishy like that. You are trying to be helpful, and you put a comment in the question:
You should try asking on Programmers.SE instead. --YourName 2 minutes ago
... and suddenly, ou...
For what it's worth, the argument the method takes is pointless. But for the code to work, it needs to take a closure argument that takes two id and returns an NSComparisonResult.
- (void)quickSortWithComparator:(NSComparisonResult ^(id first, id second))comparator {
// compare the objects in self using comparator block
}
The code below doesn't seem right to me. The scenario is:
User enters in a "quantity" into a form field.
If the user enters in 5, the loop below should iterate 5 times.
There should now be 5 new entries in the database with the container.product and container.status
var container = new C...
I've created two methods in a class that allow me to download the contents of an FTP folder and if specified then delete them. Although the code operates as intended I think it's vastly bloated and I'm looking for direction on how to correct it.
Of note I believe that there's far too many FTP c...
This is just a starting point. I am decidedly not a Code Review regular, but when I mentioned this in chat it was well received so I'm helping to get the ball rolling. Again, see the Programmers Guide for ideas.
What is a good question?
A good question on CodeReview.SE would be a good question ...
@SimonAndréForsberg Can you make my question community wiki also? I didn't see a checkbox for that.
You're on Stack Overflow and you've found a question that isn't about fixing a problem. It's about improving code or something squishy like that. You are trying to be helpful, and you put a comment in the question:
You should try asking on CodeReview.SE instead. --YourName 2 minutes ago
......
i have two similar test method
private void typeCountTest(PieData pieData) {
for (Map.Entry<String,Integer> dataEntry:typeCountTestData.entrySet()){
String typeExcept = dataEntry.getKey();
Integer countExcept = dataEntry.getValue();
Integer countReal ...
This code is taking more than half an hour for a data set of 200000 floats.
import numpy as np
log = np.log
block_length = np.loadtxt('bb.txt.gz') # get data file from http://filebin.ca/29LbYfKnsKqJ/bb.txt.gz (2MB, 200000 float numbers)
N = len(block_length) - 1
# arrays to store the best con...
@200_success What's the process for getting the Help Center updated? I've written a good amount of documentation aimed at beginners/newcomers, I'd be happy to volunteer some time to help rewrite some of it
(i've seen the two links in your comment on the Meta, BTW)
To follow up on Help spot deficiencies in our Help Center, let's collaboratively draft better Help Center pages.
For each Help Center page to be modified, post a Community Wiki "answer" containing the original text of the page. Please try to reproduce the markup as faithfully as you can. Then,...
If working on a warning system for my game. I want to display an arrow on screen where the object is going to be coming from. Here is a Imgur of what I have in mind. Object will spawn from outside the screen and start making their way to the screen. The code that I have created works however it l...
Puchi hates to carry luggage, but unfortunately he got a job to carry
the luggage of his N friends in office. Each day, one of his N
friends, gives him the luggage of a particular weight to carry. You
will be given the weight of luggage of each friend in the array
Weight, where Weighti...
I have implemented a Binary Search Tree and methods - search, insert, delete in C++. I want to know if this is the best way to code the above methods or is there any other way by which I can reduce the code size or redundancies in code, if any.
#include <bits/stdc++.h>
using namespace std;
str...
I am trying to create a very simple jQuery based slider with fadeIn on pageload. But i have problems with the cycling of the script after the first time.
Here is my JavaScript code:
function slideShow(isFirst) {
if(isFirst) {
$('#slider_img_1').delay(1500);
}
...
I need to change the existing map swapping keys into values and values into keys. As there is duplicate values in my map for the keys I cannot use _.invert() of underscore library.
function map() {
return {
'eatables': {
apple: 'fruits',
ora...
Building linked list abstraction using class 'list' data model.
##################
# Linked List #
##################
#Representation - start
empty = 'empty'
def is_link(s):
""" s is a linked list if it is empty or a (first, rest) pair."""
return s == empty or (isinstance(s, list) ...
SET IfExistInd=0
SET canbeProcessed=''
::cd /d !phpdocpath!
ECHO ************************ BEGIN !DMXTaskType! !DATE! !TIME! !Thread! *****************
FOR /F "usebackq tokens=1-9 delims=|" %%A in (%SCRIPTDIR%loadConfigFile.txt) do (
SET Database=%%A
SET Dependency=%%B
...
Namespace
#include <bits/stdc++.h>
using namespace std;
The first line supposedly inserts all includes your code needs but haven't specifically included. The second line saves you a lot of typing by not having to insert std:: in front of all relevant methods and types.
Please don't use those!...
I'd really like them to be the place where newcomers can go to get started right.
[help/on-topic] should be good enough to explain a Stack Overflow referral. [help/dont-ask] should be good enough to serve as a rebuttal for bad referrals.
I wanted to come up with a 'utility' context to enable testing of the file system with behat.
Specifically this is aimed at helping with the behavioral testing of php command line applications that work with the file system, or use a configuration file.
I'd love for the whole repository to get ...
I am developing a service application that would implement a peer to peer messaging system. I am wondering if my following code is the best approach. It works, but I am naive and it would be nice to have validation from experts for performance and reliability.
There would be about 5 plugins and ...
I have a problem set which requires me to print all the multiples of a number in given range in reverse order.
So far I have tried this but not sure it is optimize or not!
int limit = 0;
int divisor = 5;
printf("enter a number : ");
scanf("%d",&limit);
printf("enter divisor : ");
scanf("%d",&d...
Related to the code shown at Cross-site request forgery defense for code to count Likes - I was wondering how I can ensure that a logged in user can only send a Like once in a predefined time of my choosing?
An implementation of a generic flattened iterator for flattening an iterator of iterators upto any composite level without using a stack for holding the iterators:
import java.util.ArrayList;
import java.util.Iterator;
class FlattenedIterator<E> implements Iterator<E> {
private Iterator<It...
@200_success I think the description under "Do I want the code to be good code?" is a bit ambiguous
> It's OK to ask for help to optimize code to run in a resource-constrained environment. However, asking about how to eliminate a few bytes of code at the expense of maintainability is off-topic.
@durron597 I had to downvote that meta answer for now, as it is not entirely correct. (too broad and opinion based questions often find a home here). However, as it was closed by @200_success, I will not edit it at this point in time.
Recently I have found in my code several places where I was first gathering some solutions, and then continued processing them only if the solution was unique (solution collection contained only one element). Following code is an attempt to solve this in a more functional manner.
implicit clas...
I've found some solutions in web but cannot use them for my instance. Help me please.
We have a List collection of string, and we need to remove all string's chars after third whitespace. In each string.
foreach (string eachLogString in weJustGotAllStrings)
{
...
Note: I am TOTALLY NEW to C++, so you can't expect best coding...
OK
I tried to create binary digit to decimal digit converter, but somethings not right with it, it gives me the wrong answers...
(I tried to use the advantage of char, that it can hold only one digit at a time to work on all 8 n...
An implementation of BlockingQueue
import java.util.LinkedList;
import java.util.List;
public class MyBlockingQueue<T> {
List<T> queue = new LinkedList<T>();
private int limit = 0;
public MyBlockingQueue(int limit) {
this.limit = limit;
}
public synchronized void e...
An implementation of a ReentrantLock:
public class ReentrantLock {
private boolean isLocked = false;
private Thread lockedBy = null;
private int lockCount = 0;
public synchronized void lock() throws InterruptedException{
while(isLocked && Thread.currentThread() != locked...
I'm looking to make some improvements to a deliberately crude API written in PHP, it's designed to handle simple requests and talk to the DB.
I have the following DB class:
class DB
{
public function connect()
{
$serverName = ".";
$connectionInfo = array("Database"=>"Dem...
This is my first script in Python, and I am looking for tips and constructive criticism about code style, whether there are more efficient ways of doing things, etc. (not as interested in tips about the method, more so the actual code).
Method:
Choose random no. blocks (between 2 & 6)
Decide ...
Recently I have found in my code several places where I was first gathering some solutions, and then continued processing them only if the solution was unique (solution collection contained only one element). Following code is an attempt to solve this in a more functional manner.
implicit clas...
> The Bohemia Interactive offices in the Czech Republic and Slovakia are home to more than 160 people of various nationalities. All of us share a common goal: making great video games.
After adding code you still haven't got an actual question or problem, you've effectively asked for a code review/debug - we don't do that. — slugsterjust now
@Quill actually a lot of car manufacturers will choose being sued over security/safety if they predict the cost of a law suit * the chance of the law suit is cheaper than fixing the security
Apart from @implementation TestObj ... @end (which is completely unnecessary because you never create an instance of that class) this code is plain old C and no Objective-C at all. — Martin R8 mins ago
@jacwah It is compiled by a C-compiler. Objective-C "compilers" do little more than turn special Objective-C syntax into C-code. And then compile it with a C-compiler.
I have a utility routine taking an open array of TControls and want to pass it a static array of TLabels. How can I do that most elegantly?
Please see the following example:
type
TForm1 = class(TForm)
Panel1: TPanel;
Memo1: TMemo;
private
FLabels: array[0..9] of TLabel;
public...