功能设计源码以及思路-字典篇

【华为OD机考真题】- 查字典(B卷)(Java) 🔔本文收录于「2025华为OD机试真题(Java版)」专栏,手把手带你零基础教学华为OD机试。本题集提供最优题解思路,解题步骤,代码解析,复杂度分析及最优题解源码等,支持多语言题解,助你轻松拿捏OD机考,一举上岸!安利大家关注&&收藏&&订阅!题库正在疯狂收录中,up!up!up!! 🚫提醒:拒绝一切代考/替考,违法必究!    💗订阅福利:一次订阅,可永久免费阅读,提供在线答疑解惑,后续题库更新皆可阅读使用! 阅读详情
功能说明:在项目中,将一些简单的需要高频率的使用的字段加载在缓存中,减少与数据库的连接!
具体设计:
  总体分为两块:
              第一块是数据的加载:
          1,首先是xml
  <servlet>
  <servlet-name>dhservlet</servlet-name>
  <servlet-class>***.***.cache.servlet.DictionaryHelperServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>

 2然后是该指定类:
     public class DictionaryHelperServlet extends HttpServlet{
 /**
  * 系统启动初始化加载字典缓存
  */
 @Override
 public void init() throws ServletException {
  DictionaryHelper dictionaryHelper = new DictionaryHelper();
  dictionaryHelper.joinCache();
 }
 @Override
 public void doPost(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
  doPost(request, response);
 }
 @Override
 public void doGet(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
  // TODO Auto-generated method stub
  doPost(request, response);
 }
}


3然后在调用数据库中的数据存入缓存中
public class DictionaryHelper {
 private int t = 0;
 /**
  * 加入缓存
  */
 public void joinCache(){
  Map map = getDictCacheMap();
  LoginCache.put(LoginConfig.USER_DICTIONARY_HELPER, LoginConfig.DICTIONARY_HELPER, map, 3600);
 }
 
 public static String toJson(String dictId){
  DictionaryHelper dh = new DictionaryHelper();
  return StringUtil.getSelectJson(dh.getDictById(dictId), false);
 }
 
 /**
  * 重新封装字典
  * @return
  */
 private Map getDictCacheMap(){
  Map<String,List<DictDataInfo>> retMap = new HashMap<String, List<DictDataInfo>>();
  List<DictManagerInfo> dmList = getDictionaryHelper();
  List<DictDataInfo> ddList = getDictInfoList();
  if(dmList != null){
   List<DictDataInfo> retList = null;
   for (int i = 0; i < dmList.size(); i++) {
    DictManagerInfo managerInfo = dmList.get(i);
    for(int j = 0; j < ddList.size(); j++){
     DictDataInfo dataInfo = ddList.get(j);
     if(managerInfo.getDict_code().equals(dataInfo.getDict_code())){
      retList = retMap.get(managerInfo.getDict_code());
      if(retList == null){
       retList = new ArrayList<DictDataInfo>();
      }
      retList.add(dataInfo);
      System.out.println("a"+managerInfo.getDict_code());
      retMap.put(managerInfo.getDict_code(), retList);
     }
    }
   }
  }
  return retMap;
 }
 
 /**
  * 取所有父字典信息
  * @return
  */
 private List<DictManagerInfo> getDictionaryHelper(){
  CompService com = BaseDAOFactory.getCompService();
  Map dictmap = (Map)com.invoke("DictManagerData", "getDictManagerLists");
  String rnt = "";
  if(dictmap!=null){
   rnt = StringUtil.toString(dictmap.get("rnt"));
  }
  List<DictManagerInfo> list = null;
  if("1".equals(rnt)){
   list = (List<DictManagerInfo>) dictmap.get("dmList");
  }
  return list;
 }
 
 /**
  * 取所有子字典信息
  * @return
  */
 private List<DictDataInfo> getDictInfoList(){
  CompService com = BaseDAOFactory.getCompService();
  Map dictmap = (Map)com.invoke("DictManagerData", "getAllDictDataInfo");
  String rnt = "";
  if(dictmap!=null){
   rnt = StringUtil.toString(dictmap.get("rnt"));
  }
  List<DictDataInfo> list = null;
  if("1".equals(rnt)){
   list = (List<DictDataInfo>) dictmap.get("ddList");
  }
  return list;
 
 }
 
 
 
