Re: Quickest way to find out if a sequence is/isn't empty?

new topic     » goto parent     » topic index » view thread      » older message » newer message
ZNorQ said...

What would be the quickest way to verify if a sequence is/isn't empty? This especially applies to sequences of considerable sizes.

What I'm trying to explain, is that if a sequence contains data, I don't want the code to iterate through the whole sequence to verify that it ISN'T empty.. I'm guessing not length(mySequence) (or length(mySequence)=0) wouldn't be the quickest one, as it would presumably count through the whole sequence and THEN find out that it isn't empty.

I've also used equal({}, mySequence), but I'm kind of guessing that that also would run through the whole sequence before finding out that it isn't empty.

Regards, ZNorQ aka Kenneth

length(mySequence) is the fastest. length() doesn't count the elements, it just references the existing count (so it's like accessing mySequence[0] where mySequence[0] is always an integer).

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu