« first day (497 days earlier)      last day (3512 days later) » 

12:00 AM
VBA is counting references
 
Shit.
 
lol something like this might help:
10
Q: Disposable Heroes

Mat's MugI had a bit of an issue with my last piece of code, having to do with cleaning up resources. I needed a way to ensure the database connection was always properly closed, even if there still were instances of an IPresenter or IRepository still floating around. IDisposable class module Option...

 
> RELOAD
3
 
I just did a doosie!
hehe.... what a twit
When you score rep-max for a day, don't award a bounty 1 minute before reload....
that helps you lose repmax in a hurry
 
LOL!!
(crying)
you mean don't start a bounty right
 
12:07 AM
Well, yeah
 
Ugh..... it's literally every other one.
 
0
Q: Why is the "recent answers" feature so well hidden?

retailcoderFor a long while, I've been wanting to find answers in the tags I'm interested in, because I like spending my votes. I've given up hoping for a chatroom-friendly answers RSS feed, so I ended up spending my votes on whatever I see that's interesting and good for the site. Recently I was looking ...

Welcome to CR! It seems you have misunderstood what this site is all about. Please take a look at our help center, we're all about reviewing your actual, working code - explaining what code does, or a language's syntax, is unfortunately off-topic here. Cheers! — Mat's Mug 50 secs ago
^^ close before @CaptainObvious posts here?
 
Hey 2nd Monitor :D
 
HEY @ALEXL
 
Long time no see @Phrancis!
 
12:21 AM
hi!
 
hi!
 
hi!
 
How are things going these days? hi! back!
 
Just fixing syntax errors writing code
 
12:22 AM
awesome guys, mission accomplished! off-topic closed in < 8 minutes!
 
Not too much has changed @Phrancis ;)
 
-2
Q: what's the meaning of "," in R?

user53008I am new to R. Please forgive me if you think this question is too simple. I saw one example like this lately. x <- factor ( c( "yes", "yes", "no", "yes", "no" ) ) attr (, "levels") I understand attr in R is used to find the attributes of an object. What does "," mean here ? Many thanks.

 
@CaptainObvious sooooooo late!
 
@AlexL Hi
 
hi!
 
12:26 AM
Better title for this?
0
Q: Living off of chocolate

syb0rgThis is the second project for my CS1 class, this time I'm actually getting it reviewed before I submit it ;) The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exercise. This is called your basal metabolic rate, or BMR. ...

 
no, it's awesome!
 
Living off of bad great titles
It's catchy, though not very informative.
 
well... I think it's bang on
 * @file calorie.cpp
 * @brief Determines the number of chocolate bars you need to eat in order to live
 
How about something like: Living off of chocolate (calculate BMR using C++) ?
 
3
Q: Living off of chocolate

syb0rgThis is the second project for my CS1 class, this time I'm actually getting it reviewed before I submit it ;) The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exercise. This is called your basal metabolic rate, or BMR. ...

 
12:31 AM
I predict a hot network question, and many many views.
 
^^^ I like that idea
 
woah, already Loki'd
 
@Jamal Take a look ^^^
 
Circular reference....
Breaking Assert into it's own class was a dumb-ass idea.
Thanks for the Disposable hint Mug.
 
@RubberDuck lol hadn't got to that ;)
np
 
12:34 AM
Damn that Loki answer didn't take long
 
@syb0rg Loki has said most of the things already. :-P
 
Oh, @LokiAstari is in the room...
@LokiAstari For the "Use a constant that has a name that makes this have meaning" - I would use constexpr, right?
 
lol
There is only one path open to you. This insult must be punished with swift and brutal justice. — Paul D. Waite yesterday
can't believe that question is still running hot
 
> Maybe she has the foresight to think of your co-workers batting at fruit flies all day tomorrow and took action. I'm just thinkin out loud here. Buy a container next time.
Such a stupid question; I'm debating whether OP did that intentionally.
Almost as silly as posting LOLCODE Surely this is a simple matter to solve.
2
 
was anything but simple, and I am almost a guru
 
12:49 AM
wasn't really hard.. is much worse..
 
0
A: Factory Class for Game World

nhgrifI think the factory class is completely unnecessary. I don't see how you're saving 200 lines out of a single file either. The way I see it, the code in DTTowerFactory.m comes from several different files (and probably needs to go back to those files). towerWithWorldSize:isFirstTower belongs ...

