A stream is a series of data elements (characters, bytes or complex packets) which can be accessed or made accessible in a serial fashion. Random access is not possible.
2
votes
1answer
34 views
Building and querying an immutable phone book
I wanted to get your opinion on this immutable implementation of a Phone Book using recursion to process a stream. I am especially interested in ways to speed up the code execution.
Here is an ...
1
vote
1answer
52 views
Streaming learning OCaml
I wrote a simple online logistic regression, calibrated using gradient descent to compare the speed of an OCaml implementation vs the same Python script, executed with Pypy. It turned out that the ...
7
votes
1answer
139 views
Array view adaptor class for static polymorphism over network header parsing
Some context: I have some existing code to populate network header structs from istreams. A motivating excerpt:
...
6
votes
1answer
102 views
Tomorrow: rainy with a chance of null objects
In an attempt to hide from the sun outside, I gave the community challenge "Rainfall" a try.
Code here, specific questions below.
...
4
votes
1answer
52 views
Memory streambuf and stream
There are a plethora of streams and streambuffers available today, none are as fast as a memory streambuf, that you can use for testing. Shoot away!
...
0
votes
0answers
35 views
Finding vowels, digits, whitespaces and consonants
i am creating a simple app to find vowels, digits, whitespaces and consonants. the basic idea is to practice multi-threading and writing readable code.
So here is the code:
...
1
vote
0answers
16 views
Node.js stream of objects from MongoDB
I have a collection inside MongoDB with thousands of documents. A document should be processing depending on some logic. To make the point simple, I suppose here there is a field ...
3
votes
0answers
46 views
Facet for simple math expressions
I've built simple math expression facet which ignores any character except numbers and operators listed below:
plus, minus, multiply, divide, degree, left bracket, right bracket, assignment
I'm ...
4
votes
1answer
79 views
Replace EOL in stream
I need to replace the windows EOL "\r\n" with just "\n", and I want to this in the fastest way possible, as the software will have a lot of files to upload, many of them with a few thousands lines. ...
3
votes
4answers
81 views
Unit testing for concatenating two int arrays
Using Java 1.8, I created the following implementation to concat two int arrays:
...
3
votes
2answers
45 views
(Follow Up) Armstrong numbers in a given range using Java 8
Previous Question: Armstrong numbers in a given range using Java 8
Updated program for getting all Armstrong Numbers between 1 and ...
4
votes
1answer
65 views
Armstrong numbers in a given range using Java 8
Was fiddling with java-8; trying to write a program for getting all Armstrong Numbers between 1 and 10_000_000.
Following is my ...
5
votes
2answers
131 views
Packing and unpacking bits (2)
Part 1 here.
I improved my code from my previous question (linked above).
...
2
votes
1answer
47 views
Output stream-based pseudorandom number generator
I finished an output stream-based pseudorandom number generator, that works based on the current time and output data.
Here is the header's code (entrostream.hpp):
...
6
votes
2answers
153 views
Packing and unpacking bits
Part 2 here.
I wrote this class for packing data.
Would it benefit from being named BitPacker rather than BitStream (and change write/read to pack/unpack), or it works as is?
How can I improve it? ...
3
votes
2answers
46 views
Optimized Int Reader
I am new in Golang, and decided to create a function that could cater to my needs of reading an integer from stdin. I need the function to be as efficient and fast ...
4
votes
4answers
167 views
Implemenation for concurrent file access (read/write)
I am developing an application that works with files and folder on a network share (similar to the windows explorer). The application is used by multiple users and provides some commands for modifying ...
5
votes
2answers
48 views
Search files from large directory and sub-directories
Essentially I have a large directory with many sub-folders and different formats of files. It reads through XML, JAVA, .txt, etc, in search of a selected String inputted by the user. The results ...
4
votes
2answers
88 views
On-line evaluation of mean and variance in C#
In various projects, I have to evaluate the mean and/or the variance of relatively large samples.
I wrote the following, to help me evaluate these quantities with a constant footprint. Basically, it ...
1
vote
0answers
31 views
Customized streambuffer for C++ istream
Basically I implement a traditional file-descriptor-based streambuffer for istream operations. The implementation overrides the ...
3
votes
1answer
61 views
Efficient File Searching
During an interview I was asked to consider the following:
You are trying to find an instance of an error code within a number of log files within a directory. The goal is to count the number of ...
3
votes
1answer
61 views
“Multiplying” 2 lists of Strings together in Java 8
The following method is part of a class that imports zip archives, and part of that class's job is to verify that a given zip archive contains "complete filesets". A "complete fileset" is one such ...
7
votes
3answers
2k views
Printing alternating characters of a string using Java 8 streams
Given a string, S, of length N that is indexed from 0 to N−1, I want to print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line:
Hacker -> Hce akr
My code ...
3
votes
2answers
314 views
Determining the largest sum of contiguous integers in a list
I'm curious how I can improve the readability of this short program I wrote. Mainly, if and how there is a way to remove the for loops and maybe refactor the ...
5
votes
0answers
43 views
Creating an istream peeker
I want an istream that you can safely peek arbitrarily many characters from. This works as far as I can tell, but I am unsure if this is really "the right way" to ...
1
vote
2answers
70 views
Silly redis implementation
This is a silly Redis implementation that handles only three commands: INFO, ECHO, PING.
The implementation is based on streams:
...
1
vote
1answer
117 views
Copy a stream to a file using Universal .NET
I have answered to a question on Stackoverflow where Andy struggled to cancel a Stream copy to file operation using the Universal .NET Framework:
Apparently, cancelling the cts CancelOperation token ...
1
vote
2answers
437 views
Are there mistakes in reading file?
I've recently made a test. There were four tasks. One of them was to improve following code:
...
5
votes
2answers
378 views
Java 8 Stream to produce all permutations of an array using recursion
I want to write a class that returns a Stream of permutations of an int[].
...
2
votes
1answer
744 views
Printing longest sequence of zeroes
I am doing a coding exercise in codility and I came across this question:
A binary gap within a positive integer N is any maximal sequence of
consecutive zeros that is surrounded by ones at both ...
3
votes
1answer
64 views
Delayed output stream “manipulator”
I was just playing around with some code and had the idea about writing some kind of ostream manipulator to delay the output of characters in a typewriter like ...
3
votes
2answers
446 views
C getline() implementation
I'm practicing my C coding and I wanted to implement my own version of the getline function in C for learning purposes. I'd like a review on coding style, ...
5
votes
2answers
87 views
Reading input from stdin
I read user input from stdin in plain C.
The problem is that I want a sane implementation that is robust to errors and ...
4
votes
0answers
126 views
Streaming Json Serialization Using C++
I've written a C++ library for serializing objects to a stream as Json with the following goals in mind:
Minimal run-time overhead (write the contents of an existing object/array to the stream ...
4
votes
2answers
154 views
Closing InputStream of a running process
Let's say you want to extract the output of a console application till you've found a certain keyword. If you have found the keyword the started console process still should be running, however the ...
2
votes
2answers
130 views
Xml messages processing networkstream [closed]
I'm currently processing xml messages with C#. It is working But I'm not confident that my code is fast enough. There are 3 possible messages I can receive. When I receive one the message an event is ...
1
vote
1answer
316 views
ISO8583 encoding data fields
I just want to confirm that my ISO8583 format is correct.
Example:
For the data field 35, the length of the data is 36, so I put 36 before the 4842. Then all the data is inserted in a string (...
4
votes
1answer
91 views
Clojure word count
I'm fairly new to Clojure and looking to improve my use of the proper idioms, and make my code more readable. Here's the problem:
Read from standard input and produce the count of each word to ...
5
votes
2answers
599 views
Counting words from standard input in Swift
I know Swift isn't exactly meant to be used to write your classic stdin to stdout scripts, and that Python, Ruby, Perl, bash, awk, and friends are much better in this area, but I'd still like to see ...
2
votes
1answer
213 views
Prepend data to stream in C#
I'm working on an XNA project that loads several resources that are packed into a single file. XNA can take a WAV file stream and turn that into a SoundEffect (seen below in "case ".wav"").
Since ...
6
votes
1answer
463 views
C++ console program
I have been learning C++ programming. What you see here is all that I know how to do at this point. I look forward to learning more and I know there are better ways to accomplish a task such as ...
4
votes
1answer
86 views
OutputStream class for use with subprocess.Popen
I've recently been writing an application which does a lot of work with the output of commands. To call the commands I've been using the subprocess module, and originally, was using ...
4
votes
2answers
91 views
ConsumingRouter to consume based on condition
Started as to make a stream splitter to split stream based on condition, but finally found that I did ConsumingRouter, to consume based on condition and while have to provide consumers before using ...
6
votes
1answer
443 views
Java InfiniteStream with Queue
I did InfiniteStream by implementing Stream and Consumer. You can initiate the stream then ...
6
votes
3answers
102 views
begin and end overloads for istream_iterator
I wrote this pretty straight forward begin and end overloads for istream_iterator.
Is this standards compliant? Any problems with usage?
...
8
votes
1answer
105 views
Stream manipulating indenter
I've always wanted to be able to steer stream indentation, so that I could write code like this:
...
12
votes
1answer
211 views
Mandelbrot Streams
A recent Mandelbrot question (Hi @EBrown) in C# inspired me to build my own using the Java 8 parallel streams to implement the parallelism that's useful for computing each pixel value.
The intention ...
6
votes
1answer
178 views
Reading bits from a stream from least to most significant
For a recent project I was in need of excessive bit manipulation. Specifically, I had to write to or read from a variable number of bits up from the least significant bit towards the most significant ...
5
votes
3answers
483 views
Duplicate words in a text
Here is a simplified implementation to obtain the duplicate words in a text using lambda expressions.
...
4
votes
1answer
175 views
White box input stream for creating test scenarios
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 ...