Ireland Assignments .ieIRELAND.ieASSIGNMENTS
Order Now Log In
  • Home
  • Services
    Writing Services
    • Essay Writing Services
    • Dissertation Writing
    • Thesis Writing Service
    • Literature Review Writing
    • Research Paper For Sale
    • Report Writing Assistance
    • Do My Assignment
    • Write My Essay
    • Buy Assignments Online
    • Irish Homework Help
    AI Support & Referencing
    • Assignment Review Service
    • AI-Free Assignment Help
    • Remove AI From Your Assignment
    • Citation and Referencing Help
    • AI Guidance for Students
    Assignment Type
    • Learner Record Writing
    • Skill Demonstration Assignments
    • Work Experience Diary
    • Reflection Journal
    • Online Exam Help
    • QQI Level 5
    • QQI Level 6
    Course
    • Nursing
    • Childcare
    • Healthcare
    • SNA (Special Needs)
    • Care of Older People
    • Child Development
    • Care Skills
    • Care Support
    • Disability Awareness
    • Infection Prevention
    • Health & Safety at Work
    Online Degree Course
    • Psychology Assignments
    • Early Childhood QQI Assignments
    • Montessori Assignments
    • Palliative Course Assignments
    • Communications FETAC Level 5 Assignments
    • Law Course Assignments
    • Management Assignments
    • Train the Trainer
    • Healthcare Assistance
    • Digital Marketing Assignment
    • QQI Assignments
    Cities
    • Dublin
    • Galway
    • Cork
    • Limerick
    • Waterford
    • Sligo
    • Dundalk
    • Carlow
    • Maynooth
  • Samples
  • Experts
  • Questions
  • Blog
  • Reviews 4.9/5
Order Now Log In
Search from Thousands of
Ireland Asssignments Answers
  • 1500+ Experts
  • A+ Grade
  • Free Turnitin Report
  1. Home
  2. Questions
  3. Given below is a generic class Circular Queue that implements a queue modeled by a circular array: Parallel and Distributed Programming Assignment, GCD, Ireland

Given below is a generic class Circular Queue that implements a queue modeled by a circular array: Parallel and Distributed Programming Assignment, GCD, Ireland

University Griffith College Dublin (GCD)

Question 1

Given below is a generic class Circular Queue that implements a queue modeled by a circular array. There are two constructors a default one that sets the size to an arbitrary value of 20 and one that takes the maximum size of the queue as an argument n.

In both cases, the head and tail are set to zero. This class is not thread-safe. Please note that a queue simply manages the order of insertion and removal, it does not interact in any way with the data under its control. Your task is to re-write it so that it is thread-safe and solves issues that may arise around iteration.

class CircularQueue<T> implements Iterable<T>{
private T queue[];
private int head, tail, size;
public CircularQueue(){
queue = (T[])new Object[20];
head = 0; tail = 0; size = 0;
}
public CircularQueue(int n){ //assume n >=0
queue = (T[])new Object[n];
size = 0; head = 0; tail = 0;
}
public boolean join(T x){
if(size < queue.length){
queue[tail] = x;
tail = (tail+1)%queue.length;
size++;
return true;
}
else return false;
}
public T top(){
if(size > 0)
return queue[head];
else
return null;
}
public boolean leave(){
if(size == 0) return false;
else{
head = (head+1)%queue.length;
size–;
return true;
}
}
public boolean full(){return (size == queue.length);}
public boolean empty(){return (size == 0);}
public Iterator<T> iterator(){
return new QIterator<T>(queue, head, size);
}
private static class QIterator<T> implements Iterator<T>{
private T[] d; private int index;
private int size; private int returned = 0;
QIterator(T[] dd, int head, int s){
d = dd; index = head; size = s;
}
public boolean hasNext(){ return returned < size;}
public T next(){
if(returned == size) throw new NoSuchElementException();
T item = (T)d[index];
index = (index+1) % d.length;
returned++;
return item;
}
public void remove(){}
}
}

Get Solution of this Assessment. Hire Experts to solve this assignment for you Before Deadline.

Get A Free Quote

Question 2

A thread-safe class that implements a Hash table is given. This class uses coarse-grained locking to handle concurrent access for threads sharing an instance of the class. Your task is to implement a fine-grained solution for this class that optimizes concurrent access for threads. The class Concurrent Hash List is given as an appendix at the end of the document. Keep using Reentrant Lock in your fine-grained solution.

