新足迹

 找回密码
 注册

精华好帖回顾

· 十年前最喜欢在学校门口吃5毛钱一个的…… (2008-2-8) 小茉莉 · 蛋糕姐姐家的简易快捷家常晚餐之二,5月6日更新在第15页,烤鸡腿菇,蒸豆腐虾仁,苔条江白虾 (2012-5-1) chesecake
· 20年来, 那些事,那些人(2013-02-01更新) (2013-1-1) daniello · 我与北外红颜的故事之我爱你,此生不渝 (2024-3-20) rivaldo
Advertisement
Advertisement
查看: 917|回复: 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
返回顶部