新足迹

 找回密码
 注册

精华好帖回顾

· 旅途人生 人生旅途 (2023-4-19) 士多可 · tomtom红灯和超速照相机POI教程 (2006-7-11) 袋鼠
· 响应新闻版TX,开个贴说一说家用防盗系统 -- Alarm,CCTV,Intercom (2011-11-25) 尖椒猪鼻 · {面子产品大交流}之简单药妆篇 (2007-3-25) DancingKeys
Advertisement
Advertisement
查看: 918|回复: 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
返回顶部