enumeration

Z3 Enumerating all satisfying assignments

人走茶凉 提交于 2019-12-19 10:25:35
问题 I am trying to solve a problem similar to the one here (Z3: finding all satisfying models) where I need to find all satisfying assignments of SMT formulae that contain set variables. I understand the idea in the link since it is similar to what some SAT solvers do to iterate through solutions: add the negation of the solution to obtain a different solution. However, when I use the set variables (which are implemented as arrays in Z3) the things get a little complicated or perhaps I miss

How to add custom item to system menu in C++?

泪湿孤枕 提交于 2019-12-19 08:16:22
问题 I need to enumerate all running applications. In particular, all top windows. And for every window I need to add my custom item to the system menu of that window. How can I accomplish that in C++? Update. I would be more than happy to have a solution for Windows, MacOS, and Ubuntu (though, I'm not sure if MacOS and Ubuntu have such thing as 'system menu'). 回答1: For Windows, another way to get the top-level windows (besides EnumWindows, which uses a callback) is to get the first child of the

.Net enumerate winforms font styles?

霸气de小男生 提交于 2019-12-19 06:30:20
问题 I have been searching around for a way to list the valid font styles for a given font using the .Net framework (even if I have to pinvoke gdi32 or some other API) since not all fonts fall into the System.Drawing.FontStyle enum values (Bold, Italic, Regular, Strikeout, Underline). A perfect example of a font that does not fit the bill is Segoe UI, which is a TrueType Microsoft font, with font styles of: Regular, Semibold, Light, Bold, Italic, and BoldItalic. Another example is Arial which has:

Loop through irregular enumeration in Delphi

本小妞迷上赌 提交于 2019-12-19 06:18:25
问题 1) Does anyone know if it is possible to loop through an irregular enumeration in Delphi (XE)? Looping over a normal enumeration is ok. From Delphi Basics: var suit : (Hearts, Clubs, Diamonds, Spades); begin // Loop 3 times For suit := Hearts to Diamonds do ShowMessage('Suit = '+IntToStr(Ord(suit))); end; But, if 'suit' instead is declared as var suit : (Hearts=1, Clubs, Diamonds=10, Spades); it loops 10 times. Not suprising, but I would like to loop 3. The only solution I've found so far is

Make using statement usable for multiple disposable objects

荒凉一梦 提交于 2019-12-19 05:09:33
问题 I have a bunch of text files in a folder, and all of them should have identical headers. In other words the first 100 lines of all files should be identical. So I wrote a function to check this condition: private static bool CheckHeaders(string folderPath, int headersCount) { var enumerators = Directory.EnumerateFiles(folderPath) .Select(f => File.ReadLines(f).GetEnumerator()) .ToArray(); //using (enumerators) //{ for (int i = 0; i < headersCount; i++) { foreach (var e in enumerators) { if (

why does comma(,) not cause to compilation error?

自闭症网瘾萝莉.ら 提交于 2019-12-19 05:08:53
问题 I am writing a code that and suddenly see that "," doesn't cause any compilation error. Why ? What I mean public enum A { B, C, ; // no compilation error } but int a, b, ; // compilation error 回答1: http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.9 The Enumbody has the following specification: { [EnumConstantList] [,] [EnumBodyDeclarations] } As you can see there can be an optional comma after the EnumConstantList, this is just a notational convenience. 回答2: The language was

C# Class is IEnumerable AND an IEnumerator at the same time. What are the issues with this?

牧云@^-^@ 提交于 2019-12-19 02:07:08
问题 I have a class called GenericPermutations that is both enumerable and an enumerator. Its job is to take an ordered list of objects and iterate through each permutation of them in order. Example, an integer implemenation of this class could iterate through the following: GenericPermutations<int> p = new GenericPermutations<int>({ 1, 2, 3 }); p.nextPermutation(); // 123 p.nextPermutation(); // 132 p.nextPermutation(); // 213 // etc. So its enumerable in the sense that it contains a 'list' of

Java: Enumeration from Set<String>

你。 提交于 2019-12-18 13:51:23
问题 I have a simple collections question. I have a Set<String> object. I want an enumeration of the strings in that set. What is the cleanest/best way to go about it? 回答1: EDIT: There's no need to write your own (although I'll leave the implementation below for posterity) - see Kevin Bourrillion's answer for the one in the JDK. If you really need an enumeration, could could use: Enumeration<String> x = new Vector(set).elements(); It would be better to use Iterable<E> if at all possible though...

How do I import a COM object namespace/enumeration in Python?

强颜欢笑 提交于 2019-12-18 11:33:23
问题 I'm relatively new to programming/python, so I'd appreciate any help I can get. I want to save an excel file as a specific format using Excel through COM. Here is the code: import win32com.client as win32 def excel(): app = 'Excel' x1 = win32.gencache.EnsureDispatch('%s.Application' % app) ss = x1.Workbooks.Add() sh = ss.ActiveSheet x1.Visible = True sh.Cells(1,1).Value = 'test write' ss.SaveAs(Filename="temp.xls", FileFormat=56) x1.Application.Quit() if __name__=='__main__': excel() My

C# - AsEnumerable Example

江枫思渺然 提交于 2019-12-18 07:11:52
问题 What is the exact use of AsEnumerable? Will it change non-enumerable collection to enumerable collection?.Please give me a simple example. 回答1: After reading the answers, i guess you are still missing a practical example. I use this to enable me to use linq on a datatable var mySelect = from table in myDataSet.Tables[0].AsEnumerable() where table["myColumn"].ToString() == "Some text" select table; 回答2: From the "Remarks" section of the MSDN documentation: The AsEnumerable<TSource> method has