Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by newbrand · Jun 09, 2010 at 06:57 AM · javascriptmonohashtable

Is there an unsorted hashtable-like container?

Hello everybody,

I'm currently using a hashtable, but that doesn't fit my needs. Is there a similiar container with KeyValue pairs that does not sort it's items in any way but keeps them in the order I added them? I don't want to write a custom type unless it's neccessary because I'd also have to rewrite a lot of code. Also I can not alter the Keys to enforce a specific order. The container should be useable in javascript.

Thanks in advance.

Edit: Since I can not leave comments, I'll abuse the edit function, please forgive me :~)

@Mike: Well, that doesn't look too promising. I guess I'll have to implement my own container. Thank you for your help!

@Ricardo: Thanks for pointing that out. I was under the impression that only non-generic types work in js.

@Sejster: Enums are constant data types, but I need to alter the values. Also I can't iterate over them.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ricardo · Jun 09, 2010 at 11:22 AM 0
Share

Any .Net class library you get will be usable in UnityScript, as that ends up compiled to the same runtime.

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Mike 3 · Jun 09, 2010 at 09:13 AM

It may be possible that ListDictionary does what you want, though it specifically says that the order is not guaranteed over different versions of .NET, so it's possible the implementation will change

http://msdn.microsoft.com/en-us/library/system.collections.specialized.listdictionary.aspx

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Sejster · Jun 09, 2010 at 03:54 PM

If your values are integers and you don't add values at runtime, then you could just do a C++-like enum in JavaScript:

var yourEnum = {"monday":1, "tuesday":2, "wednesday":3, ...}
Debug.Log("Value of monday: " + yourEnum.monday);

It's not typesafe like a C++ enum, and its restricted to string-integer pairs, but maybe that's sufficient for your needs.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Publically readable hashtables 1 Answer

JS objects in Unityscript || BCE0048: Type 'Object' does not support slicing. 0 Answers

Hashtable as object literal serialization toJSON 0 Answers

how to use matrice with unity 3D 1 Answer

how to debug a js in mono 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges