Skip to main content
11 votes
Accepted

Counting relevant entries in a large bioinformatics file

In order to speed this up, you'll need to avoid as many string creation operations as possible, because they are expensive. Especially the split operation is expensive. Not only does this create many ...
RoToRa's user avatar
  • 11.4k
10 votes

Counting relevant entries in a large bioinformatics file

If you are in for raw performance, try to avoid repeating potentially cost-intensive operations. In this case, you split the lines twice with the same parameter, which repeatedly applies a regular ...
mtj's user avatar
  • 4,862
9 votes
Accepted

Very simple CSV-parser in Java

Side-effects Stream.forEach() operation should be utilized with care since it operates via side-effects and should not be used as a substitution of a proper ...
Alexander Ivanchenko's user avatar
8 votes
Accepted

C++ string Formatter Again Part-1

First of all, this is remarkably good and clean code! Nevertheless, I do have some things to nitpick on: Code Formatting Let's talk about line length. As of right now, you have a (physical) line in ...
Ben Steffan's user avatar
  • 5,303
8 votes
Accepted

Overloading istream>> to read comma-separated input

95 percent of programming is looking for redundancies and eliminating them. For example, why do you bother with reading strings into accusations[] first, and then ...
Quuxplusone's user avatar
  • 19.4k
7 votes

Deflating a Stream using System.IO.Compression

I think you're doing too much in one function, hiding the big picture I'd want to read without going into the implementation details. I'd first start with a broad overview: ...
Adriano Repetti's user avatar
7 votes

Merge multiple map with java stream api

Some basic tips: Split this into 2 methods, drop the enum. It doesn't do you any good unless something is really forcing you to have it there. It will be a lot ...
K.H.'s user avatar
  • 2,678
7 votes
Accepted

Copy file with text replacement

std::getline and std::string are in the <string> header, so we need to include that. ...
user673679's user avatar
  • 11.9k
6 votes

StreamIterable - create an iterable from a Java 8 Stream

As an Iterable is a functional interface with a method just returning the iterator, you could also write: ...
Rákosi Norbert's user avatar
6 votes
Accepted

Sending a file over a socket with AES encryption

try-with-resources ...
mdfst13's user avatar
  • 21.7k
6 votes

Custom output stream that acts like std::cout

Construction The construction of a MyStream object will proceed like this: Construct std::ostream part with pointer to not-yet-...
Alexei Khlebnikov's user avatar
6 votes

Counting relevant entries in a large bioinformatics file

Possible bug: ...
Imus's user avatar
  • 4,297
6 votes

Compare two map objects and show relative information Java 8

Code review in order of appearance: public static String getAllExecTimes(MasterVO masterVO, boolean displayAll) { Static methods should be avoided if you may ...
Maarten Bodewes's user avatar
6 votes

Chunking strings to binary output

I agree with you that this would be more intuitive to use by chaining streams, rather than acting as a queue that must be pushed into and pulled out of. I've never written a filtering stream like ...
Toby Speight's user avatar
  • 81.7k
6 votes
Accepted

ostream that counts and discards the characters written to it

Areas of concern Have I missed some important technical requirement when inheriting std::streambuf and std::ostream? This is ...
indi's user avatar
  • 13.7k
6 votes

To markup a C++ std::ostream and delegate formatting of markuped text

About your API To actually use your code, you have to write quite a few lines of code just to get one line printed. Consider your main() function: ...
G. Sliepen's user avatar
  • 61.7k
6 votes
Accepted

Java: Benchmark findFirst() and findAny() methods on non-parallel streams

whether the benchmark has been implemented correctly I'm afraid, no. JVM does quite a bit of optimizations at runtime, compiling certain frequently called methods into highly optimized native code. ...
Alexander Ivanchenko's user avatar
6 votes

Search values by priority in a Stream

There is absolutely no point in using streams for this or integers to represent the values. Don't complicate your life with streams just because you think they're cool. Streams are a hammer that make ...
TorbenPutkonen's user avatar
6 votes

Very simple CSV-parser in Java

conservative design Since this is billed as "a CSV parser", a caller may reasonably believe they could send it any *.csv file produced by Excel. Better to ...
J_H's user avatar
  • 34.8k
5 votes
Accepted

Creating a pipeline operator in Java

This starts getting messy quickly, preventing authors from writing readable one-line expressions. Based on this statement, I don't get, how you want to use your code. You definitely don't want to ...
mheinzerling's user avatar
  • 2,724
5 votes
Accepted

Intersection of a Stream of Collections

Using built-ins You can use built-in comparators instead of creating your own. For example ...
Tunaki's user avatar
  • 9,273
5 votes
Accepted

Nisse Server: Part 3 Stream Layer (attempt 2)

SocketStreamBuffer is really an input-streambuffer and an output-streambuffer which use the same members in a mutually incompatible way. It works if any instance is ...
Deduplicator's user avatar
  • 19.3k
5 votes
Accepted

C++ Range based stream

I don't like the name - it ought to be more explicit that it's an input-only range. Otherwise, it looks just as a range should, with the observation that we omit the usual const iterators, as they ...
Toby Speight's user avatar
  • 81.7k
5 votes

C++ Range based stream

First of all, I would change the name to istream_range: template<typename ValueType> class istream_range This will make ...
Incomputable's user avatar
  • 9,589
5 votes
Accepted

Using QXmlStreamReader to read configuration file of key-value pairs

Case for not using a class It's not clear to me whether you need a class for what you are doing. Unless you need to be able to construct an instance of ...
R Sahu's user avatar
  • 3,512
5 votes

Stopping an infinite stream with collection state

Unit tests Let's talk about your test assertions first. Your test claims: ...
rolfl's user avatar
  • 97.5k
5 votes

Sequencing Collector for Either

You are horrified by "the type of that thing" because you are using stream operations for something they were not meant for. The purpose of streams is to perform pre-defined operations on an arbitrary ...
Stingy's user avatar
  • 2,138
5 votes

File encryption with password

Style private const int _saltSizeBytes = 32; private const int _IVSizeBytes = 16; private const int _PBKDF2Iterations = 10000; Initially, I wanted to comment that ...
Flater's user avatar
  • 5,542
5 votes

File encryption with password

var AesManaged aesManaged = new AesManaged() You can make you code less verbose by using var instead of explicit type ...
t3chb0t's user avatar
  • 44.3k
5 votes

Templated byte streaming

Well, there are a few points: You make a copy of the object you output. That can be costly, impossible, or have undesirable side-effects. Use a constant reference instead. There are essentially two ...
Deduplicator's user avatar
  • 19.3k

Only top scored, non community-wiki answers of a minimum length are eligible