当前位置: 首页 > news >正文

西宁网站建设君博推荐建站模板更改

西宁网站建设君博推荐,建站模板更改,展厅设计素材网站,广州微型网站建设用链表存储用户发送的每一个推特#xff0c;用堆获取最先的10条动态 class Twitter {MapInteger,SetInteger followMap;//规定最新的放到最后MapInteger,Tweet postMap;//优先队列(堆#xff09;PriorityQueueTweet priorityQueue;int time…用链表存储用户发送的每一个推特用堆获取最先的10条动态 class Twitter {MapInteger,SetInteger followMap;//规定最新的放到最后MapInteger,Tweet postMap;//优先队列(堆PriorityQueueTweet priorityQueue;int timeStamp 0;int limit 10;public Twitter() {followMap new HashMap();postMap new HashMap();//按照每一个推特发送的时间戳由大到小排布priorityQueue new PriorityQueue((t1,t2) - t2.timeStamp - t1.timeStamp);}//userId发送推特public void postTweet(int userId, int tweetId) {//首先根据postMap来获取userId对应发送到文章Tweet tweet postMap.get(userId);//生成新的tweetTweet newTweet new Tweet(tweetId, timeStamp, tweet);postMap.put(userId,newTweet);}//根据userId获得自己和关注用户的10条推特按时间顺序由近到远排序public ListInteger getNewsFeed(int userId) {//因为每一个用户都有自己的优先队列所以先清空优先队列priorityQueue.clear();//将自己和关注的用户发送的最新的推特id先放入到优先队列if (postMap.containsKey(userId))priorityQueue.offer(postMap.get(userId));SetInteger follows followMap.get(userId);if (follows ! null){for (Integer follow : follows) {if (postMap.containsKey(follow))priorityQueue.offer(postMap.get(follow));}}//现在用户和所有关注的推特都已经放入到优先队列开始获取前10条int count 0;ArrayListInteger result new ArrayList();while (!priorityQueue.isEmpty() count limit){//获取头部,在优先队列中删除Tweet tweet priorityQueue.poll();result.add(tweet.id);if (tweet.next ! null)priorityQueue.offer(tweet.next);count;}return result;}//关注public void follow(int followerId, int followeeId) {// 被关注人不能是自己if (followeeId followerId) {return;}SetInteger follows followMap.getOrDefault(followerId, new HashSet());follows.add(followeeId);followMap.put(followerId,follows);}//取关public void unfollow(int followerId, int followeeId) {// 被关注人不能是自己if (followeeId followerId) {return;}SetInteger follows followMap.getOrDefault(followerId, new HashSet());follows.remove(followeeId);followMap.put(followerId,follows);} } class Tweet{int id;int timeStamp;Tweet next;public Tweet(int id, int timeStamp) {this.id id;this.timeStamp timeStamp;}public Tweet(int id, int timeStamp, Tweet next) {this.id id;this.timeStamp timeStamp;this.next next;} }/*** Your Twitter object will be instantiated and called as such:* Twitter obj new Twitter();* obj.postTweet(userId,tweetId);* ListInteger param_2 obj.getNewsFeed(userId);* obj.follow(followerId,followeeId);* obj.unfollow(followerId,followeeId);*/
http://www.hkea.cn/news/14486187/

相关文章:

  • 网站框架优化网站内链有什么用
  • 网站怎么添加流量长沙做网站公
  • 怎么做网站图标石景山网站制作建设公司
  • 天猫网站建设的目标做淘宝优惠券怎么有网站
  • 网站备份脚本友情链接平台网站
  • 如何查看网站 是哪家做的怎么做网站平台
  • 建设门户网站多少钱做网站的公司搞什么活动
  • 工商网上怎么申请注册公司网站如何做seo优化
  • cms网站开发php建设什么网站可以上传视频
  • 安徽省高等级公路工程建设指挥部网站wordpress 聊天室
  • 甘肃网站开发公司自己创做网站
  • 自己怎么做网站链接网站seo价格
  • 用word 做网站成都h5网站建设
  • ipad 设计网站wordpress时间有问题
  • 国家建设 免费论文期刊网站网站制作思路
  • 网站开发有哪些参考文献天津电力建设公司招标网站
  • 山东公司网站建设大街网企业招聘官网
  • 灵芝住房和城乡建设局局网站投资担保网站建设
  • 厦门正规网站建设多少邯郸哪里可以学建网站
  • 潍坊快速网站排名iis端口相同不同网站建设
  • 个人网站网页设计模板wordpress混乱
  • 家政公司网站怎么做天津建设网站的公司
  • 常州网站排名优化wordpress 房产模板
  • 网站改版 大量旧页面网站开发视频会议插件
  • 网站seo快速排名优化使用aspx做电影网站
  • 建设网站设计论文范文《网页制作与网站建设》
  • 建筑人才招聘网站平台看到一个电商网站帮做淘宝
  • 西宁知名网站设计公司免费推广方法
  • 网站建设如何赚钱wordpress免费教育机构主题
  • 安徽 网站信息内容建设成都进入搜索热度前五