Skip to content

Instantly share code, notes, and snippets.

View ldclakmal's full-sized avatar
🎯
Focusing

Chanaka Lakmal ldclakmal

🎯
Focusing
View GitHub Profile
@ldclakmal
ldclakmal / InsertionSort.cpp
Created January 24, 2015 15:58
Insertion Sort
// InsertionSort.cpp : Defines the entry point for the console application.
// input.txt file should be here.
// L.D.C.Lakmal
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
@ldclakmal
ldclakmal / MergeSort.cpp
Created January 24, 2015 16:00
Merge Sort
// MergeSort.cpp : Defines the entry point for the console application.
// L.D.C.Lakmal
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <limits.h>
#define arrSize 6
using namespace std;
@ldclakmal
ldclakmal / LinkedList.cpp
Created January 24, 2015 16:01
Linked List (OOP)
// LinkedList_OOP.cpp : Defines the entry point for the console application.
// L.D.C.Lakmal
#include "stdafx.h"
#include <iostream>
using namespace std;
typedef int E;
class Node {
@ldclakmal
ldclakmal / Dictionary.cpp
Created January 24, 2015 16:02
Dictionary
// Dictionary.cpp : Defines the entry point for the console application.
// L.D.C.Lakmal
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
@ldclakmal
ldclakmal / DynamicArray.java
Created January 24, 2015 16:03
Dynamic Array
import java.io.PrintWriter;
import java.util.Random;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
@ldclakmal
ldclakmal / BinaryTree.cpp
Created January 25, 2015 03:38
Binary Tree
// BinaryTree.cpp : Defines the entry point for the console application.
// L.D.C.Lakmal
#include "stdafx.h"
#include <iostream>
using namespace std;
typedef int element;
@ldclakmal
ldclakmal / BinarySearchTree.cpp
Created January 25, 2015 08:01
Binary Search Tree
// BinarySearchTree.cpp : Defines the entry point for the console application.
// L.D.C.Lakmal
#include "stdafx.h"
#include <iostream>
using namespace std;
typedef int element;
@ldclakmal
ldclakmal / CreateWatchService.java
Last active January 8, 2017 12:28
Create a WatchService
Path dir = Paths.get("/tmp");
WatchService watcher = FileSystems.getDefault().newWatchService();
WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
@ldclakmal
ldclakmal / PathMatcher.java
Last active January 12, 2017 14:47
Check whether picked file matches with the given path pattern
public boolean isMatchPattern(GRPattern GRPattern, Path file) {
PathMatcher matcher = FileSystems.getDefault().getPathMatcher(GRPattern.getPatternSyntax() +
Paths.get(GRPattern.getPathPattern()).toString());
Path name = file.getFileName();
return name != null && matcher.matches(file);
}
@ldclakmal
ldclakmal / CreateWatchKey.java
Last active January 12, 2017 19:12
Create a watch key and poll the events
WatchKey key = watcher.take();
for (WatchEvent<?> event: key.pollEvents()) {
WatchEvent.Kind<?> kind = event.kind();
}