Questions tagged [is-empty]

Questions about items that can be described as empty or having no data value

776 questions
44
votes
8 answers

How can I check if a Queue is empty?

In C#, how can I check if a Queue is empty? I want to iterate through the Queue's elements, and I need to know when to stop. How can I accomplish this?
MoShe
  • 6,197
  • 17
  • 51
  • 77
41
votes
1 answer

Javascript: Checking if an object has no properties or if a map/associative-array is empty

Possible Duplicate: How do I test for an empty Javascript object from JSON? Is there an easy way to check if an object has no properties, in Javascript? Or in other words, an easy way to check if a map/associative array is empty? For example,…
Vivin Paliath
  • 94,126
  • 40
  • 223
  • 295
41
votes
4 answers

How to check if a Stack is empty

Is there some other way, except Stack.Count() == 0, to check if a Stack is empty? Coming from C++/Java background where "stack" classes generally have some sort of dedicated "is empty" method like Java - Stack.empty.
BobsunShirov
  • 447
  • 1
  • 4
  • 6
39
votes
5 answers

What is the best way to check if a tuple has any empty/None values in Python?

What is the best/most efficient way to check if all tuple values? Do I need to iterate over all tuple items and check or is there some even better way? For example: t1 = (1, 2, 'abc') t2 = ('', 2, 3) t3 = (0.0, 3, 5) t4 = (4, 3, None) Checking…
Andrius
  • 19,658
  • 37
  • 143
  • 243
38
votes
14 answers

Best way to verify string is empty or null

i am sure this must have been asked before in different ways - as isEmptyOrNull is so common yet people implement it differently. but i have below curious query in terms of best available approach which is good for memory and performance both. 1)…
prash
  • 896
  • 1
  • 11
  • 18
37
votes
4 answers

Difference between isEmpty() and isBlank() Method in java 11

Java 11 has added A new instance method isBlank() to java.lang.String class. What's the basic difference between the existing isEmpty and newly added isBlank() method?
Niraj Sonawane
  • 10,225
  • 10
  • 75
  • 104
36
votes
2 answers

How do I detect empty cells in a cell array?

How do I detect empty cells in a cell array? I know the command to remove the empty cell is a(1) = [], but I can't seem to get MATLAB to automatically detect which cells are empty. Background: I preallocated a cell array using a=cell(1,53). Then…
N.C. Rolly
  • 363
  • 1
  • 3
  • 4
32
votes
4 answers

Shell Script : How to check if variable is null or no

I want to check if variable is null or no. My code is : list_Data="2018-01-15 10:00:00.000|zQfrkkiabiPZ||04| 2018-01-15 10:00:00.000|zQgKLANvbRWg||04| 2018-01-15 10:00:00.000|zQgTEbJjWGjf||01| 2018-01-15…
user6223604
27
votes
9 answers

R: Remove multiple empty columns of character variables

I have a data frame where all the variables are of character type. Many of the columns are completely empty, i.e. only the variable headers are there, but no values. Is there any way to subset out the empty columns?
user702432
  • 11,898
  • 21
  • 55
  • 70
26
votes
8 answers

Recursively remove empty elements and subarrays from a multi-dimensional array

I can't seem to find a simple, straight-forward solution to the age-old problem of removing empty elements from arrays in PHP. My input array may look like this: Array ( [0] => Array ( [Name] => [EmailAddress] => ) ) (And so on, if there's more…
Chuck Le Butt
  • 47,570
  • 62
  • 203
  • 289
25
votes
3 answers

Why does an empty dataframe fail an is.null() test?

please excuse me if my question is quite basic. I created an empty data frame by df <- data.frame() and obviously the data frame is NULL (empty). when I try to check if the data frame is empty by is.null(df), the result comes FALSE. Is there any…
Agaz Wani
  • 5,514
  • 8
  • 42
  • 62
25
votes
7 answers

Why is String.IsNullOrEmpty faster than String.Length?

ILSpy shows that String.IsNullOrEmpty is implemented in terms of String.Length. But then why is String.IsNullOrEmpty(s) faster than s.Length == 0? For example, it's 5% faster in this benchmark: var stopwatches = Enumerable.Range(0, 4).Select(_ =>…
Edward Brey
  • 40,302
  • 20
  • 199
  • 253
24
votes
6 answers

Is empty() enough or use isset()?

Note - I know pretty much about empty() and isset(), what I am asking is the most proper/efficient way of using them. I've just saw at php.net this sentence under empty() reference: No warning is generated if the variable does not exist. That…
Forien
  • 2,712
  • 2
  • 13
  • 30
20
votes
2 answers

How to check if an associative array is empty in powershell

$a = @() How do I check if $a above is empty (which it is). I would like to get $true as answer.
Spencer E
  • 203
  • 1
  • 2
  • 4
20
votes
5 answers

Check if list is empty without using the `not` command

How can I find out if a list is empty without using the not command? Here is what I tried: if list3[0] == []: print("No matches found") else: print(list3) I am very much a beginner so excuse me if I do dumb mistakes.
user2240288
  • 235
  • 2
  • 3
  • 8
1
2
3
51 52