Hej everybody.
I am writing a lot of code in JavaScript, and my code begins too look
to complicated... My work would be more effective is i could somehow
emulate Sets, Lists and Maps especially some of its operations.
Set - A collection that contains no duplicate elements (and its
elements may be everything: strings, function references, DOM element
references etc.);
List - An ordered collection (also known as a sequence) (and again
its elements may be everything: strings, function references, DOM
element references etc.);
Map - An object that maps keys to values. A map cannot contain
duplicate keys; each key can map to at most one value;
Can anyone point me to relevant URL's ? I know it is a lot to ask at
one post, but any clues would help.
B.R.
Luke Matuszewski. 1 11134
Luke Matuszewski wrote: I am writing a lot of code in JavaScript, and my code begins too look to complicated... My work would be more effective is i could somehow emulate Sets, Lists and Maps especially some of its operations.
Set - A collection that contains no duplicate elements (and its elements may be everything: strings, function references, DOM element references etc.);
You are looking for any native ECMAScript object or a user-defined object
derived from it. You will need a setter, maybe using a hash function
applied on elements to be added to compute the respective property name,
to make sure no duplicate can be created within the data structure.
List - An ordered collection (also known as a sequence) (and again its elements may be everything: strings, function references, DOM element references etc.);
You are looking for Array objects, or any native ECMAScript object or a
user-defined object derived from it that refers to Array objects with
one of its properties. You will have to define a getter that considers
elements with a special value (for example `undefined') as an indicator
that the next/previous "list element" should be accessed instead.
Map - An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value;
You are looking for any native ECMAScript object, or a user-defined object
derived from it.
In all cases, unless said otherwise, I recommend to use Object objects as
prototype, because they provide the least number of built-in properties,
which minimizes the risk of a property name collision and the size of the
memory footprint of the user-defined object.
<URL:http://pointedears.de/scripts/collection.js> maybe helps you to
implement this.
PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Atley |
last post by:
I am trying to set up a nested collection so I can run statements like this:
me.lblquestions.text = mysteps.item(1).questions(1).Asked
Any ideas on how to do this? I have created a...
|
by: Bmack500 |
last post by:
I'm definitely doing something wrong here. I have a class called
Servers, implemented as below. I then create my collection as below.
Then, I'll add a server object to the collection as follows:
...
|
by: nicolas.hilaire |
last post by:
Hi all,
i'm doing a quite long treatment in a function, and i'm showing the
progress of the treatment with a progressbar. The code is something
like this :
for each(entry in entries) // about...
|
by: Arthur Dent |
last post by:
How do you sort a generic collection derived from
System.Collections.ObjectModel.Collection?
Thanks in advance,
- Arthur Dent
|
by: Lucian Wischik |
last post by:
Does ReadOnlyCollection<T> really implement IList<T>, like it claims
to do? ...
When I right-click on ReadOnlyCollection and look at its definition,
it says this:
public class...
|
by: junw2000 |
last post by:
When should I use each of these three containers? What is the
difference?
For list and vector, it is obvious. How about set and map?
Thanks a lot.
|
by: PenguinPig |
last post by:
Dear Experts,
Could you please provide you comment to me? Thanks
An Exhibition has many Halls, and different Booth Types
If exhibition is not exist, hall and booth type will not exist too.
...
|
by: Godspeed |
last post by:
I have started writing a new collections library based on set theory as per
Spivey's Z notation. I have put the library on SourceForge. It is currently
in its infancy and it will be expanded fairly...
|
by: Tony Johansson |
last post by:
Hello!
Below I have a working program.
I have one generic class called Farm<T>
with this header definition public class Farm<T: IEnumerable<Twhere T :
Animal
Now to my question I changed the...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| | |