 /**
  * 取字典缓存
  * @return
  */
 private Map getDictCacheList(){
  Map dictmap = (Map) LoginCache.get(LoginConfig.USER_DICTIONARY_HELPER, LoginConfig.DICTIONARY_HELPER);
  if(dictmap == null){
   joinCache();
   t ++;
   if(t < 3){
    return getDictCacheList();
   }
  }
 
  return dictmap;
 }
 
 
 /**
  * 查询指定表的信息,返回的两列数据作为菜单的optionValue 和optionText
  * @param tableTag 要查询的表的别名
  * @param optionValue optionValue的列名
  * @param optionText optionText的列名
  * @param filterSql 其他约束条件 缺省值是“1=1”
  * @return
  */
 public List<CustomDictInfo> getCustonDict(String tableTag,String optionValue,String optionText,String filterSql){
  List<CustomDictInfo> list = null;
 
  if(tableTag!=null && !"".equals(tableTag)){
   if(filterSql==null || "".equals(filterSql)){
    filterSql = " 1=1 ";
   }
   CompService com = BaseDAOFactory.getCompService();
   com.addParameter(tableTag);
   com.addParameter(optionValue);
   com.addParameter(optionText);
   com.addParameter(filterSql);
   Map dictmap = (Map)com.invoke("DictionaryHelperData", "getCustomDictList");
   String rnt = "";
   if(dictmap!=null){
    rnt = StringUtil.toString(dictmap.get("rnt"));
   }
   if("1".equals(rnt)){
    list = (List<CustomDictInfo>) dictmap.get("cdList");
   }
  }
 
 
  return list;
 }
 
 
 
 
 /**
  * 根据父字典ID查询子项列表
  * @param dictId
  * @return
  */
 public List<DictDataInfo> getDictById(String dictId){
  Map dictmap = getDictCacheList();
  List<DictDataInfo> dataInfos = (List<DictDataInfo>) dictmap.get(dictId);
  return dataInfos;
 }
 
 /**
  * 根据父字典ID和子字典ID查询文本内容
  * @param dictId
  * @param id
  * @return
  */
 public String getDictTextById(String dictId,String id){
  Map dictmap = getDictCacheList();
  List<DictDataInfo> dataInfos = (List<DictDataInfo>) dictmap.get(dictId);
  String text = "";
  if(dataInfos != null){
   for (int i = 0; i < dataInfos.size(); i++) {
    DictDataInfo dataInfo = dataInfos.get(i);
    if(id.equals(dataInfo.getDict_small_code())){
     text = dataInfo.getDict_text();
     break;
    }
   }
  }
  return text;
 }
 
 
 /**
  * 根据父字典ID和子字典文本内容查询子字典ID
  * @param dictId
  * @param id
  * @return
  */
 public String getDictIdByText(String dictId,String text){
  Map dictmap = getDictCacheList();
  List<DictDataInfo> dataInfos = (List<DictDataInfo>) dictmap.get(dictId);
  String id = "";
  if(dataInfos != null){
   for (int i = 0; i < dataInfos.size(); i++) {
    DictDataInfo dataInfo = dataInfos.get(i);
    if(text.equals(dataInfo.getDict_text())){
     id = dataInfo.getDict_code();
     break;
    }
   }
  }
  return id;
 }
 /**
  * 加入缓存
  * @return
  */
 public void setDictInfo(DictDataInfo dataInfo){
  if(dataInfo != null){
   Map dictmap = getDictCacheList();
   String dictid = dataInfo.getParient_id();
   String id = dataInfo.getDict_code();
   List<DictDataInfo> dataInfos = (List<DictDataInfo>) dictmap.get(dictid);
   if(dataInfos != null){
    boolean b = true;
    for (int i = 0; i < dataInfos.size(); i++) {
     DictDataInfo info = dataInfos.get(i);
     if(id.equals(info.getDict_code())){
      b = false;
      break;
     }
    }
    if(b){
     dataInfos.add(dataInfo);
    }
    LoginCache.remove(LoginConfig.USER_DICTIONARY_HELPER, LoginConfig.DICTIONARY_HELPER);
    LoginCache.put(LoginConfig.USER_DICTIONARY_HELPER, LoginConfig.DICTIONARY_HELPER, dictmap, 3600);
   }
  }
 }
 
