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

重庆网站优化搜索引擎优化包括( )方面的优化

重庆网站优化,搜索引擎优化包括( )方面的优化,atp最新排名,做网站还要做点手机吗组合模式 1、组合模式解决这样的问题,当我们的要处理的对象可以生成一颗树形结构,而我们要对树上的节点和叶子进行操作时,它能够提供一致的方式,而不用考虑它是节点还是叶子。 示意图如下 2、 原理结构图 Data public abstrac…

组合模式

1、组合模式解决这样的问题,当我们的要处理的对象可以生成一颗树形结构,而我们要对树上的节点和叶子进行操作时,它能够提供一致的方式,而不用考虑它是节点还是叶子。
示意图如下
2、在这里插入图片描述

原理结构图
在这里插入图片描述

@Data
public abstract  class OrganizationComponent {//名字private String name;//说明private String description;protected void add(OrganizationComponent organizationComponent) {//默认实现throw new UnsupportedOperationException();}protected void remove(OrganizationComponent organizationComponent) {//默认实现throw new UnsupportedOperationException();}//构造器public OrganizationComponent(String name, String description) {this.name = name;this.description = description;}//方法打印 做成抽象的protected abstract void print();
}
@Slf4j
public class University extends OrganizationComponent {List<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();public University(String name, String description) {super(name, description);}//重写@Overrideprotected void add(OrganizationComponent organizationComponent) {organizationComponents.add(organizationComponent);}//重写@Overrideprotected void remove(OrganizationComponent organizationComponent) {organizationComponents.remove(organizationComponent);}//重写@Overrideprotected void print() {log.info("================大学【{}】================", getName());for (OrganizationComponent organizationComponent : organizationComponents) {organizationComponent.print();}}@Overridepublic String getName() {return super.getName();}@Overridepublic String getDescription() {return super.getDescription();}
}
@Slf4j
public class College extends OrganizationComponent {//List中存放的是departmentList<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();public College(String name, String description) {super(name, description);}//重写@Overrideprotected void add(OrganizationComponent organizationComponent) {//将来实际业务中,College的add方法和University的add方法不一定完全相同organizationComponents.add(organizationComponent);}//重写@Overrideprotected void remove(OrganizationComponent organizationComponent) {organizationComponents.remove(organizationComponent);}//重写@Overrideprotected void print() {log.info("============学院:{}=============", getName());for (OrganizationComponent organizationComponent : organizationComponents) {organizationComponent.print();}}@Overridepublic String getName() {return super.getName();}@Overridepublic String getDescription() {return super.getDescription();}
}
@Slf4j
public class Department extends OrganizationComponent {public Department(String name, String description) {super(name, description);}//重写【add,remove都不用再写了,因为他是叶子结点】@Overrideprotected void print() {log.info("专业:{}", getName());}@Overridepublic String getName() {return super.getName();}@Overridepublic String getDescription() {return super.getDescription();}
}
//============================
@Slf4j
public class Client {public static void main(String[] args) {//从大到小创建对象 学校OrganizationComponent university = new University("清华大学", "中国顶级大学");//创建学院College computerCollege = new College("计算机学院", "计算机学院");College infoEngineerCollege = new College("信息工程学院", "信息工程学院");//创建各个学院下的专业computerCollege.add(new Department("软件工程", "软件工程不错"));computerCollege.add(new Department("网络工程", "网络工程不错"));computerCollege.add(new Department("计算机科学与技术", "计算机科学与技术是一个老牌的专业"));infoEngineerCollege.add(new Department("通信工程", "通信工程不好学"));infoEngineerCollege.add(new Department("信息工程", "信息工程很好学"));university.add(computerCollege);university.add(infoEngineerCollege);university.print();}
}
  • 打印

大学【清华大学】
学院:计算机学院=
==专业:软件工程
==专业:网络工程
==专业:计算机科学与技术
学院:信息工程学院=
==专业:通信工程
==专业:信息工程

总结

1、简化客户端操作。客户端只需要面对一致的对象而不用考虑整体部分或者节点叶子的问题。
2、具有较强的扩展性。当我们要更改组合对象时,我们只需要调整内部的层次关系,客户端不用做出任何改动。
3、方便创建出复杂的层次结构,客户端不用理会组合里面的组成细节,容易添加剂诶单或者叶子从而创建出复杂的树形结构。
4、需要遍历组织机构,或者处理的对象具有树形结构时,非常适合使用组合模式。
5、要求较高的抽象性,如果节点和叶子有很大的差异性的话,比如很多方法和树形都不一样,不适用于组合模式。

jdk的HashMap使用到了组合模式


public interface Map<K,V> {//add  remove
}
static class Node<K,V> implements Map.Entry<K,V> {final int hash;final K key;V value;Node<K, V> next;
}public class HashMap<K,V> extends AbstractMap<K,V>implements Map<K,V>, Cloneable, Serializable {}
http://www.dtcms.com/a/419754.html

相关文章:

  • 助力工业转型升级 金士顿工博会大放异彩
  • 智慧校园智能一卡通管理系统的完整架构与功能模块设计,结合技术实现与应用场景,分为核心平台、功能子系统及扩展应用三部分
  • @[TOC](【笔试强训】Day02) # 1. ⽜⽜的快递(模拟) [题⽬链接: BC64 ⽜⽜的快递]
  • 广州魔站建站3d演示中国空间站建造历程
  • MySQL数据库——13.2.2 JDBC编程-鑫哥演示使用过程
  • AWS实战:轻松创建弹性IP,实现固定公网IP地址
  • 网站制作谁家好vps可以做wordpress和ssr
  • 全能企业网站管理系统Wordpress百万访问优化
  • 东南亚日本股票数据API对接文档
  • 吴*波频道推荐书单
  • 关于排查问题的总结
  • 优雅动听的歌曲之一-小城画师
  • 上海网站建设外包vi设计是设计什么东西
  • 做网站做国外广告竞价推广计划
  • 字节跳动多媒体实验室联合ISCAS举办第五届神经网络视频编码竞赛
  • 电商网站设计制作公司网站荣誉墙怎么做
  • 个人网站托管项目管理软件对比
  • 网站备案目的动感十足的网站
  • 自然语言处理——情感分析 <下>
  • 做长海报的网站临沂网站制作公司6
  • 设计模式(C++)详解——迭代器模式(4)
  • 北京市建设规划网站sem网络推广培训
  • 怎么让网站绑定域名访问不了南浔网站建设
  • Git怎么操作submodule的分支
  • 腾讯混元HunyuanImage-3.0 上线GitCode,首个工业级原生多模态开源模型
  • 网站设计策划wordpress移动端插件
  • 商城网站怎么建网站建设成本控制
  • 网站开发详细设计文档电商培训学校
  • 第一章 数据库系统基本概述
  • 【LangChain】P2 LangChain宏观架构深度解析:构建企业级大模型应用的首选框架