Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 24 25 [26] 27 28 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 888018 times)

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #375 on: January 10, 2012, 10:22:35 pm »

They are usually classes for a language.  Every language seems to do it a little different.

I dislike pythons implementation.  It doesn't seem to like it when I use arrays as keys.   :-\
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

kaenneth

  • Bay Watcher
  • Catching fish
    • View Profile
    • Terrible Web Site
Re: if self.isCoder(): post() #Programming Thread
« Reply #376 on: January 10, 2012, 10:23:30 pm »

So I guess my real question is, do hashmaps and dictionaries exist as defined things in themselves in a programming language?  Or is it just a recognized construction, like an Object or Linked List, that has to be inferred through your coding methodology?

Because I do feel like I have a use for these pointers, I just don't know how to implement them.

.net provides them in the System.Collections.Generic namespace, dunno about other platforms, but I would presume so.
And it would be a bad idea to try to implement them yourself (except as an exercise, in which case I recommend it) as *cough* they put a lot of work into the inbuilt versions.
Logged
Quote from: Karnewarrior
Jeeze. Any time I want to be sigged I may as well just post in this thread.
Quote from: Darvi
That is an application of trigonometry that never occurred to me.
Quote from: PTTG??
I'm getting cake.
Don't tell anyone that you can see their shadows. If they hear you telling anyone, if you let them know that you know of them, they will get you.

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #377 on: January 10, 2012, 10:27:08 pm »

http://msdn.microsoft.com/en-us/library/xfhwa508.aspx <- C# Dictionary, which is sort of a hashmap of its own but without the ability to return a null value.

http://stackoverflow.com/questions/1273139/c-sharp-java-hashmap-equivalent <- How to extend hashmap in a very useful way.

I've always seemed to run into problems with C#'s version of this thing.
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #378 on: January 10, 2012, 10:38:29 pm »

So I guess my real question is, do hashmaps and dictionaries exist as defined things in themselves in a programming language?  Or is it just a recognized construction, like an Object or Linked List, that has to be inferred through your coding methodology?

Because I do feel like I have a use for these pointers, I just don't know how to implement them.

...
Linked Lists are things... As are Hash maps!

This is an example of using a linked list as a thing.
Quote
            LinkedList<int> listOfInts = new LinkedList<int>();

            listOfInts.AddFirst(3);
            listOfInts.AddFirst(2);
            listOfInts.AddFirst(1);
            listOfInts.AddLast(4);
            listOfInts.AddLast(5);

            Console.WriteLine("Contents of list");
            foreach (int i in listOfInts)
            {
                Console.WriteLine(i);
            }

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #379 on: January 10, 2012, 10:45:57 pm »

Linked Lists are things... As are Hash maps!

This is an example of using a linked list as a thing.

Yet another reason for why I must need a book.  When I searched for such information, I got stuff like this, and remembered from my Java days that "Linked List" is just a name for when you make an Object such that it includes in its body of data a reference point for another instance, so your objects stack like Russian dolls.  I had no idea C# includes such stuff as standard classes.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #380 on: January 10, 2012, 10:55:56 pm »

I'm pretty sure they are a thing in Java too...
C# has Dictionarys, LinkedLists, ArrayLists, HashSets and I'm pretty sure there are DataTrees in there somewhere as well.



It also has a thing called a List. It's not abstract, and acts just like how you would expect a list to act... Not sure how it stores data though.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #381 on: January 10, 2012, 11:06:50 pm »

I'm pretty sure they are a thing in Java too...
C# has Dictionarys, LinkedLists, ArrayLists, HashSets and I'm pretty sure there are DataTrees in there somewhere as well.



It also has a thing called a List. It's not abstract, and acts just like how you would expect a list to act... Not sure how it stores data though.

I disappear for a day because of life and Aqizzar forgets what objects are...