 /**
  * 修改缓存字典内容
  * @param dataInfo
  */
 public void modifyDictInfo(DictDataInfo dataInfo){
  if(dataInfo != null){
   Map dictmap = getDictCacheList();
   String dictid = dataInfo.getParient_id();
   String id = dataInfo.getDict_code();
   List<DictDataInfo> dataInfos = (List<DictDataInfo>) dictmap.get(dictid);
   if(dataInfos != null){
    boolean b = false;
    for (int i = 0; i < dataInfos.size(); i++) {
     DictDataInfo info = dataInfos.get(i);
     if(id.equals(info.getDict_code())){
      dataInfos.remove(i);
      b = true;
      break;
     }
    }
    if(b){
     dataInfos.add(dataInfo);
    }
    LoginCache.remove(LoginConfig.USER_DICTIONARY_HELPER, LoginConfig.DICTIONARY_HELPER);
    LoginCache.put(LoginConfig.USER_DICTIONARY_HELPER, LoginConfig.DICTIONARY_HELPER, dictmap, 3600);
   }
  }
 }
 
 /**
  * 删除缓存字典内容
  * @param dataInfo
  */
 public void removeDictInfo(String dict_id,String id){
  if(dict_id != null && !"".equals(dict_id) && id != null && !"".equals(id)){
   Map dictmap = getDictCacheList();
   List<DictDataInfo> dataInfos = (List<DictDataInfo>) dictmap.get(dict_id);
   if(dataInfos != null){
    for (int i = 0; i < dataInfos.size(); i++) {
     DictDataInfo info = dataInfos.get(i);
     if(id.equals(info.getDict_code())){
      dataInfos.remove(i);
      break;
     }
    }
    LoginCache.remove(LoginConfig.USER_DICTIONARY_HELPER, LoginConfig.DICTIONARY_HELPER);
    LoginCache.put(LoginConfig.USER_DICTIONARY_HELPER, LoginConfig.DICTIONARY_HELPER, dictmap, 3600);
   }
  }
 }
 
 public static void main(String[] args) {
  DictionaryHelper dh = new DictionaryHelper();
  DictDataInfo dataInfo = new DictDataInfo();
  dataInfo.setParient_id("anticoagulant");
  dataInfo.setDict_text("sssssssssssssssssss");
  dataInfo.setDict_code("sda");
  dh.setDictInfo(dataInfo);
 
 
  List<DictDataInfo> list = dh.getDictById("anticoagulant");
  for (int i = 0; i < list.size(); i++) {
   DictDataInfo d = list.get(i);
   System.out.println(d.getDict_text());
  }
 
  String text = dh.getDictIdByText("anticoagulant", "无肝素");
  System.out.println("text:"+text);
 
  String id = dh.getDictTextById("sys_sex", "1");
  System.out.println("id:"+id);
 }
}





public class LoginCache {
 private static CacheManager singleton = CacheManager.getInstance();
 /**
  * 存入缓存
  * @param cacheName 主缓存名称
  * @param key 子缓存主键名称
  * @param value 需要缓存的数据
  * @param timeToIdleSeconds 缓存时间
  */
 public static synchronized void put(String cacheName, Object key, Object value, int timeToIdleSeconds){
  Cache cache = null;
  if(StringHelper.isEmpty(cacheName)){
   return;
  }
  if(key == null){
   return;
  }
  if(!singleton.cacheExists(cacheName)){
   singleton.addCache(cacheName);
   cache = singleton.getCache(cacheName);
  }
  cache = singleton.getCache(cacheName);
 
  Element e = new Element(key, value);
  e.setTimeToIdle(timeToIdleSeconds);
  cache.put(e);
 
 }
 
 /**
  * 根据主键缓存获取全部缓存内容
  * @param cacheName 主键
  * @return
  */
 public static synchronized List<Map> getAllUserMessage(String cacheName){
  List<Map> userlist = null;
  try{
   Cache cache = null;
   if(StringHelper.isEmpty(cacheName)){
    return userlist;
   }
   if(!singleton.cacheExists(cacheName))
    return null;
   cache = singleton.getCache(cacheName);
   List list = cache.getKeys();
   if(list != null && list.size() > 0){
    userlist = new ArrayList<Map>();
    int s = list.size();
    for (int j = 0; j < s; j++) {
     String key = (String)list.get(j);
     Element e = cache.get(key);
     if(e != null){
      Map user = (Map)e.getObjectValue();
      if(user != null)
       userlist.add(user);
     }
    }
   
   }
  }catch(Exception e){
   e.printStackTrace();
  }
  return userlist;
 }
 
