The Adrian's Profile User Rating: -----

Reputation: 16 Tradesman
Group:
Members
Active Posts:
47 (0.05 per day)
Joined:
09-January 12
Profile Views:
984
Last Active:
User is offline Jan 13 2014 03:46 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   The Adrian has not set their status

Posts I've Made

  1. In Topic: Pointers.

    Posted 13 Jan 2014

    I wouldn't mind this thread being closed since it is no longer on the topic of pointers.
  2. In Topic: if vs switch

    Posted 6 Jan 2014

    Oh I didn't mean to make it sound like switches would make a huge impact. For sequential cases, switch will use a jump table, and for scattered values it will use a binary search. It is definitely a micro optimization if you consider it one at all.

    Even the article that I linked had no definitive answer, but the idea that I got from it was that if the switch was implemented one way, it could reduce the number of checks to determine which case to run or if a case exists. With a binary tree approach, it could reduce the number of checks. My thought was at a lower level there would be less chances for the branch predictor to be wrong.

    But again, small optimizations. And if you're in a situation where you have that much branching to the point performance becomes an issue I think there would be bigger problems you have to deal with.

    So Baavgai, I agree with you!
  3. In Topic: Pointers.

    Posted 6 Jan 2014

    View PostNight Stalker, on 06 January 2014 - 05:40 PM, said:

    View Postodougs, on 06 January 2014 - 05:21 PM, said:

    You might be thinking: "OK, but instead of making swap a function with pointers, I could just copy + paste the function body from example 1 into whatever scope I need to use it in!". And you would be correct. But if you are dealing with long, complex operations, or large amounts of data, it is incredibly important to be able to separate that code into a function and simply pass a pointer to the data structure you want the function to work on.



    No, actually I was thinking... How in the hell can I use this in a text adventure program... getting/dropping items... moving about the world I create, and so on... but ^^/>^ was a good guess. :)/>


    I think a good place to start when dealing with pointers is like suggested above, use it to modify data by reference. Another good place is to research containers. I would say read about pointers, try to understand them as best you can and then go ahead and take a shot at linked lists. Linked lists are simple data structures that will help you better understand what pointers are and how to use them. And then with that understanding, you'll be ready to tackle other containers, search and sort algorithms, and eventually memory managers.

    The journey of learning about linked lists should take you to the stack & heap, and while you're at it you should look into dynamically allocated arrays. That should all help when it comes to pointers.
  4. In Topic: if vs switch

    Posted 6 Jan 2014

    View PostNight Stalker, on 06 January 2014 - 02:30 PM, said:

    View PostThe Adrian, on 06 January 2014 - 11:57 AM, said:

    Here's a good read.


    Well, at my level of knowledge in C++

    mov    eax, DWORD PTR _i$[ebp]
        mov    DWORD PTR tv64[ebp], eax
        cmp    DWORD PTR tv64[ebp], 100        ; 00000064H
        jg     SHORT $LN16@main5
        cmp    DWORD PTR tv64[ebp], 100        ; 00000064H
        je     $LN7@main5
        mov    ecx, DWORD PTR tv64[ebp]
        sub    ecx, 3
        mov    DWORD PTR tv64[ebp], ecx
        cmp    DWORD PTR tv64[ebp], 4
        ja     $LN1@main5
        mov    edx, DWORD PTR tv64[ebp]
        jmp    DWORD PTR $LN18@main5[edx*4]
    

    Is like rocket science. Thanks for loosing me in the techno quantum of who is the nerdiest. You win! :)/>/>
    That means absolutely nothing to me.


    So what I got out of all this was basically, apples to apples they accomplish the same thing. It's a matter of taste as to which one reads better. Much like

    if (a==1 || a==2 || a==3 || a==4  ||a==5){
    ..
    }
    

    can be cleaned up to something like

    if (a>0 && a<6){
    ..
    }
    


    I think I have to agree with Baavagi.


    Believe me haha, assembly isn't something I enjoy reading either. I think it's something to at the very least be aware of.

    But I do kind of disagree with the conclusion you've come to. It doesn't all mean the same thing. There is a reason why switch exists. If used properly, it can give you a performance boost, maybe not by much but still something. There is also the neat thing that switches have which is fall through as vivid gave an example of.

    If you don't see it as a big deal, chances are it probably isn't. It could just end up be a preference thing. But at least now you have a better idea of how it works under the hood.
  5. In Topic: Do Sockets are worth attention here?

    Posted 6 Jan 2014

    A socket is a binding of an IP address and a port that you use to send and receive data from. If you wanted to do networking, you will need to use sockets. There are other options like writing/reading directly to the wire, but don't do this. If you're in Java, you'll need to use Socket and ServerSocket. (And by need I mean you definitely should, there are of course other options but I won't go into them)

    There are a lot of things that you can do with the game you've proposed. You can use databases where you post and read to tables in the database, or you can actually use a client-server approach which is definitely the best choice starting out.

    Good luck!

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Programming Languages:
C, C++, Java, C#, Flash

Contact Information

E-mail:
Private

Friends

Comments

The Adrian has no profile comments yet. Why not say hello?