FAQ Database Discussion Community


How to read Superspeed or Highspeed of a USB flash drive in C#

c#,usb,enumeration
I have found this question and answer within this site here:Detect if device is using USB 3.0 but when I ran the program, the result never returned a SuperSpeed connection. I plugged in the USB3.0 flash drive into the USB 3 port so it's supposed to return SuperSpeed to me....

Looping through an enum, TypeScript and JQuery

jquery,enums,typescript,ienumerable,enumeration
Hello im trying t develop a straight forward todo app using TypeScript and JQuery. I have an enum that lists task types: export enum TaskType { FrontEnd, BackEnd, Designer }; However looping through the emum using jquery.each or for loop, i get the following result, (values then indexes): FrontEnd, BackEnd,...

order mismatch in Enumeration

java,enumeration
I am using Enumeration to read property file. Let's say values in my properties file are lon2qaidxiat01.idx.local, master, 2015-02-13, 2015-02-28. But when I try to read the same using Enumeration, it reads in random order like 2015-02-13,master,2015-02-28,lon2qaidxiat01.idx.local. Below is my code: try { dbProperties.load(new FileInputStream("config/db.properties")); Enumeration enuKeys = dbProperties.elements(); while...

Directory enumeration is missing csrss.exe and lsass.exe (c#)

c#,windows,enumeration,system32
I'm trying to enumerate files in C:\Windows\system32 and C:\Windows\SysWow64. But I'm missing files csrss.exe and lsass.exe and possibly more, I only checked these two files. Those files are there, I can see them in total commander and in explorer. They are just not in the enumeration result. List<string> result =...

What's the cleanest way to set up an enumeration in Python? [duplicate]

python,enums,enumeration
This question already has an answer here: How can I represent an 'Enum' in Python? 43 answers I'm relatively new to Python and I was interested in finding out the simplest way to create an enumeration. The best I've found is something like: (APPLE, BANANA, WALRUS) = range(3) Which...

NoSuchElementException in request

java,vector,httprequest,enumeration
After the first call to getHeaders(), the pointer stays at end of Enumeration en. Second time when getHeaders() is called, the and when while(en.hasMoreElements()) is checked, there are no elements and so empty vector is returned. public Enumeration<String> getHeaders(String Pname) { Vector<String> s = new Vector<String>(); Enumeration<String> en = getHttpServletRequest().getHeaders(Pname);...

Difference between associated and raw values in swift enumerations

swift,enums,enumeration
Swift enumerations have both associated and raw values. But the use cases of these values is not clear to me. So I would really appreciate if anyone can explain the difference between the associated and raw values, an example would be very helpful.

Can Scala enumeration maps to an Integer like Java?

java,scala,enums,enumeration
I have an original Java enumeration class, which I can get the corresponding integer value using: Integer blackInteger = ColorEnum.BLACK.getValue() public enum ColorEnum { BLACK(0), BLUE(1), RED(2); private int value; private ColorEnum(int value) { this.value = value; } public int getValue() { return value; } } I then tried to...

How to print all the additions and multiplications of a Galois Field in Sage

python,enumeration,sage,galois-field
My command line takes two inputs, a prime p and a positive integer n. I put them in a Galois Field in the form of GF(p^n). My goal is to print out all the elements of the field, the additions, and multiplications. I can print out the elements of the...

Iterate/enumerate over part of a list?

c#,collections,enumeration
Is there a way to remember the position of an enumerator? I want to remember the position of an enumerate, so that I can reset it to a position before the current. I don't want to go back to the beginning so .reset() doesn't help. Btw, is it possible to...

What is a mapping between natural numbers and valid simply typed lambda calculus terms?

algorithm,search,functional-programming,enumeration,lambda-calculus
Is there any efficient algorithm that maps between well-typed, closed terms of the simply typed lambda calculus and natural numbers? For example, using bruijn indexes (and probably on incorrect order): 0 → (λ 0) 1 → (λ (λ (0 1))) 2 → (λ (λ (1 0))) 3 → (λ 0...

Enumerate factors of a number directly in ascending order without sorting?

algorithm,primes,enumeration,factors
Is there an efficient algorithm to enumerate the factors of a number n, in ascending order, without sorting? By “efficient” I mean: The algorithm avoids a brute-force search for divisors by starting with the prime-power factorization of n. The runtime complexity of the algorithm is O(d log₂ d) or better,...

Fast Enumeration over NSMutableArray problems

objective-c,nsmutablearray,enumeration
I am having some issues trying to wrap my head around why we can not mutate a collection during enumeration... Apparently, if you are doing any sort of fast enumeration, the system should throw an exception if you try to mutate. Below I have three examples where I am mutating...

Python will Sometimes Not Read in Entire File

python,io,enumeration
I have python 2.7 program used on a unix server that reads in an ASCII file with two types of information and processes that information. I have put this process into a function that essentially does: def read_info() f = open(file_name, 'rb') f_enumerator = enumerate(f, start=1) for i, line in...

Remove duplication of enumerated elements

c++,enums,enumeration
I have the following enumerator and it's likely to be expanded over the course of program development: enum myEnum { Element1, Element2, Element3 ... ElementX Last }; I have a function that uses the enumerator in the following way: bool CheckEnumValidity(myEnum a) { bool valid = false; switch (a) {...

Does Octave support enumeration like Matlab?

matlab,octave,enumeration
Does Octave support enumeration like Matlab? I haven't found any info about it. We can create an enumeration class by adding an enumeration block to a class definition. For example, the WeekDays class enumerates a set of days of the week (from Matlab doc). %file WeekDays.m classdef WeekDays enumeration Monday,...

What is the use of Enumerations in Hashtables or maps?

java,hashmap,hashtable,enumeration
I was Looking for some examples of Hashtables on Stack Overflow, and found this: Enumeration enumeration = companies.elements(); while ( enumeration.hasMoreElements() ) { System.out.println("hashtable values: "+enumeration.nextElement()); } Why do we use Enumerations and specifically in Hashtables what is its significance?...

RealmSwift error: “RLMException, reason: Collection was mutated while being enumerated.”

swift,nspredicate,enumeration,realm
I am getting the following error: "RLMException, reason: Collection was mutated while being enumerated." I get the error when I try to do this: let realm = Realm() let words = realm.objects(Word).filter("ANY collectedSentences.characterCount > 0") realm.write { for word in words { word.collectedSentences.removeAll() } } I don't get that error...

Python — how to force enumerate to start at 1 — or workaround?

python,for-loop,enumeration,modulus
I have a simple for loop: for index, (key, value) in enumerate(self.addArgs["khzObj"].nodes.items()): and I want to start a new wx horizontal boxsizer after every 3rd item to create a panel with 3 nodes each and going on for as many as are in nodes. The obvious solution is to do:...

Current object in Enumerator [closed]

ruby,enumeration
Enumerator#peek returns next object in enumerator. But how to get current object? I couldn't find any other solution than using index (for array)....

Elixir - Looping through and adding to map

enumeration,elixir
I'm rebuilding something in Elixir from some code I built in C#. It was pretty hacked together, but works perfectly (although not on Linux, hence rebuild). Essentially what it did was check some RSS feeds and see if there was any new content. This is the code: Map historic (URL...

Different behaviour when collection modified between Dictionary and ConcurrentDictionary

c#,dictionary,.net-4.0,enumeration,concurrentdictionary
With a normal Dictionary code as list below, I get exception that Collection was modified; enumeration operation may not execute. Dictionary<int, int> dict2 = new Dictionary<int, int>(); dict2.Add(1, 10); dict2.Add(2, 20); dict2.Add(3, 30); dict2.Add(4, 40); foreach (var d in dict2) { if (dict2.ContainsKey(2)) dict2.Remove(2); if (dict2.ContainsKey(3)) dict2.Remove(3); } However with...