import java.util.*;
import java.util.concurrent.locks.*;
public class ConcurrentHashList<E> implements Iterable<E>{
private LinkedList<E> data[];
private Lock lock = new ReentrantLock();
@SuppressWarnings(“unchecked”)
public ConcurrentHashList(int n){
if(n > 1000)
data = (LinkedList<E>[])(new LinkedList[n/10]);
else
data = (LinkedList<E>[])(new LinkedList[100]);
for(int j = 0; j < data.length;j++)
data[j] = new LinkedList<E>();
}
@SuppressWarnings(“unchecked”)
public ConcurrentHashList(Collection<? extends E> cl){
if(cl.size() > 1000)
data = (LinkedList<E>[])(new LinkedList[cl.size()/10]);
else
data = (LinkedList<E>[])(new LinkedList[100]);
for(int j = 0; j < data.length;j++)
data[j] = new LinkedList<E>();
for(E x : cl) this.add(x);
}
private int hashC(E x){
int k = x.hashCode();
int h = Math.abs(k % data.length);
return(h);
}
public void add(E x){
if(x != null){
lock.lock();
try{
int index = hashC(x);
if(!data[index].contains(x))
data[index].add(x);
}finally{lock.unlock();}
}
}
public boolean contains(E x){
if(x == null) return false;
lock.lock();
try{
int index = hashC(x);
return(data[index].contains(x));
}finally{lock.unlock();}
}
public boolean remove(E x){
if(x == null) return false;
lock.lock();
try{
int index = hashC(x);
return data[index].remove(x);
}finally{lock.unlock();}
}
public String toString(){
lock.lock();
try{
StringBuffer s = new StringBuffer(this.size());
s.append(‘<‘);
int ind = 0;
while(ind < data.length){
Iterator<E> it = data[ind].iterator();
while(it.hasNext())
s.append(it.next()+”, “);
ind++;
}
s.deleteCharAt(s.length()-1);
s.setCharAt(s.length()-1,’>’);
return s.toString();
}finally{lock.unlock();}
}
public int size(){
lock.lock();
try{
int j = 0;
for(LinkedList<E> lst : data) j += lst.size();
return j;
}finally{lock.unlock();}
}
public Iterator<E> iterator(){
lock.lock();
try{
ArrayList<E> items = new ArrayList<E>();
int ind = 0;
while(ind < data.length){
Iterator<E> it = data[ind].iterator();
while(it.hasNext())
items.add(it.next());
ind++;
}
return items.iterator();
}finally{lock.unlock();}
}
}

Are You Searching Answer of this Question? Request Ireland Writers to Write a plagiarism Free Copy for You.

Get A Free Quote

Shared with
Ireland Assignments Editorial Team

A student shared this brief with our team; personal details have been removed. Our editorial team works on tasks like this and can guide you on how to approach it.

Submit Your Assignment Questions & Get Plagiarism Free Answers.

Buy Now

Get Help With Your Assignment

Tell us about your assignment in 3 quick steps and get a free, no-obligation quote.

1 Basics 2 Details 3 Contact
The basics
Over 10,000 words? Choose 10,000+ and type your exact count.
Step 1 of 3 · takes under a minute
About your assignment
What help do you need?
Do you have the brief or marking rubric?
Step 2 of 3 · last step is your contact details
Where should we send your quote?
Attach your brief, rubric or notes (optional, up to 10 files)
PDF, Word, PowerPoint, Excel or images · up to 100MB in total
Uploading…
Free quote No payment to submit 100% confidential

To Get Answer
Please Fill the following Details

If you think the question is incomplete, then you can upload your assignment brief.

Facing Issues with Assignments? Talk to Our Experts Now!Download Our App Now!

Request a Call Back
Irish assignment expert ready to help a student

Have Questions About Our Services?
Download Our App!

Get the App Today!

iphone android
QRcode
Ireland Assignments .ieIRELAND.ieASSIGNMENTS

Ireland Assignments

Ireland Assignment's offers plagiarism free assistance to the students around the globe. We understand the value of top grades to a student. And that is the reason we are here to assist you with ultimate professionalism. By availing our services we assure you better grades. Raise your academic grades with our Ireland assignment help.

Useful Links

Useful Links

Useful Links
  • Home
  • Services
  • Samples
  • Blog
  • User Reviews
  • Questions
  • Experts
  • Submit Questions
Legal & Policies

Legal & Policies

Legal & Policies
  • Privacy Policy
  • Warranty
  • Copyright Notice
  • Terms & Conditions
  • About Us
  • Contact Us
  • How Ordering Works
  • University Assignment Help
  • Final Year Project Help
  • Semester Assignment Help
  • Social Care Project Help
  • Care of the Surgical Patient
Cities

Cities

Cities
  • Dublin
  • Galway
  • Cork
  • Limerick
  • Waterford
  • Sligo
  • Dundalk
  • Carlow
  • Maynooth
GDPR
info@irelandassignments.ie
Secure Payment

77 Camden Street Lower, Dublin, D2 XE80, Ireland

Student Login·Facebook

Disclaimer: Ireland Assignments provides academic assistance to students so that they can complete their university assignments and projects on time. Our business does NOT deal with ghostwriting services as we are aware of this being one of the academic misconducts. But we do help students by connecting them to online subject experts within an affordable price range. Also, if you're looking for high-quality resources such as journals and articles, pdf files, videos, research papers, e-books, and other secondary literature to write your assignment task, then we can certainly help you out. Ireland Assignments is not sponsored or endorsed by (Ireland) Quality and Qualification Ireland or any college or university in Ireland or elsewhere in the world. All trademarks, logos and brand names are the property of their respective owners. All university related assistance services, materials and their names used in this website are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.

Ireland Assignments rated 4.9/5 based on 15000+ student reviews on WhatsApp

Copyright © 2026 Ireland Assignments, All Right Reserved