Monday, October 1, 2018
How to Find Multiple Missing Integers in Given Array With Duplicates in Java?
I found this interesting problem here:
https://javarevisited.blogspot.com/2014/11/how-to-find-missing-number-on-integer-array-java.html
but I think the solution is too long, see mine below:
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class MissingIntegers {
public static void main(String[] args) {
Set<Integer> s1 = new HashSet<>(Arrays.asList(new Integer[]{1, 2, 3, 4, 9, 8}));
Set<Integer> s2 = new HashSet<>(IntStream.rangeClosed(1, 10).boxed().collect(Collectors.toList()));
s2.removeAll(s1);
System.out.println(s2);
}
}
In fact we don't need the intermediate List in the case of Set 2, we can use the toCollection method of Collectors:
Set<Integer> s2 = IntStream.rangeClosed(1, 10).boxed().collect(Collectors.toCollection(HashSet::new));
Next day I came up with another solution:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class MissingIntegers {
public static void main(String[] args) {
List<Integer> L1 = Arrays.asList(new Integer[]{1, 2, 3, 4, 9, 2, 8});
List<Integer> L2 = IntStream.rangeClosed(1, 10).boxed().collect(Collectors.toCollection(ArrayList::new));
L2.removeAll(L1);
System.out.println(L2);
}
}
Friday, August 31, 2018
Using Apache Ant in Netbeans
The following ant code is run inside the -post-jar target in a Netbeans Java project.
<!--
Copy the .jar file and the zipped directory dist
to deploy folder in Z: drive
-->
<echo message="Zip and copy: ${application.title}" />
<!--
A file name property for the zip file we are going to create
-->
<local name="zipfile" />
<property name="zipfile" value="${application.title}-dist.zip" />
<!-- The creation of the zip file -->
<zip destfile="${zipfile}">
<fileset dir="${dist.dir}/" />
</zip>
<!-- Copying the 2 files -->
<copy todir="Z:/deploy" overwrite="true">
<resources>
<file file="${dist.jar}" />
<file file="${zipfile}" />
</resources>
</copy>
<delete file="${zipfile}" />
<!-- End of the copy -->
<!--
Copy the .jar file and the zipped directory dist
to deploy folder in Z: drive
-->
<echo message="Zip and copy: ${application.title}" />
<!--
A file name property for the zip file we are going to create
-->
<local name="zipfile" />
<property name="zipfile" value="${application.title}-dist.zip" />
<!-- The creation of the zip file -->
<zip destfile="${zipfile}">
<fileset dir="${dist.dir}/" />
</zip>
<!-- Copying the 2 files -->
<copy todir="Z:/deploy" overwrite="true">
<resources>
<file file="${dist.jar}" />
<file file="${zipfile}" />
</resources>
</copy>
<delete file="${zipfile}" />
<!-- End of the copy -->
Tuesday, March 27, 2018
Style Guidelines for Local Variable Type Inference in Java
Stuart W. Marks just published a very useful guidelines for the use of the newly introduced local variable type inference in Java 10:
var list = List.of("One", "Two", 3);
http://openjdk.java.net/projects/amber/LVTIstyle.html
Friday, January 12, 2018
Mastering Multithreading with C++
![Mastering Multithreading with C++ [Video] from Packt Mastering Multithreading with C++ [Video] Book Cover](https://d255esdrn735hr.cloudfront.net/sites/default/files/imagecache/ppv4_main_book_cover/bookretailers/V09707.png)
A very interesting series of videos about multi threading with C++ by Maya Posch:
https://www.packtpub.com//application-development/mastering-multithreading-c-video
The code in GitHub:
https://github.com/PacktPublishing/Mastering-CPP-Multithreading.git
Thursday, January 11, 2018
How to Check if Your PC Is Protected Against Meltdown and Spectre
Below is a very detailed how-to for checking if a PC is protected against Meltdown and Spectre.
https://www.howtogeek.com/338801/how-to-check-if-your-pc-is-protected-against-meltdown-and-spectre/
https://www.howtogeek.com/338801/how-to-check-if-your-pc-is-protected-against-meltdown-and-spectre/
New - iLink FIX Tag Library
CME just published a resource for querying their iLink FIX tag library. See the announce below.
Taken from: http://www.cmegroup.com/notices/electronic-trading/2018/01/20180108.html#iftlNew - iLink FIX Tag Library
In response to customer requests, a new iLink FIX Tag Library resource is currently available in the Client Systems Wiki. This page centralizes the iLink Message Specification and includes filters for querying iLink tags by:
- Tag Number
- FIX Name
- Tag Requiredness
- Tag Format
Tuesday, January 9, 2018
Subscribe to:
Posts (Atom)