In Java, LinkedList and all other datastructures are still objects.  How it stores data depends on what it is, but the important thing here is that LinkedList is a full-blown object.  List is actually an interface.  It doesn't store data.  Java interfaces are essentially a promise to implement methods with the included signatures.  You can't instantiate an instance of an interface, similar to how you can't instantiate an instance of an abstract class.  They also give you the ability to cast implementing objects to that interface.  Useful for storing in datastructures.  That theory is why you usually see me implementing ArrayList and LinkedList like this...both implement the List interface...
Code: [Select]
List<Object> l1 = new ArrayList<Object>();
List<Object> l2 = new LinkedList<Object>();
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #382 on: January 10, 2012, 11:07:41 pm »

You kids and your fancy containers. Back in my day, all we had were arrays and structs! We couldn't even overload operators to make our code simpler and easier to read! Then, C++ and the STL came along, and we burned it at the stake for witchcraft!

Funny how I'm saying this despite probably being the youngest (or close to it) that posts in this thread.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #383 on: January 10, 2012, 11:09:12 pm »

Quote
So I guess my real question is, do hashmaps and dictionaries exist as defined things in themselves in a programming language?  Or is it just a recognized construction, like an Object or Linked List, that has to be inferred through your coding methodology?
Pretty much everything that is a "recognized construction" exists in some language or other. While "objects" may just be methodologies in some languages, in others (many) like Ruby they are THE central component that holds everything together. (In fact, Ruby is pretty much composed of objects and messages and that's it)

Sure, at the assembly level these things don't exist, but higher level languages are all about turning these recognized constructions into core parts of their design pattern.

On another note, I've really fallen badly in love with closures and duck typing. I'm going to be an unhappy camper if I ever again have to spend the bulk of my time programming in a language that doesn't have them. :P
In the other hand I did some hex editing by hand the other day, and that was also enjoyable...
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #384 on: January 10, 2012, 11:10:39 pm »

Speaking of duck typing, does anyone have any clue how Boost worked their magic with boost::any?

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #385 on: January 10, 2012, 11:14:02 pm »

List is actually an interface.
C# man, you always forget C#.
List is a class in c#, not an interface, and it isn't even an abstract class. You can make an instance of it and everything...

The interface that c# uses would be ICollection, for example
Code: [Select]
            ICollection<int> myCollection = new List<int>();
            myCollection = new LinkedList<int>();
            myCollection = new int[5];

Aqizzar

  • Bay Watcher
  • There is no 'U'.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #386 on: January 10, 2012, 11:20:33 pm »

Once again, a lot of my confusion here comes from not knowing what exists in a particular language and what is just an academic term for a system that arises from your code.  It's kind of hard to talk about things like that, because in some languages, words like "object" or "list" or "construct" or "dictionary" are a tangible component with its own syntax, and in other languages they're not.

I really really need a dictionary.  Which is to say, a glossary of terms and descriptions for a language, not a list of data pointers.
Logged
And here is where my beef pops up like a looming awkward boner.
Please amplify your relaxed states.
Quote from: PTTG??
The ancients built these quote pyramids to forever store vast quantities of rage.

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #387 on: January 10, 2012, 11:25:07 pm »

Well, for ruby there's http://ruby-doc.org/
For C++ there is http://www.cplusplus.com/reference/

Though that doesn't include syntax level stuff like the ternary operator.

I imagine other languages have something similar.
« Last Edit: January 10, 2012, 11:30:58 pm by GlyphGryph »
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #388 on: January 10, 2012, 11:28:32 pm »

Has anybody yet pointed you to the .net library? It has pretty much everything.

Otherwise, I'm sure between us if you ever want to know something, you have 24 hour tec support.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #389 on: January 10, 2012, 11:31:12 pm »

List is actually an interface.
C# man, you always forget C#.
List is a class in c#, not an interface, and it isn't even an abstract class. You can make an instance of it and everything...

The interface that c# uses would be ICollection, for example
Code: [Select]
            ICollection<int> myCollection = new List<int>();
            myCollection = new LinkedList<int>();
            myCollection = new int[5];

Sorry, got confused since you were talking about two different languages in one post.

And yeah, Aqizzar, feel free to ask us anything.  I'm sure we know the answer to any question you will reasonably run into.
Logged
Pages: 1 ... 24 25 [26] 27 28 ... 796