Skip to content

Instantly share code, notes, and snippets.

@amadamala
amadamala / HashTable.java
Last active June 28, 2022 03:55
HashTable implementation in Java
public class HashTable {
private static int INITIAL_SIZE = 16;
private HashEntry[] entries = new HashEntry[INITIAL_SIZE];
public void put(String key, String value) {
int hash = getHash(key);
final HashEntry hashEntry = new HashEntry(key, value);
if(entries[hash] == null) {
entries[hash] = hashEntry;
}
// If there is already an entry at current hash
@Isabellle
Isabellle / RecyclerViewListener.java
Created May 13, 2016 09:41
Get clicked item and its position in RecyclerView
//Based on the link: Why doesn't RecyclerView have onItemClickListener()? and How RecyclerView is different from Listview?, and also @Duncan's general idea, I give my solution here:
//define one interface 'RecyclerViewClickListener' for passing message from adapter to Activity/Fragment:
public interface RecyclerViewClickListener
{
public void recyclerViewListClicked(View v, int position);
}
//In Activity/Fragment implement the interface, and also pass listener to adapter:
@Override