What is the lookup time complexity of HashSet(IEqualityComparer)?

A HashSet works via hashing (via IEqualityComparer.GetHashCode) the objects you insert and tosses the objects into buckets per the hash. The buckets themselves are stored in an array, hence the O(1) part. For example (this is not necessarily exactly how the C# implementation works, it just gives a flavor) it takes the first character of … Read more

What is the best way of reading configuration parameters from configuration file in Java?

I am thinking it will impact performance. I doubt that this will be true. Assuming that the application reads the configuration file just once at startup, the time taken to read the file is probably irrelevant to your application’s overall performance. Indeed, the longer the application runs, the less important startup time will be. Standard … Read more

Prevent launching multiple instances of a java application

You could use a FileLock, this also works in environments where multiple users share ports: String userHome = System.getProperty(“user.home”); File file = new File(userHome, “my.lock”); try { FileChannel fc = FileChannel.open(file.toPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE); FileLock lock = fc.tryLock(); if (lock == null) { System.out.println(“another instance is running”); } } catch (IOException e) { throw new Error(e); … Read more

Is there any penalty/cost of virtual inheritance in C++, when calling non-virtual base method?

There may be, yes, if you call the member function via a pointer or reference and the compiler can’t determine with absolute certainty what type of object that pointer or reference points or refers to. For example, consider: void f(B* p) { p->foo(); } void g() { D bar; f(&bar); } Assuming the call to … Read more

How to call .NET methods from Excel VBA?

Here is a canonical answer on the 3 main methods to call .Net from Excel (or VBA). All three ways work in .Net 4.0. 1. XLLs The 3rd party vendor Add-In Express offer XLL functionality, however its free and easy to use Excel-DNA the author is here https://stackoverflow.com/users/44264 Here is an extract from the Excel-DNA … Read more

How to read Javadoc comments by reflection?

Doclet class: public class ExtractCommentsDoclet { public static boolean start(RootDoc root) throws IOException { for (ClassDoc c : root.classes()) { print(c.qualifiedName(), c.commentText()); for (FieldDoc f : c.fields(false)) { print(f.qualifiedName(), f.commentText()); } for (MethodDoc m : c.methods(false)) { print(m.qualifiedName(), m.commentText()); if (m.commentText() != null && m.commentText().length() > 0) { for (ParamTag p : m.paramTags()) print(m.qualifiedName() + … Read more

How to find time taken to run a Java program?

You can compare times using System.nanoTime() . It will return the time in nanoseconds. Returns the current value of the most precise available system timer, in nanoseconds. You could use it like this: long startTime = System.nanoTime(); // code long endTime = System.nanoTime(); System.out.println(“Took “+(endTime – startTime) + ” ns”); Usefull links: System.nanoTime()

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)