Hey there! Sign in to join this conversationNew here? Join for free
    • PS Helper
    • Thread Starter
    Offline

    0
    ReputationRep:
    PS Helper
    (Original post by secretmessages)
    Anyway, how do I store two attributes in the same array position? I would have to store the "ID", lets call it (a string), and the priority itself.
    You can't store a string in an array which is defined as int. I don't think this is possible storing 2 variables into the same memory location.

    What is this priority queue for? Must be another way round.
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    (Original post by spikeymike)
    You can't store a string in an array which is defined as int. I don't think this is possible storing 2 variables into the same memory location.

    What is this priority queue for? Must be another way round.
    Basically I have an object "c", of which there are multiple instances (I don't know the correct terminology, basically there are lots of them). They all have an ID, a date, some other information, and a number, "d". The smaller d is, the higher the priority of c. These objects can be added into the system at any time, so I need to implement something in which the object can be inserted into the priority queue in any place, at any time.

    Do you think I could store the whole object as an element, and then refer to attributes of that object when I'm doing stuff with the priority queue? I was thinking of using a binary heap (I think it's a binary tree type thing whereby a child element is always smaller than its parent).
    • PS Helper
    • Thread Starter
    Offline

    0
    ReputationRep:
    PS Helper
    (Original post by secretmessages)
    Basically I have an object "c", of which there are multiple instances (I don't know the correct terminology, basically there are lots of them). They all have an ID, a date, some other information, and a number, "d". The smaller d is, the higher the priority of c. These objects can be added into the system at any time, so I need to implement something in which the object can be inserted into the priority queue in any place, at any time.

    Do you think I could store the whole object as an element, and then refer to attributes of that object when I'm doing stuff with the priority queue? I was thinking of using a binary heap (I think it's a binary tree type thing whereby a child element is always smaller than its parent).
    Store everything in a database.

    If you program one, go for it but I certainly do not know how. Correct IIRC.
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    ,
    (Original post by spikeymike)
    Store everything in a database.

    If you program one, go for it but I certainly do not know how. Correct IIRC.


    Can I store objects in arrays though, like described?
    • PS Helper
    • Thread Starter
    Offline

    0
    ReputationRep:
    PS Helper
    (Original post by secretmessages)
    ,


    Can I store objects in arrays though, like described?
    Maybe? ArrayList?
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    (Original post by spikeymike)
    Maybe? ArrayList?
    "Page Not Found" :ahee:
    • PS Helper
    • Thread Starter
    Offline

    0
    ReputationRep:
    PS Helper
    (Original post by secretmessages)
    "Page Not Found" :ahee:
    FFFFFFFuuuuuuuuuu

    http://java.sun.com/j2se/1.4.2/docs/...ArrayList.html
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    (Original post by spikeymike)
    FFFFFFFuuuuuuuuuu

    http://java.sun.com/j2se/1.4.2/docs/...ArrayList.html
    :dontknow: I thought it was enabled by default. Search the control panel?

    "Page Not Found" :ahee: Are you feeling ok?
    • PS Helper
    • Thread Starter
    Offline

    0
    ReputationRep:
    PS Helper
    (Original post by secretmessages)
    :dontknow: I thought it was enabled by default. Search the control panel?

    "Page Not Found" :ahee: Are you feeling ok?
    **** sake.

    Just google ArrayList java. You don't seem to be able to post those links. :holmes:
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    (Original post by spikeymike)
    **** sake.

    Just google ArrayList java. You don't seem to be able to post those links. :holmes:
    :lol: :console:

    Why not? Put the link in noparse tags and I'll have a go.
    • PS Helper
    • Thread Starter
    Offline

    0
    ReputationRep:
    PS Helper
    (Original post by secretmessages)
    :lol: :console:

    Why not? Put the link in noparse tags and I'll have a go.
    Can you not Google? Are you feeling ok? :sexface:

    http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html

    http://java.sun.com/j2se/1.4.2/docs/...ArrayList.html

    Edit:
    The link changes itself. :lolwut: The proper link you can see when editing, but changes when saved.
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    (Original post by spikeymike)
    Can you not Google? Are you feeling ok? :sexface:

    http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html

    http://java.sun.com/j2se/1.4.2/docs/...ArrayList.html

    Edit:
    The link changes itself. :lolwut: The proper link you can see when editing, but changes when saved.
    I did Google :fyi: but none of my results' URLs ended in "standardList.html" so I thought it must be another page. However, that's another good point - why would the second half of the URL transform into something completely different? :holmes:

    Post in development & bugs, this is weird :lolwut:
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    Test:

    http://java.sun.com/j2se/1.4.2/docs/...ArrayList.html

    Yeah, not just you :erm:
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    Another test:

    http://java.sun.com/j2se/1.4.2/docs/...il/Vector.html

    Well Vector is fine :dontknow:
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    (Original post by spikeymike)
    Wierd URL issue
    Fail :facepalm2:
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    Final test:

    /java/util/ArrayList.html
    • PS Helper
    • Thread Starter
    Offline

    0
    ReputationRep:
    PS Helper
    Does ArrayList fit your needs? :holmes:
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    (Original post by spikeymike)
    Does ArrayList fit your needs? :holmes:
    Possibly. Depends if I can store both ID and value in there somewhere. Then the question is, is it optimal, or would something like a binary heap take less computational time? :beard:
    • PS Helper
    • Thread Starter
    Offline

    0
    ReputationRep:
    PS Helper
    (Original post by secretmessages)
    Possibly. Depends if I can store both ID and value in there somewhere. Then the question is, is it optimal, or would something like a binary heap take less computational time? :beard:
    Efficiency is not priority at the moment IMO. A working program would be a start.

    Going to bed soon.
    • PS Helper
    • Wiki Support Team
    Offline

    4
    PS Helper
    Wiki Support Team
    (Original post by spikeymike)
    Efficiency is not priority at the moment IMO. A working program would be a start.

    Going to bed soon.
    You speak the truth.

    I will sleep after I do this priority queue.. then campus tomorrow from midday.. Saturday.. :facepalm2:
 
 
 
TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Updated: October 26, 2011
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Has a teacher ever helped you cheat?
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Write a reply...
    Reply
    Hide
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.