Doin' the "Sequence Shuffle" (or not)

Here's a problem: Check out [javafx.util.Sequences API|http://java.sun.com/javafx/1/docs/api/javafx.util/javafx.util.Sequences.html] . It has some nifty functions like sort and shuffle. However, say you make a sequence of stuff with an id attribute: syntax may not be 100% correct but the idea is the same
var circles:Circles[] = for(i in [1...10]) Circle{
x: x + i
y: y + i
radius: 10 - i
id: "{i}"
}Because Sequences.shuffle only takes Objects not Circles, how can you type cast a Circle?
circles = Sequences.shuffle((Object)circles) // IDE identifies this as an errorLets sort something with a Comparator:
c:Comparator = MyCircleComparator{}
circles = Sequences.sort(circles, c);  // good luckI guess you could try to wrap up a Circle inside of a JComponent because this ain't happening either:
class MyCircleComparator implements Comparator<Circle>{
public int compare(Circle o1, Circle o2){
     return o1.getId().compareTo(o2.getId());
}Why would the JavaFX developers tease us like this? It's just cruel!
So here's the challenge.
Write a java.util.Comparator and pass it to Sequence.sort() function or a sequence of CustomNode objects by some custom attribute. There's 10 of my precocious Duke Stars in it for the best solution. Oooooooh.....Aaaaaaaaaah.
Edited by: bthayer on Jan 7, 2009 10:45 PM

Here is how it is done.
var circles : Circle[] = for(i in [1..10]) {
    Circle{
        id: "{i}"
println("--- shuffle ---");
circles = Sequences.shuffle(circles) as Circle[];
for ( c in circles ) { println("{c.id}"); }
println("--- sort with comparator ---");
class MyCircleComparator extends java.util.Comparator {
    override function compare(o1: Object, o2: Object) {
        var c1 = o1 as Circle;
        var c2 = o2 as Circle;
        c1.id.compareTo(c2.id);
    override function equals(other: Object) {
        other == this;
def c = MyCircleComparator{}
circles = Sequences.sort(circles, c) as Circle[];
for ( c in circles ) { println("{c.id}"); }

Similar Messages

  • The Sequence in Premiere not display the video channels

    I have this problema: The Sequence panel NOT display the video channels, only the audio cannel.  This occur in an old Project. When I start a new Project there is no problem, the sequence show all video and audio channels. How can I fix it ?  Muchas gracias por su cooperación!!

    Maybe try importing the old project into a new one, instead of just opening the old project.

  • The new shuffle is not user friendly

    I am so disappointed and frustrated with it.  I can't get my music and Podcasts to be in the device at the same time-and I have spent so much time trying different permutations of making this happen that I'm actually posting my displeasure!  I've been to 3 different computers even, with the same results.  The drag and drop feature of previous generation was great. There was no need to change that.  The instructions I can follow-but they are useless here.  I want my Podrunner music and my downloads in my device so that I can run to what I like-and it's not happening...  If my old one turns up (and I hope it does) I'm returning this thing to the store.  My daughter bought a new one too-and she also finds it a p.i.a................Apple people need to fix this........

    thank god you saved me. i was going to switch to another program. itunes was barely cutting it before but the new update messed me over when i had a party to go to tommorrow. tips woulda been down the drain. i hope apple wisens up and listens to customers rather then making blatent descisions about how things should function. apple has some of he worst customer support in my opinion. their communities are more help then the tech support. very sad when a company chases customers away. thanks again though!

  • IPod shuffle will not connect to car audio

    my 2015 Lexus audio system recognizes my iPod Nano's (6th &7th generation) without any problems via BT or USB; does the 4th gen iPod shuffle have the capability to play through my car's audio system with it's USB cable?

    Probably not, because the iPod shuffle does not have the "standard" iPod dock connector.  It uses the headphones jack as the connection point for data.  Also, the shuffle is designed to be a more limited device, in terms of its interaction capabilities.
    A better choice for connecting to a car audio system is an inexpensive USB flash drive.  You may already have one.  For example, this one barely sticks out of the USB port
    http://eshop.macsales.com/item/SanDisk/SDCZ33016G/
    and has many times the storage capacity of a shuffle.  You can load it with your favorite songs and just leave it connected in the car, instead of constantly connecting and disconnecting an iPod (which causes wear on the iPod).

  • Why does the new CVI adapter not put the contextCVI parameter?

    Hi,
    With good old 2.0 prototype you could not specify arguments and you always used the parameters tTestData and tTestError. Now, with the TS3.x the recommended prototype is the new one.
    If I specify the standard prototype it puts some arguments which the sequence context is not one of them.
    The question is why?
    1) Don't you always need it? Is there a way to get the context from within the CVI code? Isn't the idea of the context argument is to be able to get/set information from the TS variables?
    2) I read the manuals but didn't see exact instructions how to specify the context as an argument. Can anybody show me how to do it? Do I need to specify it by value or by reference?
    3) Isn't there a check box to include the context in the same fashion as it was in TS2.x?
    4) I specify the context parameter with every TS step. Is that the proper way? Can I modify the standard prototype so it will automatically be inserted along with the other argument?
    Thanks
    Rafi

    Hello Rafi -
    I think the Action steptype will always give you a seqContextCVI pointer, but I agree that the default templates for the other steps don't. Certainly you don't 'always' need it. Especially if all you're doing is talking to hardware, doing some calculation and returning a measurement value, but it's very nice to have for various chores in TestStand.
    I think in TS 3.0 rather expect you to specify it manually.It's not too hard to do once you see the trick. I looked at the Action step's default arguements before I saw how it was done, but here's the simple breakdown.
    (1) create new arguement, on the right-hand side of the screen name it whatever you like.
    (2) The category is 'Object, the Type is 'CVI ActiveX Automation Handle' and the Pass is 'By Value'.
    (3) on the left-hand side of the screen, assign it the value 'ThisContext' as usual, and you're all set.
    If you build your functions manually in CVI you'll just include the parameter "CAObjHandle seqContextCVI" and use it just like you used to.
    Other options might be... I know there's still a button on the Module tab of CVI steps to allow you to create a TS 2.0 style prototype with TestData and TestError...
    Or, Yes, you can also modify the default template that comes with TestStand, but the software will likely complain at you for changing the settings on a NI steptype. If you want to explore this route, you need to add your seqContextCVI parameter in two places. Once to the actual template file at (TestStand Root dir)\CodeTemplates\User\NumericLimitCVI, and once to the type definition of the step you want to change. For example, use the Type Palette to find the Numeric Limit type and right click on it to alter it's properties. The tab you'll want to investigate is 'Code Templates'and then the template for CVI.
    I hope this helps!
    Cheers,
    Elaine R.
    www.bloomy.com
    Cheers,
    Elaine R.
    www.bloomy.com

  • Shuffle does not play music!

    I bought a new ipod ahuffle for christmas and i installed it and everything but when i put songs in it in unplug it from the computer it just wont play. whats wrong is there a bug in the software?
    Help me please because i have a friend that has the same problem and i really want to fix mine.

    Hi,
    When the iPod shuffle is not connected to the
    computer, turn on the iPod shuffle and press the play
    / pause button, if the front status light show a
    steady green light or green and orange light restore
    the iPod shuffle with the iPod updater.
    http://docs.info.apple.com/article.html?artnum=300701
    Santo
    What do you do when the front status light flashes alternating green and yellow under the same circumstances?

  • How do I process user command line arguments inside of the Sequence Editor?

    Using TestStand 4.0, how would I go about storing "extra" command line arguments processed from the /runentrypoint command in the Sequence Editor specifically?

    djdewitt -
    TestStand 4.2 does not have this feature; however, we do have an internal issue (#163169) to track this request. You can actually get the commandline passed to the TestStand Sequence Editor using the below psuedo code in a sequence; however, currently the TestStand Sequence Editor displays a prompt when it does not recognize a custom token on the command-line and there is no way to suppress this.
    Locals.AppMgrRef = RunState.Engine.GetInternalOption(InternalOption_ApplicationManager);
    Locals.CommandsRef = Locals.AppMgrRef.CommandLineArguments;
    Locals.CountNum = Locals.CommandRef.Count;
    For i=0 to Locals.CountNum - 1
        Locals.CommandString = Locals.CommandRef.Item(i);
    End
    One suggestion is to use a batch file to write the commands to a dedicated text file and then launch the sequence editor. You can then use a sequence in the sequence editor to read from the file.
    Lastly, I just tried something and I do not necessarily recommend this, but I noticed that the Sequence Editor does not prompt when using the /goto token, so if I use the below command-line, it seems that no prompt appears, the goto command does nothing, and the psuedo code accesses the command-line tokens: 
    "C:\PathToApp\SeqEdit.exe" /goto "location tokens that do nothing" /run MainSequence "C:\PathToSequenceFile\GetCommandLineArgs.seq"
    Keep in mind that NI does not necessarily support this but it does seem to work for now.
    Scott Richardson
    National Instruments

  • Sequence File will not unlock for editing

    A password was set on a sequence file.  This password was copied from an instruction on how to create a deployment for a set of test.  The sequence  file will not unlock for editing.  How can I unlock the sequence file?  I am using Test Stand 2014.  This file was last edited in Test Stand 2014.

    cbernie wrote:
    A password was set on a sequence file.  This password was copied from an instruction on how to create a deployment for a set of test.  The sequence  file will not unlock for editing.  How can I unlock the sequence file?  I am using Test Stand 2014.  This file was last edited in Test Stand 2014.
    I'm not 100% sure what you are having problems with. Is the problem that you simply don't remember the password? Or are you unsure how to get teststand to prompt to unlock the file? You can always go to the sequence file property dialog to unlock the file, assuming you know the password.
    -Doug

  • I can not play the sequence in preview mode. How do I fix this issue?

    Each frame loads in the preview window when highlighted, but I can not play the sequence.

    I am working on a project for school. I have been draging clips down to the timeline and matching it with a few voice overs. Nothing too complex. I have been previewing my work as I go by pressing the space bar, Im not sure what I did but now Premiere will not play the preview in the Program sequence window.

  • HT1451 Why do the song names and cd name not show up on the IPod Shuffle?

    Why do the song names and cd name not show up on the Shuffle?

    MysticChyk wrote:
    Why do the song names and cd name not show up on the Shuffle?
    Err this is no longer April 1st you know.
    The iPod Shuffle has never had a 'display' on which track names can be shown. See http://www.apple.com/ipod-shuffle/ if you want an iPod which does have a display on which you can see the tracks names and even the album cover art then look instead at the bigger and more expensive iPod Nano http://www.apple.com/ipod-nano/ or iPod Touch http://www.apple.com/ipod-touch/
    PS. The current iPod Shuffle even though it has no display on which it can show the track names can read them out loud to you using a voice-synthesiser this is the VoiceOver feature described on the iPod Shuffle product page I listed above.

  • Why is it that when I try to open a project, it says "the project contained a sequence that could not be opened. No sequence preview preset file or codec could be associated with this sequence type"?

    It could be opened last night but today it just kept showing "the project contained a sequence that could not be opened. No sequence preview preset file or codec could be associated with this sequence type". I really need to access my video.
    Some help out there, please?

    Hi,
    Please check this out : https://forums.adobe.com/message/4626663#4626663#4626663
    Thank You
    Arjun

  • My 2008 Mac Pro running Lion will not play HDV1080i60 footage in FCP 7. When I open the sequence settings, all HDV codecs are hdv1, hdv2, hdv3, and so forth. Anyone have any idea how to fix this?

    My 2006 - 2008 Mac Pro running Lion will not play HDV 1080i60 footage in FCP 7. When I open the sequence settings, all HDV codecs are hdv1, hdv2, hdv3, and so forth. However, when I open the project on my other Mac Pro running Snow Leopard and FCP 6, the footage works fine as it does on my newer Imac running Mavericks and FCP 7. I have tried a Quicktime update on the Mac Pro that the footage doesn't work on but it says that I already have the newest version of Quicktime installed. I have also tried reinstalling the Final Cut Pro Studio twice, still no fix. I'm completely out of solutions and need to be able to edit HDV footage on this machine. Any help would be great. Thanks.

    there was a recent software update that seemed to screw HDV up.  Do some searching here over the last month or 2 and you'll find a bunch of posts and some possible solutions.
    Worst case scenario, do as Shane suggests.  But might I suggest you take a look at the user tips section of the forum.  there are some great tips on how to prevent these sorts of problems by cloning your startup drive, etc.

  • When creating a new project, the step "new sequence settings" doe not appear automatically, what to do?

    Hi there,
    I have a question I am doing product videos for a comany they would like me to do this in a format that is 16:9 and in HD. Since they don't know on which channels they want to publish it but it is certain they will publish it on youtube I wanted to do it in the settings HDV and then DVCPROHD 720p24 or even 1080p24. I have bought the license of Premiere online and for some reason I do not have the option in the beginning when I create a new project to change the sequence settings. They do not appear and afterwards I cannot change them. Do you guys have an idea what can be done in order to access this setting before the project ultimately opens?
    I'd highly appreciate any kind of help on the matter!
    Cheers,
    Mascha

    Or do this:
    or this

  • My iPod shuffle will not turn on, nor is it recognized by the computer to pull up iTunes. I have order new USB cords and nothing. Please help!

    My iPod shuffle will not turn on, nor is it recognized by the computer to pull up iTunes. I have order new USB cords and nothing. Please help! Not sure of the generation of iPod shuffle, I think 3rd.

    first: why did you download the iOS Beta 8? If you are a developer, go to the Apple Developers website and check what they can do for your case.
    second: setup an appointment to a Genius Bar for service.

  • My iPod shuffle could be seen on iTunes, but it cannot be charged and don't play music. The battery light do not flash at all.

    Like what I mentioned, the iPod do not work, it won't play music and the battery light do not flash.
    But it shows in iTunes, and I could sync music into it.
    I tried to reset all the settings of the iPod, and installed all the new software, but it does not work.
    I don't know if it works before, my friend left it to me. I erased all the data she used before and syncronized all my music inside.
    But it just never worked in my hand...
    I really appreciate all feedbacks! Thanks and please answer this question if you have the similar situation!!

    Are you using the USB docking cable that came with the iPod?  There are separate contact points for power and data, so it is possible for the cable to connect for data, but not for power.  Some third-party replacement cables may be of lower quality, if you do not have the original cable
    However, it seems to be getting power, since the shuffle is operating when connected and you are able to sync when it is connected.  So I think your USB docking cable is working.
    That leaves a problem with the USB port or a problem on the shuffle.
    For the USB port, it may not be supplying sufficient power to charge the battery.  As a test, you should shut down (power off) the computer and disconnect all USB devices, including hub, except for standard keyboard and mouse (if normally used).  If the Mac is a laptop, connect its power adapter (so that it's not running on battery power).  Do this to reset the shuffle
    http://support.apple.com/kb/ht1655
    Start up the Mac, run iTunes, and connect the shuffle to a direct USB port on the Mac.  Any difference...?
    If that does not help, it may be a problem with the shuffle, such as a worn out battery. 

Maybe you are looking for