57
Q: What's the difference between mobile and desktop processors?

JamesDonnellyI just read about the new Samsung Galaxy Note Edge having a 2.7GHz quad-core processor and 3gb of Ram. The laptop I bought last year by HP is 4 Gb of ram and 2.3GHz quad-core and my iMac is even older and is 2.5GHz i5. My question is does this mean that the new Samsung gadget is more powerful...

 
1:09 AM
Nice @nhgrif
Come on Postgres, give me a break...
-- when I include this:
set search_path = PsychoProductions;
-- i get
ERROR:  unrecognized configuration parameter "search_patch"
CONTEXT:  SQL function "fcn_insert_person" statement 1

********** Error **********

ERROR: unrecognized configuration parameter "search_patch"
SQL state: 42704
Context: SQL function "fcn_insert_person" statement 1
--when I don't
ERROR:  function fcn_insert_person(unknown, unknown, unknown, unknown, unknown, unknown, boolean, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown) does not exist
LINE 2: select fcn_insert_person (
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

********** Error **********

ERROR: function fcn_insert_person(unknown, unknown, unknown, unknown, unknown, unknown, boolean, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown) does not exist
 
Is it fcn? And not fnc?
 
It is fcn everywhere...
I also checked to make sure the number of arguments match... expecting 16, passing 16... wtf.
Guess I better head to SO
 
1:26 AM
0
Q: Lua bindings for FTGL (FreeType font rendering in OpenGL)

DaggI wrote some Lua bindings for FTGL's C API. This works well enough, but I ended up with lots of macros, one for each Lua function signature. For example, LUD_NUMBER_NUMBER_TO_NUMBER creates a Lua function that takes a lightuserdata argument followed by two numeric arguments and returns a number. ...

 
0
Q: Postgres function creates but does not execute

PhrancisI've been trying many things to get this to work. I've followed the documentation, as far as I know, and this is just not working. Can any of you with experience in Postgres recommend a fix? I would be eternally grateful. I'm using Version 1.18.1 (jun 9 2014, rev: REL-1_18_1) My create code:...

 
A lot of pages could simply be eliminated, and all these navigation links could be greatly simplified, if super-ninja-searchâ„¢ was the way to browse SE sites... — retailcoder 2 mins ago
 
1:42 AM
@RubberDuck (copying your code)
 
@Mat'sMug Fair enough. I copy enough of yours.
I get down the road a little bit I'm going to put it on github.
Because all of a sudden, my VBEX code is in here too.....
 
This is the first time I see Friend being used (and warranted) in VBA!
 
Constructors.... I hacked together constructors.
 
And immutable types
the class is non-creatable from the client assembly workbook
so you have a factory method, and can expose getters without setters!
I never realized a VBA project could reference another!
seriously... that changes everything.
 
I know.
 
1:49 AM
@Phrancis it says path in one part and patch in another?
 
Just watch for the circular references...... lol
 
-- when I include this:
set search_path = PsychoProductions;
-- i get
ERROR:  unrecognized configuration parameter "search_patch"
 
@RubberDuck That's it, I'm turning that workbook into a f**** framework!
 
@Mat'sMug Race ya to it.
 
it's like, take 90% of the questions on CR, and put that in a workbook; reference and enjoy.
 
1:53 AM
Yup.
 
hmm wait, no.
 
What?
 
having the workbook referenced forces you to have it open.
 
Serioulsy?
 
yup.
but there's a cure.
 
1:54 AM
Care to share?
 
instead of a macro-enabled workbook (*.xlsm), you save an Excel Add-In (*.xlam).
2
 
Oh. Yeah. I have one of those for some custom functions.
 
2:08 AM
BTW I had this comment in my FractionType.Parse method:
'CR62709: are they numeric?
    Set Parse = Create(CInt(numeratorPart), CInt(denominatorPart))
^^ I found that bug after I posted
FractionType.Parse("abc/def") doesn't raise an error I had expected, basically.
should have closed as non-working code.
    If Not IsNumeric(numeratorPart) Or Not IsNumeric(denominatorPart) Then
        RaiseInvalidFormatError value, "Parse"
    End If
 
Boiler plate? No worries.
Public Function New_UnitTestModule(project As VBProject) As vbeCodeModule
    Set New_UnitTestModule = project.VBComponents.Add(vbext_ct_ClassModule).CodeModule
    '@todo insert template
End Function
 
2:29 AM
@syb0rg YEs
 
2:55 AM
@RubberDuck did you know this?
> In recent versions, however, VBA converts all integer values to type Long, even if they are declared as type Integer.
 
3:17 AM
^^^ really, I just had a steak and pasta dinner. I am on diet. How can I think life is tough?
 
I didn't @Mat. Link?
 
My Google fu is weak. Thank you.
 
That's OK, that's what moderators are for (for making snide swagger comments).
 
Hmmm so, there is absolutely no reason to ever use an integer in vba then. Okay. Bookmarking that.
Lol. What snide comments? =;)-
 