 /**
  * 删除子项缓存
  * @param cachename 主键缓存名称
  * @param key 子项缓存名称
  */
 public static synchronized void remove(String cachename, Object key){
  try{
   if(StringHelper.isEmpty(cachename)){
    return;
   }
   if(!singleton.cacheExists(cachename)){
    return;
   }
   Cache cache = singleton.getCache(cachename);
   cache.remove(key);
  }catch(Exception e){
   e.printStackTrace();
  }
 }
 
 /**
  * 获取缓存
  * @param cachename 主键缓存名称
  * @param key 子项缓存名称
  * @return
  */
 public static Object get(String cachename,Object key){
  Object o = null;
  if(!singleton.cacheExists(cachename)){
   return o;
  }
  Cache cache = singleton.getCache(cachename);
  if(!cache.isKeyInCache(key)){
   return o;
  }
  Element e = cache.get(key);
  if(e != null)
   o = e.getObjectValue();
  return o;
 }
 
 /**
  * 获取缓存子项
  * @param cachename 主键缓存名称
  * @return
  */
 public static Ehcache getCache(String cachename){
  Cache cache = null;
  if(!singleton.cacheExists(cachename)){
   return cache;
  }
  cache = singleton.getCache(cachename);
  return cache;
 }
}


4在项目应用中,调用该类的changeDictValWithBeanList()方法,将数据库中的比如(1,2,3等数字)转化成对应的字典数据


/**
 * 测试处理Bean多列字典的问题
 * @author DongChao
 *
 */
public class DictionaryUtil {
 
 /**
  * 依次将beanList中的项目(beanParams)用指定的字典(dictNames)替换
  * beanParams 的顺序要和dictNames一致
  * @param beanList
  * @param beanParams
  * @param dictNames
  * @return
  */
 public static List changeDictValWithBeanList(List beanList,String [] beanParams,String[] dictNames){
 
  DictionaryHelper dh = new DictionaryHelper();
 
  if(beanList!=null && beanList.size()>0){// 入股list为空,无法处理,原样返回list
   
   if(beanParams==null){//如果参数名为空则无法处理,原样返回list
    return beanList;
   }if(dictNames==null){//如果字典为空则无法处理,原样返回list
    return beanList;
   }
   if(beanParams.length!=dictNames.length){//bean的内容和字典数量不匹配则无法处理,原样返回list
    return beanList;
   }
   
   HashMap paramsAndDicts = StringArrToHashMap(beanParams,dictNames);
   
   for(int i=0;i<beanList.size();i++){
    Object bean = beanList.get(i);
    PropertyDescriptor[] props = null;
    try {
     props = Introspector.getBeanInfo(bean.getClass(), Object.class).getPropertyDescriptors();
    } catch (IntrospectionException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
   
    if (props != null) {
     
      for(int j=0;j<props.length;j++){
       String name = props[j].getName();//bean中的成员变量的名字
       //Arrays.sort(beanParams);
       String dictName = (String)paramsAndDicts.get(name);
       
       if(dictName!=null && !"".equals(dictName)){
       
       
        //取出原始值
        try {
        String oriaValue = props[j].getReadMethod().invoke(bean).toString() ;
       
         //将value转换成字典的文本值
        //System.out.println(dictName+"=="+oriaValue);
         String dictText=dh.getDictTextById(dictName, oriaValue);
         //将转换后的文本写会到Bean中
         Method methodSet=props[j].getWriteMethod();
         methodSet.invoke(bean, dictText);
       } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
       } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
       } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
       }
       
       
       
       }
       
       
       
     
      }
     
     
    }
   
   
   }
  }
 
 
  return beanList;
 }
 
 
 private static HashMap StringArrToHashMap(String [] beanParams,String[] dictNames){
  HashMap map = new HashMap();
  for(int i=0;i<beanParams.length;i++){
   map.put(beanParams[i], dictNames[i]);
  }
  return map ;
 }
}


5.实际的调用的例子:
DictionaryUtil dt = new DictionaryUtil();
    String []beanParams = new String []{"sex","blood_type","rh_blood_type","charge_type","insurance_type","patient_state"};
    String []dictNames = new String []{"sys_sex","sys_blood_type","sys_rh_blood_type","sys_charge_type","sys_insurance_type","sys_patient_state"};
    list = dt.changeDictValWithBeanList(list, beanParams, dictNames);//获取缓存中对应的数据值
    DictionaryHelper dh = new DictionaryHelper();

