第六次作业 orm整合 接口
结合以前一个项目,将普通的jdbc进行了相关整合,全部改写成了hibernate接口
项目名称:短视频分享平台
主要功能:用户模块:注册、登录、编辑资料、查看用户相关
分类模块:分类添加、查看
视频共享模块:查看、上传、删除
点赞模块:是否已赞、点赞
评论模块:评论、查看
关注模块:关注、查看关注列表、是否已关注、取消关注
实体类:
用户 User
分类 Find
视频信息 Video
点赞信息 Praise
评论信息 Post
关注信息 Follow
对应关系: 一个用户对应多个视频,对应多条评论,对应多个点赞信息,对应多个关注信息。
一个分类对应多个视频
一个视频对应一个分类,对应一个用户,对应多个点赞信息,对应多个评论信息
一个赞对应一个用户,对应一个视频
一条评论对应一个用户,对应一个视频
一个关注对应一个用户
实体类:
1.User
public class User{ private Integer userID; private String username; private String password; private String sex; private String email; private String priority; private String icon; private String introduce; private Set<Video> videos = new HashSet<>(); private Set<Post> posts = new HashSet<>(); private Set<Praise> praises = new HashSet<>(); private Set<Follow> follows1 = new HashSet<>(); private Set<Follow> follows2 = new HashSet<>(); //get and set方法 ...... }
2.Find
public class Find { private int ID; private String find; private Set<Video> videos = new HashSet<>(); //get and set ...... }
3.Video
public class Video{ private int videoID; private String content; private Timestamp date; private String path; private int viewNum; private String isuse; private User user; private Find find; private Set<Post> posts = new HashSet<>(); private Set<Praise> praises = new HashSet<>(); //get and set ...... }
4.Post
public class Post { private int postID; private String content; private Timestamp date; private Video video; private User user; //get and set ...... }
5.Praise
public class Praise { private Integer praiseID; private Video video; private User user; //get and set ...... }
6.Follow
public class Follow { private int followID; private User user1; private User user2; //get and set ...... }
实体配置
1.User.hbm.xml
<hibernate-mapping> <class name="bean.User" table="user"> <id name="userID" column="userID"> <generator class="native"></generator> </id> <property name="username" length="16"></property> <property name="password" length="16"></property> <property name="sex" length="16"></property> <property name="email" ></property> <property name="priority"></property> <property name="icon"></property> <property name="introduce"></property> <set name="videos" inverse="true"> <key column="userID"></key> <one-to-many class="bean.Video"/> </set> <set name="posts" inverse="true"> <key column="userID"></key> <one-to-many class="bean.Post"/> </set> <set name="praises" inverse="true"> <key column="userID"></key> <one-to-many class="bean.Praise"/> </set> <set name="follows1" inverse="true"> <key column="user1"></key> <one-to-many class="bean.Follow"/> </set> <set name="follows2" inverse="true"> <key column="user2"></key> <one-to-many class="bean.Follow"/> </set> </class> </hibernate-mapping>
2.Find.hbm.xml
<hibernate-mapping> <class name="bean.Find" table="find"> <id name="ID" column="ID"> <generator class="native"></generator> </id> <property name="find" length="64"></property> <set name="videos"> <key column="findID"></key> <one-to-many class="bean.Video"/> </set> </class> </hibernate-mapping>
3.Video.hbm.xml
<hibernate-mapping> <class name="bean.Video" table="video"> <id name="videoID" column="videoID"> <generator class="native"></generator> </id> <property name="content"></property> <property name="date"></property> <property name="path"></property> <property name="viewNum"></property> <property name="isuse"></property> <set name="posts" cascade="delete"> <key column="videoID"></key> <one-to-many class="bean.Post"/> </set> <set name="praises" cascade="delete"> <key column="videoID"></key> <one-to-many class="bean.Praise"/> </set> <many-to-one name="user" class="bean.User" column="userID"></many-to-one> <many-to-one name="find" class="bean.Find" column="findID"></many-to-one> </class> </hibernate-mapping>
4.Praise.hbm.xml
<hibernate-mapping> <class name="bean.Praise" table="praise"> <id name="praiseID" column="praiseID"> <generator class="native"></generator> </id> <many-to-one name="user" class="bean.User" column="userID"></many-to-one> <many-to-one name="video" class="bean.Video" column="videoID"></many-to-one> </class> </hibernate-mapping>
5.Post.hbm.xml
<hibernate-mapping> <class name="bean.Post" table="post"> <id name="postID" column="postID"> <generator class="native"></generator> </id> <property name="content"></property> <property name="date"></property> <many-to-one name="user" class="bean.User" column="userID"></many-to-one> <many-to-one name="video" class="bean.Video" column="videoID"></many-to-one> </class> </hibernate-mapping>
6.Follow.hbm.xml
<hibernate-mapping> <class name="bean.Follow" table="follow"> <id name="followID" column="followID"> <generator class="native"></generator> </id> <many-to-one name="user1" class="bean.User" column="user1"></many-to-one> <many-to-one name="user2" class="bean.User" column="user2"></many-to-one> </class> </hibernate-mapping>
dao层
用户dao
public class UserDaoImpl extends AbstractDao implements UserDao{ @Override public int addUser(User user) { if (queryUserByUsername(user)!=null) { return 404; } SessionFactory sessionFactory = null; Session session = null; Transaction transaction =null; try { sessionFactory = HibernateUtil.getSessionFactory(); session = sessionFactory.getCurrentSession(); transaction = session.beginTransaction(); session.save(user); transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } return 0; } return 1; } @Override public User getUser(User user) { SessionFactory sessionFactory = null; Session session = null; Transaction transaction =null; User iUser = null; try { sessionFactory = HibernateUtil.getSessionFactory(); session = sessionFactory.getCurrentSession(); transaction = session.beginTransaction(); Query<User> query = session.createQuery("from User u where u.username=:username and u.password=:password "); query.setParameter("username", user.getUsername()); query.setParameter("password", user.getPassword()); List<User> uList = query.list(); if (uList.size()==1) { iUser = uList.get(0); } transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return iUser; } @Override public User updateUser(File icon, String extensions, User iUser, User user) { user.setUserID(iUser.getUserID()); user.setPassword(iUser.getPassword()); SessionFactory sessionFactory = null; Session session = null; Transaction transaction =null; if (extensions!=null) { String iconPath = UploadUtil.saveFile(icon, extensions, iUser.getUserID()); user.setIcon(iconPath); } try { sessionFactory = HibernateUtil.getSessionFactory(); session = sessionFactory.getCurrentSession(); transaction = session.beginTransaction(); session.update(user); user = session.get(User.class, iUser.getUserID()); transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return user; } @Override public User queryUserByID(User iUser) { SessionFactory sessionFactory = null; Session session = null; Transaction transaction =null; try { sessionFactory = HibernateUtil.getSessionFactory(); session = sessionFactory.getCurrentSession(); transaction = session.beginTransaction(); iUser = session.get(User.class, iUser.getUserID()); transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return iUser; } public User queryUserByUsername(User iUser) { SessionFactory sessionFactory = null; Session session = null; Transaction transaction =null; User user = null; try { sessionFactory = HibernateUtil.getSessionFactory(); session = sessionFactory.getCurrentSession(); transaction = session.beginTransaction(); Query query = session.createQuery("from User u where u.username=:username"); query.setParameter("username", iUser.getUsername()); List<User> uList = query.list(); if(uList.size()>0) user = (User) query.list().get(0); transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return user; } }
视频dao
public class VideoDaoImpl extends AbstractDao implements VideoDao{ @Override public Find queryFind(int findID) { Session session = null; Transaction transaction = null; Query<Find> query = null; Find find = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); query = session.createQuery("from Find f where f.ID=:ID"); query.setParameter("ID", findID); find = query.list().get(1); transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return find; } @Override public List<Find> queryFindList() { if(findNum()==0) { saveFinds(); } Session session = null; Transaction transaction = null; Query<Find> query = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); query = session.createQuery("from Find"); List<Find> finds = query.list(); transaction.commit(); return finds; }catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return null; } @Override public long findNum() { Session session = null; Transaction transaction = null; Query query = null; long num = 0; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); query = session.createQuery("select count(*) from Find"); num = (long)query.uniqueResult(); transaction.commit(); }catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return num; } @Override public void saveFinds() { Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); Find find1 = new Find(); find1.setFind("游戏"); Find find2 = new Find(); find2.setFind("音乐"); Find find3 = new Find(); find3.setFind("学习"); session.save(find1); session.save(find2); session.save(find3); transaction.commit(); }catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } } @Override public Video addVideo(File resource,Video video,int findID, String extensions) { Session session = null; Transaction transaction = null; String videoPath = UploadUtil.saveFile(resource, extensions, video.getUser().getUserID()); video.setPath(videoPath); video.setDate(new Timestamp(new Date().getTime())); try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); Find find = session.get(Find.class, findID); video.setFind(find); session.save(video); transaction.commit(); return video; }catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return null; } @Override public int getVideoID(String path) { Session session = null; Transaction transaction = null; Query query = null; int videoID = 0; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); query = session.createQuery("select v.videoID from Video v where v.path=:path"); query.setParameter("path", path); videoID = (int) query.uniqueResult(); transaction.commit(); }catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return videoID; } @Override public List<VideoView> getVideos(String type) { List<VideoView> videoViews = new ArrayList<>(); Session session = null; Transaction transaction = null; Query query = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); String hql = "from Video v order by videoID desc"; query = session.createQuery(hql); List<Video> videos = query.list(); for(Video video :videos) { VideoView videoView = new VideoView(); videoView.setVideo(video); videoView.setUser(video.getUser()); videoView.setFind(video.getFind()); //videoView.setPraiseNum(praiseDao.getPraiseNum(video.getVideoID())); videoView.setPraiseNum(video.getPraises().size()); //videoView.setPostNum(postDao.getPostNum(video.getVideoID())); videoView.setPostNum(video.getPosts().size()); System.out.println(videoView); videoViews.add(videoView); } transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return videoViews; } @Override public VideoView queryVideoView(int videoID) { Session session = null; Transaction transaction = null; Query query = null; VideoView videoView = new VideoView(); try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); Video video = session.get(Video.class,videoID); video.setViewNum(video.getViewNum()+1); User user = video.getUser(); Find find = video.getFind(); videoView.setFind(find); videoView.setPostNum(video.getPosts().size()); videoView.setPraiseNum(video.getPraises().size()); videoView.setUser(user); videoView.setVideo(video); System.out.println(videoView); transaction.commit(); return videoView; } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return null; } @Override public List<VideoView> getVideoViewsByUserID(int userID) { List<VideoView> videoViews = new ArrayList<>(); Session session = null; Transaction transaction = null; Query query = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); User user = session.get(User.class, userID); query = session.createQuery("from Video where userID=? order by videoID desc"); query.setParameter(0, user.getUserID()); List<Video> videos = query.list(); for(Video video :videos) { VideoView videoView = new VideoView(); videoView.setVideo(video); videoView.setUser(user); videoView.setFind(video.getFind()); videoView.setPraiseNum(video.getPraises().size()); videoView.setPostNum(video.getPosts().size()); System.out.println(videoView); videoViews.add(videoView); } transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return videoViews; } @Override public int deleteVideo(int videoID, int userID) { Session session = null; Transaction transaction = null; Query query = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); String hql = "from Video v where videoID=? and userID=?"; query = session.createQuery(hql); query.setParameter(0, videoID); query.setParameter(1, userID); //query.executeUpdate(); Video video = (Video) query.list().get(0); session.delete(video); transaction.commit(); return 1; } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return 0; } }
PraiseDao
public class PraiseDaoImpl extends AbstractDao implements PraiseDao{ @Override public int addPraise(Praise praise,int videoID) { Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); Video video = session.get(Video.class, videoID); praise.setVideo(video); session.save(praise); transaction.commit(); return 1; } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return 0; } @Override public int queryPraise(User iUser, VideoView videoView) { Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); String hql = "from Praise where userID=? and videoID=?"; Query<Praise> query = session.createQuery(hql); query.setParameter(0, iUser.getUserID()); query.setParameter(1, videoView.getVideo().getVideoID()); List<Praise> praises = query.list(); transaction.commit(); return praises.size(); } catch (Exception e) { // TODO: handle exception } return 0; } }
PostDao
public class PostDaoImpl extends AbstractDao implements PostDao { @Override public List<PostView> getPostViews(int videoID) { List<PostView> postViews = new ArrayList<>(); Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); //Video video = session.get(Video.class, videoID); Query<Post> query = session.createQuery("from Post where videoID=? order by postID desc"); query.setParameter(0, videoID); List<Post> posts = query.list(); for(Post post:posts) { PostView postView = new PostView(); User user = post.getUser(); postView.setPost(post); postView.setUser(user); System.out.println(postView); postViews.add(postView); } transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return postViews; } @Override public int addPost(int videoID, int userID, String content) { Session session = null; Transaction transaction = null; Post post = new Post(); post.setDate(new Timestamp(new Date().getTime())); post.setContent(content); try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); Video video = session.get(Video.class, videoID); User user = session.get(User.class, userID); post.setVideo(video); post.setUser(user); session.save(post); transaction.commit(); return 1; } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return 0; }}
FollowDao
public class FollowDaoImpl extends AbstractDao implements FollowDao{ @Override public List<FollowView> queryFollows(int userID) { List<FollowView> followViews = new ArrayList<>(); Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); String hql = "from Follow f where f.user1=:user1"; User user = session.get(User.class, userID); Query<Follow> query = session.createQuery(hql); query.setParameter("user1",user ); List<Follow> follows = query.list(); for(Follow follow :follows) { FollowView followView = new FollowView(); followView.setFollow(follow); User user2 = follow.getUser2(); followView.setUser(user2); System.out.println(followView); followViews.add(followView); } transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return followViews; } @Override public int deleteFollow(User iUser, int userID2) { Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); User user1 = session.get(User.class, iUser.getUserID()); User user2 = session.get(User.class, userID2); String hql = "from Follow f where f.user1=:user1 AND f.user2=:user2"; Query<Follow> query = session.createQuery(hql); query.setParameter("user1",user1); query.setParameter("user2", user2); Follow follow = query.list().get(0); session.delete(follow); transaction.commit(); return 1; } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return 0; } @Override public long queryFollowedNum(int userID) { long num = 0; Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); User user = session.get(User.class, userID); String hql ="select count(*) from Follow f where f.user2=:user2"; Query query = session.createQuery(hql); query.setParameter("user2", user); num =(long) query.uniqueResult(); transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return num; } @Override public long queryFollowNum(int userID) { long num = 0; Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); User user = session.get(User.class, userID); String hql ="select count(*) from Follow f where f.user1=:user1"; Query query = session.createQuery(hql); query.setParameter("user1", user); num = (long) query.uniqueResult(); transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return num; } @Override public long getFollow(int userID1, int userID2) { long num = 0; Session session = null; Transaction transaction = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); User user1 = session.get(User.class, userID1); User user2 = session.get(User.class, userID2); String hql ="select count(*) from Follow f where f.user1=:user1 and f.user2=:user2"; Query query = session.createQuery(hql); query.setParameter("user1", user1); query.setParameter("user2", user2); num = (long) query.uniqueResult(); transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return num; } @Override public int addFollow(int userID1, int userID2) { int num = 0; Session session = null; Transaction transaction = null; Follow follow = new Follow(); try { session = HibernateUtil.getSessionFactory().getCurrentSession(); transaction = session.beginTransaction(); User user1 = session.get(User.class, userID1); User user2 = session.get(User.class, userID2); follow.setUser1(user1); follow.setUser2(user2); session.save(follow); transaction.commit(); } catch (Exception e) { e.printStackTrace(); if(transaction!=null) { transaction.rollback(); } } return num; } }
第六次作业 orm整合 接口的更多相关文章
- 17秋 软件工程 第六次作业 Beta冲刺 Scrum1
17秋 软件工程 第六次作业 Beta冲刺 Scrum1 各个成员冲刺期间完成的任务 重新梳理项目架构与当前进展,并且对我们的Alpha版本项目进行完整测试,将测试过程中发现的问题列入Github i ...
- 17秋 软件工程 第六次作业 Beta冲刺 Scrum2
17秋 软件工程 第六次作业 Beta冲刺 Scrum2 我们组转会成员:杰麟: 我们组新成员:宏庆. 各个成员冲刺期间完成的任务 世强:完成分页功能的演示: 陈翔:完成超级管理员后端login模块: ...
- 17秋 软件工程 第六次作业 Beta冲刺 Scrum3
17秋 软件工程 第六次作业 Beta冲刺 Scrum3 各个成员冲刺期间完成的任务 世强:完成手势签到模块,重构活动详情页面: 陈翔:完善超级管理员后端login模块,完成logout模块: 树民: ...
- 17秋 软件工程 第六次作业 Beta冲刺 Scrum4
17秋 软件工程 第六次作业 Beta冲刺 Scrum4 各个成员冲刺期间完成的任务 世强:完成APP用户签到模块.群发短信模块前端界面: 陈翔:恢复Github项目,完成Scrum博客: 树民:和超 ...
- C++第六次作业
前言 拿到作业的时候,整个人都不好了,虽然之前和同学说以后一起写游戏,画界面,然而现在的自己对界面的知识一窍不通,虽然同学分享了一些资料,但是通过这次作业,发现自己火候还是不够-- 问题描述及仓库地址 ...
- Week06《Java程序设计》第六次作业总结
Week06<Java程序设计>第六次作业总结 1. 本周学习总结 1.1 面向对象学习暂告一段落,请使用思维导图,以封装.继承.多态为核心概念画一张思维导图或相关笔记,对面向对象思想进行 ...
- 201621123080《java程序设计》第六周作业总结
201621123080<java程序设计>第六周作业总结 1. 本周学习总结 2. 书面作业 clone方法 1.1 在test1包中编写Employee类,在test2包中新建一个Te ...
- 【西北师大-2108Java】第六次作业成绩汇总
[西北师大-2108Java]第六次作业成绩汇总 作业题目 面向对象程序设计(JAVA) 第8周学习指导及要求 实验目的与要求 (1)掌握接口定义方法: (2)掌握实现接口类的定义要求: (3)掌握实 ...
- 《ABCD组》第六次作业:团队项目系统设计改进与详细设计
<ABCD组>第六次作业:团队项目系统设计改进与详细设计 项目 内容 这个作业属于哪个课程 http://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 ht ...
随机推荐
- [Node.js] 3、搭建hexo博客
一.安装新版本的nodejs和npm 安装n模块: npm install -g n 升级node.js到最新稳定版 n stable 二.安装hexo note: 参考github,不要去其 ...
- Netty 心跳服务之 IdleStateHandler 源码分析
前言:Netty 提供的心跳介绍 Netty 作为一个网络框架,提供了诸多功能,比如我们之前说的编解码,Netty 准备很多现成的编解码器,同时,Netty 还为我们准备了网络中,非常重要的一个服务- ...
- [Angularjs]cookie操作
摘要 现在很多app采用内嵌h5的方式进行开发,有些数据会存在webveiw的cookie中,那么如果使用angularjs开发单页应用,就需要用到angularjs的cookie操作.这里提供一个简 ...
- 我的菜单在母版页,如何更改菜单点击后的效果 Ver2
很久之前,Insus.NET使用ASP.NET实现一个功能,非javascript.<我的菜单在母版页,如何更改菜单点击后的效果>http://www.cnblogs.com/insus/ ...
- Java多线程--基础概念
Java多线程--基础概念 必须知道的几个概念 同步和异步 同步方法一旦开始,调用者必须等到方法调用返回后,才能执行后续行为:而异步方法调用,一旦开始,方法调用就立即返回,调用者不用等待就可以继续执行 ...
- oracle的学习笔记(转)
Oracle的介绍 1. Oracle的创始人----拉里•埃里森 2. oracle的安装 [连接Oracle步骤](](https://img2018.cnblogs.com/blog/12245 ...
- Power of Matrix(uva11149+矩阵快速幂)
Power of Matrix Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit St ...
- TCP/IP 基础简介
引言本篇属于TCP/IP协议的基础知识,重点介绍了TCP/IP协议簇的内容.作用以及TCP.UDP.IP三种常见网络协议相关的基础知识. 内容TCP/IP协议簇是由OSI七层模型发展而来的,之所以存在 ...
- HDU1824(2-SAT)
Let's go home Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 排序算法(8)--Merge Sorting--归并排序--Merge sort--归并排序
1.基本思想 归并排序是建立在归并操作上的一种有效的排序算法,该算法是采用分治法(Divide and Conquer)的一个非常典型的应用.将已有序的子序列合并,得到完全有序的序列:即先使每个子序 ...