3:29 AM
2
A: What is the collective noun for a group of moderators?

rolflIf the purpose of your post is to seek out the right term for moderators, I think there are two contexts that are significant, and there should thus be two collective expressions: A Posse of moderators - people out to seek justice a Swagger of moderators - just because that's the way many non-m...

 
@rolfl exactly - thanks!
 
 
1 hour later…
4:52 AM
Just Saying Hi!
 
Hey Lucio
 
5:07 AM
@200_success that is one crazy story
 
Pringles, huh.
I figure the fact he was also an alcoholic had little to do with it ... ;-)
 
it just reads like somebody wrote it, rather than a true story
have you ever heard of someones internal organs "atrophy"ing
as if your organs need a regular work out.. lol
 
Hi Lucio. How may we help you?
 
5:52 AM
-1
Q: Growl notification does not display proper icon in MacOSX 10.9

varunI want to show notification in my project, so using growl framework (version-2.0) in MacOSX 10.9.4. I have set Icon.icns as App icon. I am Using below method to show notification. I want to show Icon with notification, So I am passing image(notification.png) in iconData parameter. + (void) not...

 
monking
Saturday is always the slowest day
 
6:36 AM
0
Q: Whats the best design that doesn't sacrifice efficiency

vmichaelI have the following method signature private void GroupByFieldType(SharePointMigrationContext migrationContext, List documentLibrary, out List<FieldInformation> fieldInformationList, out List<FieldInform...

 
7:06 AM
0
Q: Lazily Load CSS and JS

GrepI have written this piece of JS and CSS loading code and I would like some advice on it. Anything some of the Javascript Gurus could possibly point out would be much appreciated. The code works, but I have not done extensive testing, because I am concerned about replacing functions in this manner...

 
0
Q: Linking to users in my answers

janosI do this kind of thing all the time: In addition to moving these declarations closer to where you use them as @lokiastari said, the initializations are pointless because you overwrite them anyway. That is, when I mention a user, I don't just mention their (uhm, slightly mispelled) name, I ...

 
0
Q: Voxel World Frustum Culling

KrythicI just recently added frustum culling to my voxel game; it worked pretty well at first glance. However, I immediately noticed that the frustum seems to be a little off—being that some voxels near the edge of the window are prematurely cut-off, before completely falling out of visual scope. Here i...

 
 
2 hours later…
9:45 AM
Monking
 
10:10 AM
0
Q: Program for finding the longest common subsequence

user283779Here is the code that I wrote to print the LCS: #include <iostream> #include <string> #include <vector> void print_lcs( std::vector< std::vector<char> >& S, std::string& X, int i, int j) { if(i==0 || j==0) return; if( S[i][j] == 's') { print_lcs(S, X, i-...

 
10:29 AM
0
Q: input character and i will convert it, if the user input is lower case it will be convert into uppercase vise versa

user49111using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { char k; Console.SetCursorPosition(40, 12); Console.WriteLine(""); k = char.Pars...

 
@StackExchange Totally off-topic and horrible question
I have a feeling that Santa has missed this one:
0
A: Memory text based game

Simon André ForsbergBesides what Pimgd has pointed out, I have some more things to say: First of all, your code is a bit of a mess as the indentation is quite far off, and the spacing likewise. If you're using an IDE, which I hope that you are, use your IDE to automatically correct these things. Or look at Pimgd's ...

Monking btw
 
10:55 AM
0
Q: Push-pull pattern with nodejs and zmq

kharandziukI created the code below to illustrate push-pull pattern with zmq and to benchmark some concurrent job. 'use strict'; const cluster = require('cluster'), zmq = require('zmq'), assert = require('assert'), moment = require('moment'); var fib = function (n) { if (n === 0) return...

 
11:08 AM
@SimonAndréForsberg That was a repeat offense, too!
 
@200_success And someone even dared to answer on meta.CR
 
WTF?
Another one? From the person who answered?
 
11:23 AM
-1
Q: Improvement of my String interface

cellFirst of all, I should say I am new to CR, so, if this is not a question strictly related to the purposes of this site, instead of downvoting immediately, just tell me why it is not. I created a few months ago my String class to practice my programming skills, but now I would like to improve my ...

 
@Mat I know you use Excel, but lookie here. I can compile and distribute library code. vb123.com.au/toolbox/07_access/libraries.htm
 
0
Q: Spreading mysql query code over multiple lines - new lines vs concatenation

BrettJust wondering if there was any reason NOT to wrap a long query over multiple line via new lines vs using concatenation? For example, consider this: $this->query("SELECT u.*, COALESCE(c2.name,u.state) AS real_state, c.name AS real_country, bc.alpha3 AS country_iso, bs.code AS state_iso ...

 
@200_success I don't know exactly, but someone answered on that question you linked
 
12:29 PM
Made myself a banana split
not the most common breakfast but it's gooooood.
Sucks that the perceived chocolate is actually mocha though.
 
Monking @JeroenVannevel :)
 
morning!
 
0
Q: Best practise way to handle array of pairs

ShaktalI am trying to randomly select 4 items out of an array, each item has an index, a name and a price attached to it. Currently I have the following code segment to select 4 at random: function SelectItems() { $arrayItems = array( 1 => "Name of Item 1", 2 => "Name of Ite...

 
@JeroenVannevel that sounds even better in my book
 
That's how I would have made one ^^
 
12:48 PM
I am in love with angular, bower, and node.js.
 
I really don't know what either of those actually do...
 
angular is a javascript databinding framework
bower is a package management-esque thing for web resources
node.js is a javascript framework
 
Wow...
        reactor.on($(topic), new Consumer<Event<Message>>(){

            @Override
            public void accept(Event<Message> t) {
                System.out.println("Hello World");
            }

        });
This Java actually compiles?
 
@skiwi Sure it does, $ is a legal identifier in Java
 
> A variable's name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character "". The convention, however, is to always begin your variable names with a letter, not "$" or "".
 
1:00 PM
Looks more like abuse to me though ;)
 
it looks a hell of a lot like javascript don't you think? lol
 
And the parentheses make it even weirder
 
aside from the Event<Message> and @Override and public void..
 
just because it contains a $ sign doesn't make it JavaScript
 
I said it looks like javascript
 
1:01 PM
Wanting to use JavaScript in Java is like a bad sign to make
 
it's clearly the name of a method
 
1
Q: Compare values of elements in Stream

Matthias BraunI'm having fun with Java's Stream library and lambdas. The following code looks for persons within a list that have the same ID (which might indicate that something's wrong with the data) and prints out each group of people that share one ID. I'm not sure if I'm doing this the most concise way,...

 
1:39 PM
@bazola
+ (NSDictionary *)dictionaryOfDwarves {
    NSMutableDictionary *dwarves = [NSMutableDictionary dictionaryWithCapacity:90];
    for (int i = 0; i < 90; ++i) {
        dwarves[@(i+1)] = [[self alloc] init];
    }
    return [NSDictionary dictionaryWithDictionary:dwarves];
}
 
monking
 
@nhgrif you think that it makes sense to have that in the Dwarf class? I guess I just never thought of it
 
As an example method in DTDwarf.m
I've done similar before.
It could even just be a C-style function, but the class method is more than fine.
If anything, the class method indicates that this collection is a collection of objects of this class.
 
aye hello.
 
interesting
 
1:41 PM
I had some code one time that took a filepath has an argument and returned an array of objects. The filepath being a path to a CSV file to initialize the objects.
It certainly makes more sense to me than a whole separate factory class.
 
well I think the core problem was still that there was too much code in the Tower class
 
Being a method of the class you're producing a collection of gives you access to any and all of the other methods, constants, etc. that was available to the original init method of that class. And moreover... since we now are creating via [[self alloc] init] rather than a specific class
[DTSubclassedDwarf dictionaryOfDwarves] would return a dictionary of subclass dwarves without writing a new method.
 
wondering if I can steal something from @200_success :
0
A: Spreading mysql query code over multiple lines - new lines vs concatenation

janosThe first way is less error-prone. When you write like this: "FROM " . MAIN_DB . ".users AS u " . "INNER JOIN " . MAIN_DB . ".countries AS c ON u.country=c.id " . ... it's easy to "forget" to add a trailing space on the previous line, which is necessary to separate the clauses of the statem...

 
thats a very good point @nhgrif
 
thanks Santa (though that was a tad bit too fast!)
 
1:46 PM
@bazola I assume that some of the code in the Tower class is code that can now be moved to the TowerFloor, or Animal, or Dwarf class now though, right?
 
0
Q: Calculating the ideal body weight

Oompa LoompaThe following question was taken from Absolute Java 5th ed. by Walter Savitch: A simple rule to estimate your ideal body weight is to allow 110 pounds for the first 5 feet of height and 5 pounds for each additional inch. Write a program with a variable for the height of a person in feet and a...

 
Moreover, if you're purely interested in reducing the number of lines per file, there are some other tricks that can be used to improve the lines per file without sacrificing organization. Perhaps even improving organization.
You can use either subclassing or class categories.
So the basic DTTower class just holds the very basic properties and the necessary initializations methods.
So then move your more complicated logic on the tower class down to a subclass or over to a class category.
 
@nhgrif well it is 1000 lines now, and I don't think it will be getting much bigger. I could of course subclass it (i will probably need subclasses for the later stages of the game) but I usually try to avoid inheritance unless it really really makes sense
but yes I need to move some more things to class methods in Floor, Animal and Dwarf
I appreciate the help, as always
 
I wouldn't worry too much about pure line length.
 
its not that I'm purely worried about length, moreso that once it gets that big it is harder for me to work with it
 
1:59 PM
I mean, Xcode can give you a very easy quick overview of all the methods, and let you jump to any of them.
I would worry about the length of individual methods. An individual method should always be completely visible on your monitor without scrolling.
 
yeah I try to follow that as much as possible
one question I do have is, when should I use C methods? (other than when I have to, or during initialization). Because it has occurred to me that I could pretty much use C methods all the time (although I know that is not a good idea, it is theoretically possible)
 
Not often really, but it depends.
 
Sorry @rolfl, I didn't know you were also writing an answer ;-)
I was delayed by something though and then format I was wanting to write an answer, so it was real luck that I still was in time
 
Most of the time we need objects. However, I just started working on some SQLite code in an iOS project. There's nothing object oriented about reading or writing to the SQLite database so far as I can tell. I have objects that I create based on what I read from the database, but actually reading from the database isn't OOP.
 
I saw your notification bar come up, so I quickly pressed submit ;-)
 
2:07 PM
So that's just a C-function that returns an array of objects.
 
@skiwi No need to apologise, because my answer is better ;-)
 
@rolfl Ouch... Yours didn't mention everything though!
 
0
Q: Speeding up Mersenne prime generator

ProgoI am writing a program to calculate Mersenne primes. Here is my code, it works, but it is so slow: import java.math.BigInteger; import java.util.Scanner; class calculate{ private static Scanner scanner; public static boolean MPtest(int x) { if (x < 2) throw new IllegalArgumentE...

 
@skiwi @rolfl I put one up too for that one ;-)
 
Just made an account to leave some comments on GameDev
32
Q: Why are character-classes used in game design?

Evgeni PetrovWe had a long discussion in my company about character-classes. We are building a skill based game where you will eventually need to select 8 to enter a battle. I am a fan of classless systems, I have always felt that they are created to extend your gameplay hours in a fake way. We reached a few...

 
2:20 PM
@janos It still gets stored, you cannot magically iterate over it in memory... The only difference is that you do not assign it to a variable
 
@skiwi that's kinda my point: he cannot get around it, he has to store it
 
@PaulElfish Though it would be rather humiliating to be checkmated by a litter-tray... — David Richerby yesterday
 
I'm a bit sad to shoot your suggestions down @janos, but I don't think parallelizing will help here if you use it to put it to`System.out`, because I think(?) it uses a synchronized buffer internally
 
0
Q: Find out max duplicate number between 1 to N numbers

kyleThis is my sample programme int[] _input = new int[] { 5,45,184,594,14,8,5,184,1841,184,594,5,78,594,14,8,18,4,18,14,8,594}; Dictionary<int, int> _inputDictionary = new Dictionary<int, int>(); foreach (int i in _input) { if (_inputDictionary.Contains...

0
Q: C program to implement & measure the relative performance of certain sorting algorithms

topcoder_7Generate random numbers for Bubble sort, Insertion Sort, Selection Sort, Merge Sort & Quick Sort. We have to execute all 5 sorting algorithms & generate a text file(.txt) which will contain the number of comparisons made in each algorithm. Finally we have to plot a graph - A particular set of num...

 
@skiwi is there a harm in trying?
 
2:22 PM
Not sure, I don't think it causes extra overhead
You are fully correct about your statement if you want to send it to some other place that can work with parallelized input
 
I think of it as a hint, that this can be parellelized, and I'd let Java do what it can with it
 
You've got to be careful there though, parallelization in itself is already harmful in essence, it only starts to have benefits once you can gain more than the harm that's being done
 
Note that because println is fully synchronized, it is safe, but you rely on that for your answer.
 
You need to create an extra thread for example already
 
did you know that println is threadsafe?
 
2:27 PM
I didn't know
 
ok, so it's completely pointless then
 
And, if it wasn't your code would completely mess up the output.... if there was more than one match
 
fixin it now...
 
@rolfl Shouldn't it be using a private Object lock there? Now everyone can lock any PrintStream instance if he wanted to do so
 
2:29 PM
This question has a lot of answers that all fail the Skyrim test: gamedev.stackexchange.com/questions/83251/…
 
is there a lag now?
 
Not that I am aware of
 
No, just nobody has said anything
 
the gamedev SE link took ages to load
 
@skiwi It should possibly be a private lock, but, it has advantages too by being locked at the outer level too.
You can lock on System.out, and then print multiple times, and be sure that no other thread will interject in your output.
 
2:39 PM
That's nice indeed
 
The documentation is shocking about that, though
 
3:06 PM
monking!
@RubberDuck I've rewritten your code my answer.
 
monking @Mat'sMug
 
I have to go "fix" one of my friends' router. He changed the encryption mode (and password), and can't access his router anymore.
 
Holy cow...
 
ouch!
woah, I'm top answerer on site! ...not fair, @svick (and the rest of the top users) is a much stronger programmer than I am. oh well, rep score != programming strength
2
 
0
Q: AngularJS factory, return object to be used again in factory

Paolo BernasconiI'm trying to create a wrapper / factory around the cordova media plugin, which requires you to create a new Media object, and then use it again to pause, stop, play, etc it. The factory + link to actual code: .factory('$cordovaMedia', ['$q', function ($q) { return { newMedia: function (src)...

 
3:16 PM
@Mat'sMug I've never seen physical strength being listed as a requirement for programmers outside of Russia yet
 
lol
programming uh, ... talent then ;)
 
;)
 
can't wait for @RubberDuck's feedback on my review.. that was pretty exciting VBA code to review. As exciting as VBA gets :)
 
There's no accounting for taste:... ;-)
Thank you very much. I think your code looks the most concise right now :-) — Matthias Braun 18 mins ago
 
I do like my answer best too
 
3:25 PM
I just believe the opening statement is wrong...... and I can't bring myself to +1 it ...
 
how is it wrong?
 
> There cannot be a simpler solution:
Your solution includes a list, a map, a set, and 2 streams.
My suggestion contains just the list, map, and 1 stream
 
It is being quite a high profile question (votes on question/answer) for a 27 views question actually
 
Actually, your's contains 3 streams, mine contains 2.
Additionally, your solution requires an intermediate nexus point, where the entire stream gets dammed-up in the Set, before the set is then released through the next stream. so the latency in your solution before the first result will always be worse than mine, and the overall elapsed time is probably worse too.
 
I meant the statement about simpler solution at the conceptual level, not the implementation: that it cannot be more streamlined, the intermediary map is necessary, which seems the ugliest point about to me
 
3:31 PM
the map is necessary, but the set is not.
 
@rolfl Doesn't a Map internally store it as a set already?
 
No. it does not.
 
Or is that an assumption you shouldn't make even if you could
 
A set stores its data as a Map
 
Ah yes, I remember that trick now
 
3:32 PM
Avtgually, I have been calling it a Set, but it is just a 'collection'.
the values() is a collection, the keySet() is a set.
I feel like I am being horribly argumentative, but.... well, maybe I am ;-)
Each of the options presented is more than adequate for the task at hand.
 
I lost the bad point about it
Now it needs to go through the stream API an extra time, which is not strictly neccessary
And as always, when working on a TCG, I can manage to break things:
{Card id 96 in zone {Zone Hand (6) owned by {Player 'Player2'}}}
    Action: {TargetAction Enchant on card {Card id 96 in zone {Zone Hand (6) owned by {Player 'Player2'}}}}
    enchHealth: 1
    enchStrength: 0
    scrapCost: 1
    cardType: Enchantment
    manaCost: 0
An Enchant-Card should not be able to Enchant itself.
 
0
Q: Policy-based, variadic logger class in C++

ChrisI've been exploring design based around some of the more advanced C++11 features lately, and some of them are turning out to be rather useful for some projects I'm working on. One is this policy-based, variadic logger class that supports any combination of policies to determine where it logs outp...

 
@rolfl so you think I lose performance there because of the .values().stream() ?
 
@janos - I am also learning the streams API's, and I think that is why I was being pedantic about it.... because I was not sure about what was really right.
I want to learn the right things to do.
 
I'm learning too
 
3:39 PM
I do not think you lose performance measured in Big-Oh when you use Streams, you do lose some absolutely performance due to object allocation, etc.
 
By my understanding of the way streams works, yes, there's a perf hit every time you do that.
Each time you 'collect' data in a stream, you introduce a 'dam'..... and that backs up all calculations in the stream until all the data is colelcted.
 
@Mat'sMug would it be possible to measure programming talent in another way, using SE?
 
but you collect too
 
@rolfl Care to clarify?
 
Yes, but you collect twice.
 
3:40 PM
and btw my first statement is about the necessity of a collect
 
Give me 2 minutes to put together the logical constructs of what you are doing in a different format....
bbiab
 
where's my second collect?
 
@rolfl I don't see two collectors though
 
@rolfl Avtgually? Of all the typos I've ever seen you write...
3
@skiwi That does not say what you think it does.... it doesn't specify the target there, it just specifies the owner of the action...
 
@rolfl btw if you convince me that your solution is more efficient, I'll recommend him to accept yours instead
and while @rolfl is away, I think I found an answer on another question that beats mine hands down and needs attention:
2
A: Leaving out the max value in an Enumeration

Dan LyonsActually, most of the leg work is done for us in the framework. Enum.GetValues returns the list sorted ascending already, via the underlying implementation of Type.GetEnumData. With that in mind, you can use LINQ for the rest, retrieving all but the last value: static void Opdracht3() { va...

can some C# wizzes have a look?
 
3:45 PM
@rolfl I only see one collect in @janos' code.
 
Obtaining a stream is (unless you have a flawed custom implementation) just a O(1) operation
 
obtaining, yes. collecting, no.
 
Great, I just spent 30 minutes on solving a bug that was not there
 
Hmmm, your implementation is successful because of the implementation details of the HashMap (which is not necessarily the implementation used by the Map in the collection:
The values() call returns a light-weight collection that does not acually collect until called.
 
yup
 
3:56 PM
and the stream of that collection will defer to the iterator of the values, not on a hydrated collection.
where is my x key.
 
@skiwi That's better than spending 30 minutes on creating a bug that was not there before
 
come on, will you rub my back already with an upvote or what :p
 
@sim no idea. Is it even measurable?
 
So, your implementation makes assumptions on how the Map is implemented that is used for the collection... and those assumptions are not necessarily right.
 
how important is an upvote on a weekend day?
 
3:58 PM
don't we all make reasonable assumptions all the time?
 
@rolfl What exactly do you mean there again?
 
I assume that .values() won't collect
 
The obtained Collection<E> has a method called called stream() which returns a Stream<E>, which must be lazy in collecting
 

« first day (497 days earlier)      last day (3512 days later) »