华为OD机试 - 查字典(Java 2024 E卷 100分) 本专栏包含了最新最全的2023年华为OD机试真题,有详细的分析和Java解答。已帮助1000+同学顺利通过OD机考。专栏会持续更新,每天在线答疑。输入一个单词前缀和一个字典,输出包含该前缀的单词。这道题简直就是送分题,送分题一定不能出错。所有包含该前缀的单词,多个单词换行输出。1、单词前缀长度 阅读详情

相关推荐

Python:实现第k个字典排列算法(附完整源码)

Python:实现第k个字典排列算法(附完整源码)

希望我的博客,能帮上你解决学习中工作中所遇到的问题 457

数据字典前后端代码的编写

数据字典用于存放数据,存放那些当主体有很多的属性,每种属性有很多的取值的数据,如果对于每个属性都为它建立一张表时,不利于数据的管理和增加了主体和属性的耦合度。如每种属性的取值用下拉选择的形式把数据写死到选项里,又不利于后面添加属性的取值。因此使用数据字典的优点有:在一定程度上,通过系统维护人员即可改变系统的行为(功能),不需要开发人员的介入。使得系统的变化更快,能及时响应客户和市场的需求。提高了系统的灵活性、通用性,减少了主体和属性的耦合度简化了主体类的业务逻辑。

weixin_54226626的博客 1799

MySQL数据字典制作工具

好用好用好用好用好用好用好用好用好用好用好用好用好用好用好用好用好用好用

springboot 数据字典设计思路:字典表+字典枚举 两者兼故方案

springboot 数据字典设计思路:字典表+字典枚举 两者兼故方案,查询返回结果在controller方法上添加注解进行字典翻译

mxskymx的专栏 9619

Unity - gamma space下还原linear space效果

还有头发之后的 (头发没有处理完整,因为使用 ASE 连连看练出来的,使用 surface shader,虽然可以生成一下 vert, frag 的方式在修改,但是我懒得去修改了,这样就是 PBR 的 BRDF 里面的部分曲线是不一样的,所以可以看到头发有一些差异)其实上面的代码判断 是否有分量 > 1.0f 的方式来判断是否 HDR 是不太合理的,因为不同的贴图格式的编码方式不同。还有比较隐蔽的一些颜色相关的常量值 (比如PBR中的 绝缘体的 F0 常量值,等等)

Jave.Lin 的学习笔记 2829

ZYNQ通过AXI DMA实现PL发送连续大量数据到PS DDR

方案二是在PS端的MPU配置中,将DMA缓冲区所在的内存区域标记为“不缓存”(Device或Strongly Ordered类型),但这样CPU访问这些内存区的速度会大幅降低,需要根据实时性和数据正确性的需求做权衡。更妙的是,描述符链表可以做成一个环状队列,放在DDR里让DMA循环取走,从而实现持续不断的“流式”传输。用FPGA实现FFT硬件加速的系统中也是如此:PS向PL提交待处理的FFT数据,PL硬件加速计算后,DMA把结果写回DDR,全程CPU几乎只做配置调度,大量数据吞吐留给了硬件通道。

QQ_778132974的博客 171

数据字典表设计

数据字典 1.需求 在开发中数据字典常被用于行业、省市区等下拉选业务中。 以下图为例,我们需要设计一个公共的数据字典表以适用于行业、省市区等多种类型的多级连带的下拉选业务 2.表机构设计 id varchar 32 主键 name varchar 32 枚举名称 value varchar 32 枚举值 type varchar 32 枚举类型 grade int 1 等级(1:一级,2:二级,3:三级依次类推) sort int 11 排序 pid varchar

爱笑的boy的博客 1万+

Python 爬虫教程:抓取视频平台数据(观看量、评论数、点赞数等)

爬虫(Crawler)是通过编写程序模拟浏览器行为,从互联网上抓取并提取信息的技术。爬虫的核心任务是模拟用户访问网页,获取网页内容并解析出我们需要的数据。爬虫技术被广泛应用于搜索引擎、数据分析、电商价格监控、内容抓取等领域。Bilibili和YouTube。这两个平台都提供丰富的用户生成内容(UGC),且在中国和全球范围内都非常流行。Bilibili:以二次元文化为主的视频平台,用户活跃,视频内容丰富。Bilibili的网页数据较为简单,可以通过传统的HTML解析抓取。YouTube。

