新足迹

 找回密码
 注册

精华好帖回顾

· 墨尔本的一场周末房产拍卖 (2006-6-25) villa · Wagga Wagga旅途见闻 (2004-12-10) NT
· 我在墨尔本的第一天 (2004-12-19) 飞龙 · 澳洲天堂❤Hamilton Island ❤大堡礁游船,浮潜,直升机,水上摩托阳光与沙滩浪漫激情游! (2014-10-5) Kittymeow
Advertisement
Advertisement
查看: 916|回复: 2

[IT] 中介给的self assessment问题似乎都是这样的 C/C++ [复制链接]

发表于 2007-12-13 17:13 |显示全部楼层
此文章由 内核 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 内核 所有!转贴必须注明作者、出处和本声明,并保持内容完整
碰到4个中介都用同一套题来考偶~~拿出来给大家参考参考~~

You are required to implement a queue, as illustrated by the following diagram:



The queue must have the following features:
•        Thread safe for any number of reading and writing threads
•        The Dequeue method must be blocking. i.e. it does not return until it can retrieve an item from the queue.

You may choose to implement the queue in either C++ or C#.  Please select from the prototypes listed below.

You are only required to implement the Enqueue and Dequeue methods.

If you are unsure of the syntax of any commands you are using please make sure the intent of your code is clear via inline comments or similar.

C# Prototype using .NET Generics
class WaitableQueue<T>
{
    private Queue<T> _queue;
    public WaitableQueue();
    public void Enqueue(T item);
    public T Dequeue();
}

C++ Prototype using templates and the STL
template <class T>
class WaitableQueue
{
public:
        WaitableQueue();
        virtual ~WaitableQueue();
        void Enqueue(T* item);
        T* Dequeue();
private:
        std::queue<T> _queue;
};

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

评分

参与人数 1积分 +8 收起 理由
黑山老妖 + 8 感谢分享

查看全部评分

Advertisement
Advertisement

退役斑竹 2007 年度奖章获得者 2008年度奖章获得者 特殊贡献奖章 参与宝库编辑功臣

发表于 2007-12-13 18:13 |显示全部楼层
此文章由 黑山老妖 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 黑山老妖 所有!转贴必须注明作者、出处和本声明,并保持内容完整
谢谢LZ分享

发表于 2007-12-13 20:14 |显示全部楼层
此文章由 内核 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 内核 所有!转贴必须注明作者、出处和本声明,并保持内容完整

发表回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Advertisement
Advertisement
返回顶部