精华内容
下载资源
问答
  • Given a string, find the length of the longest substring without repeating characters. class Solution { public: int lengthOfLongestSubstring(string s) { map<char,int> record; ...

    Given a string, find the length of the longest substring without repeating characters.

    class Solution {
    public:
        int lengthOfLongestSubstring(string s) {
            map<char,int> record;
            int len = 0;
            for(int i = 0, j = 0; j < s.length(); j ++)
            {
                if(record.find(s[j]) != record.end())
                {
                    i = max(i,record[s[j]] + 1);
                }
                record[s[j]] = j;
                len = max(len,j - i + 1);
            }
            return len;
        }
    };
    

     

    展开全文
  • Category用法

    2015-07-18 00:27:50
    今天给大家介绍一下我们常说的Category的详细用法,首先引用API文档的一段话: You use categories to define additional methods of an existing class—even one whose source code is unavailable to you—...

    今天给大家介绍一下我们常说的Category的详细用法,首先引用API文档的一段话:

    You use categories to define additional methods of an existing class—even one whose source code is unavailable to you—without subclassing.

    从这段话中我们可以看出Category(范畴)的本质:  
    在不需要继承一个父类的情况下来实现另外的类中的某些方法,哪怕那个类的源代码不是开源的。
    那么说到源代码不开源,我们首当其冲地就想到了iOS的SDK(也就是Cocoa Touch 框架),我们只能查看他们的头文件声明但是不能查看.m文件的实现。所以范畴用的比较多的情况就是在我们自己的类中去实现SDK中某个类的既有方法。
    当然我们也可以在我们自己写的两个类中间使用category,这种情况一般有两种:
    1.当我们一个类过于庞大的时候我们可以将它拆分成若干个category,在各个category的.m文件中去实现,这样避免主类的.m实现文件过长和混乱。
    2.声明私有方法。

    这些都应该好理解的,可能我的描述也有一些地方不够精确,但应该没有大的偏差,主要是用的时候理解对就行了。我们来看看category的声明方式:


    <a target=_blank id="L1" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a>
    <a target=_blank id="L2" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a>
    <a target=_blank id="L3" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a>
    <a target=_blank id="L4" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a>
    <a target=_blank id="L5" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a>
    #import "SystemClass.h" //这里的.h文可能是某些我们无法查看.m源文件的类的头文件声明,就是我刚刚说的第一种情况
    @interface SystemClass (CategoryName) //这里的()括起来的地方就是我们Category(范畴)的名字了,在SDK源代码中或者XMPPFramework中我们也经常看到这种声明
    // 在这里声明你要实现的方法
    @end
     来自CODE的代码片
    category1


    然后是名字了,如果我们写好了一个范畴,比如叫做ObjecoderCategory,引用的Class叫做UITableView ,那么我们的Category的源文件名字就应该是UITableView+ObjecoderCategory.h .这在我们的XMPPFramework中的扩展类中,例如XMPPMessage+XEP0045,大家应该不陌生吧:

    <a target=_blank id="L1" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;">  1</a>
    <a target=_blank id="L2" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;">  2</a>
    <a target=_blank id="L3" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;">  3</a>
    <a target=_blank id="L4" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;">  4</a>
    <a target=_blank id="L5" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;">  5</a>
    <a target=_blank id="L6" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;">  6</a>
    <a target=_blank id="L7" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;">  7</a>
    <a target=_blank id="L8" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;">  8</a>
    <a target=_blank id="L9" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;">  9</a>
    <a target=_blank id="L10" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L10" rel="#L10" style="color: rgb(102, 102, 102); text-decoration: none;"> 10</a>
    #import <Foundation/Foundation.h>
    #import "XMPPMessage.h"
    @interface XMPPMessage(XEP0045)
    - (BOOL)isGroupChatMessage;
    - (BOOL)isGroupChatMessageWithBody;
    @end
     来自CODE的代码片
    category2



    如果你是想用Category声明私有方法,那么只需要在你的类的.h文件的@implementation标记前面加上这个Category的声明即可了,不需要单独去创建新的xxx+xxx.h文件,这个跟我们的@protocal写法很类似,例如:


    <a target=_blank id="L1" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a>
    <a target=_blank id="L2" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a>
    <a target=_blank id="L3" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a>
    <a target=_blank id="L4" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a>
    <a target=_blank id="L5" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a>
    <a target=_blank id="L6" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L6" rel="#L6" style="color: rgb(102, 102, 102); text-decoration: none;"> 6</a>
    <a target=_blank id="L7" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L7" rel="#L7" style="color: rgb(102, 102, 102); text-decoration: none;"> 7</a>
    <a target=_blank id="L8" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L8" rel="#L8" style="color: rgb(102, 102, 102); text-decoration: none;"> 8</a>
    <a target=_blank id="L9" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L9" rel="#L9" style="color: rgb(102, 102, 102); text-decoration: none;"> 9</a>
    #import "MyClass.h"
    @interface MyClass (PrivateMethods)
    // PrivateMethods范畴的私有方法声明
    @end
    @implementation MyClass
    // 普通方法的声明
    @end
     来自CODE的代码片
    category3



    除开这个,我们更为普通的情况是我们如果基于一个无法查看源代码的类之上写了一个Category,这个时候我们由于没有"父类"的.m文件的查看和修改权利,所以我们只有创建一个xxxx+xxxx.h/.m文件在里面实现Category的扩展方法,实现方式如下:
    <a target=_blank id="L1" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L1" rel="#L1" style="color: rgb(102, 102, 102); text-decoration: none;"> 1</a>
    <a target=_blank id="L2" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L2" rel="#L2" style="color: rgb(102, 102, 102); text-decoration: none;"> 2</a>
    <a target=_blank id="L3" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L3" rel="#L3" style="color: rgb(102, 102, 102); text-decoration: none;"> 3</a>
    <a target=_blank id="L4" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L4" rel="#L4" style="color: rgb(102, 102, 102); text-decoration: none;"> 4</a>
    <a target=_blank id="L5" href="http://blog.csdn.net/mobanchengshuang/article/details/10631581#L5" rel="#L5" style="color: rgb(102, 102, 102); text-decoration: none;"> 5</a>
    #import "SystemClass+CategoryName.h"
    @implementationSystemClass ( CategoryName )
    //category扩展的方法簇
    @end
     来自CODE的代码片
    category4

    展开全文
  • stick用法

    2019-10-05 09:01:54
    I was stuck at work.---《老友记》 第一季 第二集 ...手杖[C]Grandpa still walks without a stick. 爷爷走路仍不拄拐杖。 3. 棒状物[C][(+of)]I bought the child some sticks of candy. 我给孩子买了几...

    I was stuck at work.---《老友记》 第一季 第二集

    我被工作缠住了。

    1.

    枝条;柴枝[C]
    2.
    ,,;手杖[C]
    Grandpa still walks without a stick.
    爷爷走路仍不拄拐杖。
    3.
    棒状物[C][(+of)]
    I bought the child some sticks of candy.
    我给孩子买了几根棒棒糖。
    4.
    【英】【口】惩罚;棒打;有敌意的言行[U]
    5.
    【口】家伙;呆头呆脑的人[C]
    6.
    【口】(简单的)家具[C]
    7.
    【口】小镇;乡间[the P]
    They are moving out into the sticks.
    他们将从市区搬到乡间去。


    及物动词 vt.

    1.
    ;;刺死
    2.
    钉住;插牢
    3.
    粘贴;张贴
    They stuck the notice on the wall.
    他们把通知贴在墙上。
    4.
    【口】放置[O]
    Her younger sister helped her stick a flower in her hair.
    她妹妹帮她把一朵花插在头发上。
    5.
    ,伸出[O]
    Don't stick your head out of the train window.
    不要把头伸出火车窗外面。
    6.
    【口】(通常用于疑问句和否定句)容忍,忍受[W][+v-ing]
    I can't stick such people.
    我无法容忍那种人。
    7.
    使停止;阻塞
    8.
    【口】被...难住;...困住[H]
    Are you stuck over your algebra?
    你的代数题做不下去了吧?
    9.
    【俚】(把不称心的事物)强加于


    不及物动词 vi.

    1.
    粘住;钉住
    This stamp won't stick.
    这张邮票贴不上。
    2.
    陷住;梗塞;被困住
    A fish-bone stuck in his throat.
    他喉咙里卡了一根鱼刺。
    3.
    停留;坚持;固守
    4.
    伸出;突出[(+from)]
    What's that sticking out of your pocket?
    你口袋里伸出来的是什么东西?

    转载于:https://www.cnblogs.com/CodingPerfectWorld/archive/2010/07/18/1780356.html

    展开全文
  • can和could的用法辨析1) can和could表示能力,can用于现在时,could用于过去时或表示委婉的说法,而be ableto可以用于各种时态。【例如】He is over 80 but still can read without glasses.He could speak French, ...

    can和could的用法辨析

    1) can和could表示能力,can用于现在时,could用于过去时或表示委婉的说法,而be able

    to可以用于各种时态。

    【例如】He is over 80 but still can read without glasses.

    He could speak French, so he was able to help the French lady

    yesterday.

    This is the information I've been able to get so far.

    I used to be able to remember thing quickly.

    2) can和could可以表示可能性和许可。在表示许可时,may比较正式。

    【例如】

    Sports and games can be fairly expensive. (可能性)

    You can walk for miles in the country without meeting anyone.

    (可能性)

    You can go now if you really have something urgent. (许可)

    You may return the books you borrowed to the library on

    Friday. (许可)

    3) can和could接动词的完成形式,表示可能已经做某事。can用在否定和疑问句中,表示

    不相信、怀疑等态度。

    【例如】

    They can't have gone out because the light is on.

    He can't be in the library, for I saw him in the department

    store a moment ago.

    You ____her in the office last Friday; she has been out of

    town for two weeks. (CET-4 1996, 1)

    A) needn't have seen B) must have seen

    C) might have seen D) can't have seen

    本句译为:你上星期五不可能在办公室看到她。她已经离开镇上两个月了。can't have

    seen意思是:不可能干什么,含不相信的态度,与句意相符,故选择D.

    展开全文
  • nginx常用用法

    2021-01-07 15:16:33
    2. 配置:./configure --without-http_rewrite_module --prefix=./bin --without-http_gzip_module 去掉一些本地不支持的模块; 3. make && make install 4. 修改 bin 目录下的 配置文件,网..
  • /** Copyright (c) 1995, 2008, Oracle and/or its ... All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the fol...
  • jump out用法

    千次阅读 2019-08-01 04:30:05
    You ready to jump out the airplane without your parachute? ---《老友记》 第一季 第一集 你准备好不用降落伞跳出飞机吗? 拓展: to jump right out of one's skin all skin and bones 今天我们 来给大家...
  • Masonry的基础用法

    2016-03-23 10:04:18
    1.用法 #import "ViewController.h" //define this constant if you want to use Masonry without the 'mas_' prefix #define MAS_SHORTHAND //define this constant if you want to enable auto-boxing for default
  • ssh 一些用法

    2017-05-27 22:13:50
    ssh login without password:ssh-keygen -t rsacat .ssh/id_rsa.pub | ssh root@10.110.12.170 'cat >> .ssh/authorized_keys' ssh -L 3306:localhost:3306 root@106.120.172.164netstat -na | grep :80 | wc -lnet
  • spring mongodb用法

    2016-01-28 09:00:00
    A field annotated with @Id (org.springframework.data.annotation.Id) will be mapped to the '_id' field.A field without an annotation but named 'id' will be mapped to the '_id' field. 需要包括maven.....
  • Mongodb $slice用法

    2021-04-20 14:20:39
    db.movies.find({title:"Youth Without Youth"},{languages:{$slice:3}}).pretty(); 查询输出数组后两个 db.movies.find({title:"Youth Without Youth"},{languages:{$slice:-2}}).pretty(); 查询输出从数组第...
  • 今天我们来学习imply和infer的用法。请熟读下面生活中常见情景例句到会说。01imply含有…的意思,暗示,暗指说明,表明必然包含,使有必要What do you imply by that statement?你那句话的意思是什么?TV ads ...
  • 本文实例讲述了python中随机函数random用法。分享给大家供大家参考。具体如下: python中的random模块功能非常强大,可以生成各种随机值 #! python # random import random print random.choice(['apple', 'pear', ...
  • ORACLE RTRIM用法

    2012-08-31 17:51:04
    以下是OCP教材中对该函数的描述 RTRIM(, ) takes two arguments, where c1 and c2 are ... This function returns c1 without any trailing characters that appear in c2. If no c2 characters are trailing c
  • Linux kernel kthread用法

    2021-02-02 17:23:09
    参考:https://stackoverflow.com/questions/65987208/kthread-stopped-without-running 创建线程 可以用kthread_create和kthread_run。 /** * kthread_create - create a kthread on the curre
  • @property的用法

    2020-12-23 09:34:25
    使用@property装饰器来创建只读属性,@property装饰器会将方法转换为相同名称的只读属性,可以与所定义的属性配合使用,这样可以防止属性... def method_without_property(self): ##不含@property return 15 l = DataS
  • class ctypes.py_objectRepresents the C PyObject * ... Calling this without an argument creates a NULL PyObject * pointer.示例:>>> dc = {'a':'aaa','b':'bbb'}>>> c = py_object(dc)&...
  • Verbs Followed by an Infinitive without ‘to’ 动词+不带to 的不定式后面接不带to 的动词不定式的动词中包含了can, could may, might, shall ,should, will, would, must这些情态动词。You must leave now.She ...
  • BackgroudWorker 用法示例

    2010-03-23 11:11:00
    来源:http://www.dotneat.net/2009/02/10/BackgroundworkerExample.aspxThe background worker allows you to execute intense or long operations on a separate thread, without having to deal with threads, ...
  • numpy.dot用法

    2018-06-01 11:50:48
    首先看定义:Dot ... Specifically,If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation).If both a and b are 2-D arrays, it is matrix multiplication, ...
  • 非习惯用法

    2007-09-26 14:19:08
    getText public String getText() Returns the text value of this element without recursing through child elements. This method iterates through all Text,CDATA and Entitynodes that this element contai...
  • 函数vars()的用法

    2019-09-27 08:44:47
    # -*- coding: utf-8 -*- ...#python之函数用法vars() #vars() #说明:返回对象object的属性和属性值的字典对象''' vars(...) vars([object]) -> dictionary dictionary:字典对象 Without arguments, equi...
  • java中StringBuffer的用法

    2019-09-27 18:38:47
    2.StringBuffer StringBuffer:String类同等的类,它允许...Overall, this avoids creating many temporary (临时)strings, in other words, without StringBuffer, you must create many temporary strings.Str...
  • without copying data 关键理念 Insert 1 dim ahead Expand dims with size 1 to same size 经过卷积神经网络之后得到一个Feature maps,有32个channel,在每一个channel上面添加一个Bias 如何让一个一维的Bias与...
  • grep的常用用法 grep [options] PATTERN [FILE...]即grep [选项] 要查找的字符串 查找范围(查找路径),常用组合为grep -rinl "要查找的字符串" 查找范围,rinl表示如下: -r 是递归查找,查找所有文件包含子目录中...
  • python之函数用法vars()

    2020-02-11 11:12:17
    # -*- coding: utf-8 -*- ...#python之函数用法vars() #vars() #说明:返回对象object的属性和属性值的字典对象 ''' vars(...) vars([object]) -> dictionary dictionary:字典对象 Without arguments, ...

空空如也

空空如也

1 2 3 4 5 ... 13
收藏数 247
精华内容 98
关键字:

without用法