2201_76125261的博客 1854

MySQL表设计---字典表的设计与接口实现

但此时有新的问题了,国籍、学历也是可以枚举完的字段,那再加个学历类型表?字典中定义好数据了,再写一个对应于dict_type的枚举类,枚举类中定义值,方便后面代码中调用枚举值做业务处理。定义接口,查询不同类型下的字典的key和value,给前端展示(当然前端也可以用html定义下拉框选项写死几个)中查,如果有,直接返回,如果缓存中没有,则调mapper层去数据库查,并把结果查询结果写进缓存备用。基于以上一个简单的背景,来看若依框架提供的字典表结构:ruoyi有两张字典相关表,一个。,将字典定义和数据分开。

llg___的博客 2万+

Python爬虫实战:高德地图POI信息爬取(餐馆/加油站等),附选址分析技巧

高德API配置AMAP_KEY = "你的高德API Key" # 替换成自己的Key# 爬取参数CITY = "成都" # 城市DISTRICTS = ["锦江区"] # 区域,可添加多个(比如["锦江区", "武侯区"])KEYWORDS_LIST = ["川菜馆", "加油站"] # 要爬取的POI类型TYPES = {"川菜馆": "050101", # 餐饮服务→中餐→川菜馆(高德POI分类编码)"加油站": "110100" # 交通设施→加油站。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 2467

作为一名爬虫人如何实现千万级数据爬取?

爬虫门槛不高,高就高在往后余生的每一次实操都随时会让你崩溃!Bro

吴秋霖的博客 1万+

浅谈通用的字典表结构设计

应该绝大多数系统都需要字典表吧,或许不叫这个名字,值集,枚举表等等。当然,java中有枚举类,能够将一部分不涉及到更新的枚举值配置其中,但大部分涉及到维护的数据,或者是通用的数据,如国家省市值,这个表数据状态值,配置到字典表里面都是非常好的选择。 在这里,我们就使用比较有名的项目ruoyi提供的字典表DDL来简单分享一下。ruoyi有两张字典相关表,一个字典类型表,一个字典数据表,将字典定义和数据分开,我也非常赞同这种设计。当然,也有些系统就用一张表代替,第一层存字典类型,即定义,后一层存数据。 字典类.

Rosen's 1万+

OpenClaw-遇到的问题-Health check failed: gateway closed (1006 abnormal closure (no close frame)): no clos

OpenClaw网关服务安装成功但运行异常,显示健康检查失败(错误代码1006)。系统提供了Web控制界面(http://127.0.0.1:18789/)和带令牌的安全访问链接。文档建议参考故障排除指南,并提供了可选应用扩展功能(包括移动端支持)。注意运行本地代理存在安全风险,建议加固系统配置。若需启用网络搜索功能,需配置Brave搜索API密钥。安装完成后会自动打开仪表盘,需保持浏览器标签页以控制OpenClaw服务。

直到世界的尽头 1万+

若依(ruoyi)字典管理插件实现思路探究

若依(ruoyi)字典管理插件实现思路探究

siweidetu的专栏 1万+

PHP与Node.js的对比及优缺点分析

PHP和Node.js是两种常用的服务器端编程语言,它们在不同的应用场景下各有优势和劣势。本文将全方位比较PHP和Node.js的特点,以及它们在编程中的优缺点,并提供相应的源代码示例供参考。需要注意的是,本文只是对PHP和Node.js的一些优缺点进行了简要介绍,实际应用中还需要考虑其他因素,如团队经验、项目规模和预算等。最终的选择应该基于全面的评估和需求分析。PHP:PHP是一种同步阻塞的编程语言,它的处理方式是一次只处理一个请求。Node.js:Node.js的性能较高,特别适合处理高并发的请求。

ByteSparkX的博客 887

tsmc12:via0的spacing问题(Via0.S.1)

12nm有个via0 grid的概念,除了普通fill外,基本都有via0这一层,这一层需要与via0 grid对齐。手动调整cell的位置比较容易出这个drc,比如修m0po max length drc时。解决方法1: 替换EEQV类型cell,这种类型是专门为了修via0 Grid问题存在的。更多学习内容请关注「拾陆楼」知识星球。解决方法2: 翻转或移动。

m0_61544122的博客 1115

redis学习记录:字典(dict)源码分析

redis字典(dict)部分源码分析。

这里是河边 1067

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

Redis源码解析——字典结构

C++语言中有标准的字典库,我们可以通过pair(key,value)的形式存储数据。但是C语言中没有这种的库,于是就需要自己实现。本文讲解的就是Redis源码中的字典库的实现方法。(转载请指明出于breaksoftware的csdn博客) 一般情况下,我们谈到字典,难免要谈到红黑树。但是Redis这套字典库并没有使用该方案去实现,而是使用的是链表,且整个代码行数...

方亮的专栏 3106

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

思路+源码,利用Python破解WIFI密码详解,100M的字典已备好

前言 WIFI破解,Python程序员必学技能。WIFI已经完全普及,现在Python程序员没网,走到哪里都不怕! 想要WIFI破解,python+字典,这是是少不了的。热点加弱口令也是核心。字典自己加精,你的字典有强大,你能破解的WIFI就越多。 私信小编001即可获取大量Python学习资料! 原理 就是操纵网卡,一个一个的试密码本上的密码,直到密码正确,这时电脑也会连上这个wifi。 Python脚本就是对密码本中的密码,一个一个的尝试,如果密码正确,那么就建一个名字为wifi名字的文件,并把.

管彤python每日分享python技巧 3万+

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Redis源码阅读(二)字典

/ 底层数组// 元素数量// 修改次数,用于快速失败机制// 扩容阈值// 负载因子// 基本节点类型V value;// 红黑树节点// ...特性Redis 字典影响冲突解决链表 + 红黑树仅链表Java在高冲突情况下性能更稳定扩容方式一次性渐进式Redis操作延迟更一致负载因子默认0.75可调整,强制阈值为5Java空间效率更高内存分配连续数组两个哈希表Redis在rehash期间内存占用更高随机访问不支持。

Jerry的博客 1065

Java 数据字典的实现

记得第一次接触数据字典还是第一个项目,是用简单的hashmap实现了,现在做一个笔录吧,8年之久了,

专注Java(全栈)应用开发,求知若渴,虚心若愚,talk is cheap, show me the code. 4302

字典树

在我们的网络生活中,处处都有热搜的身影,这天某某某递出了律师函,那天某站又泄露了源码,等等 那么,这个热搜是怎么实现的呢? 一种办法,我可以用一种数组,下标是关键词,然后键值是被搜索的次数,然后每次被检索后都进行一次排序,emmm,这种办法虽然简单,但是时间复杂度和空间复杂度都很大,如果应用到现实生活中,没有什么效率, 那么我们有更好的办法吗?当然是有的,在网上找的资料上,可以用很多中方法实现,这...

I_AM_jm的博客 4261

Redis源码分析(三)—— 字典的设计与实现

前言 字典是一种用于保存键值对的数据结构,Redis数据库使用字典做为底层实现,字典也是哈希键的底层实现之一。 C语言中并没有内置字典这个数据结构,Redis自己实现了字典。 以下结合源码分析Redis字典的设计与实现,源码版本:Redis 6.0.10 问题思考 C语言中如何设计一个通用的字典和哈希表? 字典的设计与实现 哈希表和哈希表节点的设计 字典的数据结构设计 如何设计多态字典 哈希算法 为什么数组长度设计为2的n次方 如何解决键冲突 rehash操作 为什么要rehash

pcj_888的博客 1101

Java:实现 trie字典树算法(附带源码)

Java:实现 trie字典树算法(附带源码)

欢迎来到我的博客!这里是一个专注于计算机技术的分享平台,涵盖编程开发、算法研究、系统架构、软件工程等多个领域。无论你是初学者还是资深开发者,都能在这里找到有价值的内容。 1565

C源码:生成一个自己的口令字典

使用一个单词文件,本程序只考虑单个单词的大小写变形和两个变形单词的组合,由此生成一个字典, 例如对于hello和unix两个单词的单词文件,本程序可生成: hello Hello HELLO unix Unix UNIX hellounix helloUnix helloUNIX Hellounix HelloUnix HelloUNIX HELLOunix HELLOUnix HELLOUNIX

halfstudio的专栏 1327
上一篇: 自我检讨
下一篇: 功能设计源码以及思路-图片上传篇
breaknull
博客等级 码龄14年 15粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值