Vim documentation: tips
main help file*tips.txt* For Vim version 7.2. Last change: 2006 Jul 24 VIM REFERENCE MANUAL by Bram Moolenaar Tips and ideas for using Vim *tips* Don't forget to browse the user manual, it also contains lots of useful tips |usr_toc.txt|. Editing C programs |C-editing| Finding where identifiers are used |ident-search| Switching screens in an xterm |xterm-screens| Scrolling in Insert mode |scroll-insert| Smooth scrolling |scroll-smooth| Correcting common typing mistakes |type-mistakes| Counting words, lines, etc. |count-items| Restoring the cursor position |restore-position| Renaming files |rename-files| Speeding up external commands |speed-up| Useful mappings |useful-mappings| Compressing the help files |gzip-helpfile| Hex editing |hex-editing| Executing shell commands in a window |shell-window| Using <> notation in autocommands |autocmd-<>| Highlighting matching parens |match-parens|
Editing C programs *C-editing* There are quite a few features in Vim to help you edit C program files. Here is an overview with tags to jump to: |usr_29.txt| Moving through programs chapter in the user manual. |usr_30.txt| Editing programs chapter in the user manual. |C-indenting| Automatically set the indent of a line while typing text. |=| Re-indent a few lines. |format-comments| Format comments. |:checkpath| Show all recursively included files. |[i| Search for identifier under cursor in current and included files. |[_CTRL-I| Jump to match for "[i" |[I| List all lines in current and included files where identifier under the cursor matches. |[d| Search for define under cursor in current and included files. |CTRL-]| Jump to tag under cursor (e.g., definition of a function). |CTRL-T| Jump back to before a CTRL-] command. |:tselect| Select one tag out of a list of matching tags. |gd| Go to Declaration of local variable under cursor. |gD| Go to Declaration of global variable under cursor. |gf| Go to file name under the cursor. |%| Go to matching (), {}, [], /* */, #if, #else, #endif. |[/| Go to previous start of comment. |]/| Go to next end of comment. |[#| Go back to unclosed #if, #ifdef, or #else. |]#| Go forward to unclosed #else or #endif. |[(| Go back to unclosed '(' |])| Go forward to unclosed ')' |[{| Go back to unclosed '{' |]}| Go forward to unclosed '}' |v_ab| Select "a block" from "[(" to "])", including braces |v_ib| Select "inner block" from "[(" to "])" |v_aB| Select "a block" from "[{" to "]}", including brackets |v_iB| Select "inner block" from "[{" to "]}"
Finding where identifiers are used *ident-search* You probably already know that |tags| can be used to jump to the place where a function or variable is defined. But sometimes you wish you could jump to all the places where a function or variable is being used. This is possible in two ways: 1. Using the |:grep| command. This should work on most Unix systems, but can be slow (it reads all files) and only searches in one directory. 2. Using ID utils. This is fast and works in multiple directories. It uses a database to store locations. You will need some additional programs for this to work. And you need to keep the database up to date. Using the GNU id-tools: What you need: - The GNU id-tools installed (mkid is needed to create ID and lid is needed to use the macros). - An identifier database file called "ID" in the current directory. You can create it with the shell command "mkid file1 file2 ..". Put this in your .vimrc: map _u :call ID_search()<Bar>execute "/\\<" . g:word . "\\>"<CR> map _n :n<Bar>execute "/\\<" . g:word . "\\>"<CR> function! ID_search() let g:word = expand("<cword>") let x = system("lid --key=none ". g:word) let x = substitute(x, "\n", " ", "g") execute "next " . x endfun To use it, place the cursor on a word, type "_u" and vim will load the file that contains the word. Search for the next occurrence of the word in the same file with "n". Go to the next file with "_n". This has been tested with id-utils-3.2 (which is the name of the id-tools archive file on your closest gnu-ftp-mirror). [the idea for this comes from Andreas Kutschera]
Switching screens in an xterm *xterm-screens* *xterm-save-screen* (From comp.editors, by Juergen Weigert, in reply to a question) :> Another question is that after exiting vim, the screen is left as it :> was, i.e. the contents of the file I was viewing (editing) was left on :> the screen. The output from my previous like "ls" were lost, :> ie. no longer in the scrolling buffer. I know that there is a way to :> restore the screen after exiting vim or other vi like editors, :> I just don't know how. Helps are appreciated. Thanks. : :I imagine someone else can answer this. I assume though that vim and vi do :the same thing as each other for a given xterm setup. They not necessarily do the same thing, as this may be a termcap vs. terminfo problem. You should be aware that there are two databases for describing attributes of a particular type of terminal: termcap and terminfo. This can cause differences when the entries differ AND when of the programs in question one uses terminfo and the other uses termcap (also see |+terminfo|). In your particular problem, you are looking for the control sequences ^[[?47h and ^[[?47l. These switch between xterms alternate and main screen buffer. As a quick workaround a command sequence like echo -n "^[[?47h"; vim ... ; echo -n "^[[?47l" may do what you want. (My notation ^[ means the ESC character, further down you'll see that the databases use \E instead). On startup, vim echoes the value of the termcap variable ti (terminfo: smcup) to the terminal. When exiting, it echoes te (terminfo: rmcup). Thus these two variables are the correct place where the above mentioned control sequences should go. Compare your xterm termcap entry (found in /etc/termcap) with your xterm terminfo entry (retrieved with "infocmp -C xterm"). Both should contain entries similar to: :te=\E[2J\E[?47l\E8:ti=\E7\E[?47h: PS: If you find any difference, someone (your sysadmin?) should better check the complete termcap and terminfo database for consistency. NOTE 1: If you recompile Vim with FEAT_XTERM_SAVE defined in feature.h, the builtin xterm will include the mentioned "te" and "ti" entries. NOTE 2: If you want to disable the screen switching, and you don't want to change your termcap, you can add these lines to your .vimrc: :set t_ti= t_te=
Scrolling in Insert mode *scroll-insert* If you are in insert mode and you want to see something that is just off the screen, you can use CTRL-X CTRL-E and CTRL-X CTRL-Y to scroll the screen. |i_CTRL-X_CTRL-E| To make this easier, you could use these mappings: :inoremap <C-E> <C-X><C-E> :inoremap <C-Y> <C-X><C-Y> (Type this literally, make sure the '<' flag is not in 'cpoptions'). You then lose the ability to copy text from the line above/below the cursor |i_CTRL-E|. Also consider setting 'scrolloff' to a larger value, so that you can always see some context around the cursor. If 'scrolloff' is bigger than half the window height, the cursor will always be in the middle and the text is scrolled when the cursor is moved up/down.
Smooth scrolling *scroll-smooth* If you like the scrolling to go a bit smoother, you can use these mappings: :map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y> :map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E> (Type this literally, make sure the '<' flag is not in 'cpoptions').
Correcting common typing mistakes *type-mistakes* When there are a few words that you keep on typing in the wrong way, make abbreviations that correct them. For example: :ab teh the :ab fro for
Counting words, lines, etc. *count-items* To count how often any pattern occurs in the current buffer use the substitute command and add the 'n' flag to avoid the substitution. The reported number of substitutions is the number of items. Examples: :%s/./&/gn characters :%s/\i\+/&/gn words :%s/^//n lines :%s/the/&/gn "the" anywhere :%s/\<the\>/&/gn "the" as a word You might want to reset 'hlsearch' or do ":nohlsearch". Add the 'e' flag if you don't want an error when there are no matches. An alternative is using |v_g_CTRL-G| in Visual mode. If you want to find matches in multiple files use |:vimgrep|. *count-bytes* If you want to count bytes, you can use this: Visually select the characters (block is also possible) Use "y" to yank the characters Use the strlen() function: :echo strlen(@") A line break is counted for one byte.
Restoring the cursor position *restore-position* Sometimes you want to write a mapping that makes a change somewhere in the file and restores the cursor position, without scrolling the text. For example, to change the date mark in a file: :map <F2> msHmtgg/Last [cC]hange:\s*/e+1<CR>"_D"=strftime("%Y %b %d")<CR>p'tzt`s Breaking up saving the position: ms store cursor position in the 's' mark H go to the first line in the window mt store this position in the 't' mark Breaking up restoring the position: 't go to the line previously at the top of the window zt scroll to move this line to the top of the window `s jump to the original position of the cursor
Renaming files *rename-files* Say I have a directory with the following files in them (directory picked at random :-): buffer.c charset.c digraph.c ... and I want to rename *.c *.bla. I'd do it like this: $ vim :r !ls *.c :%s/\(.*\).c/mv & \1.bla :w !sh :q!
Speeding up external commands *speed-up* In some situations, execution of an external command can be very slow. This can also slow down wildcard expansion on Unix. Here are a few suggestions to increase the speed. If your .cshrc (or other file, depending on the shell used) is very long, you should separate it into a section for interactive use and a section for non-interactive use (often called secondary shells). When you execute a command from Vim like ":!ls", you do not need the interactive things (for example, setting the prompt). Put the stuff that is not needed after these lines: if ($?prompt == 0) then exit 0 endif Another way is to include the "-f" flag in the 'shell' option, e.g.: :set shell=csh\ -f (the backslash is needed to include the space in the option). This will make csh completely skip the use of the .cshrc file. This may cause some things to stop working though.
Useful mappings *useful-mappings* Here are a few mappings that some people like to use. *map-backtick* :map ' ` Make the single quote work like a backtick. Puts the cursor on the column of a mark, instead of going to the first non-blank character in the line. *emacs-keys* For Emacs-style editing on the command-line: " start of line :cnoremap <C-A> <Home> " back one character :cnoremap <C-B> <Left> " delete character under cursor :cnoremap <C-D> <Del> " end of line :cnoremap <C-E> <End> " forward one character :cnoremap <C-F> <Right> " recall newer command-line :cnoremap <C-N> <Down> " recall previous (older) command-line :cnoremap <C-P> <Up> " back one word :cnoremap <Esc><C-B> <S-Left> " forward one word :cnoremap <Esc><C-F> <S-Right> NOTE: This requires that the '<' flag is excluded from 'cpoptions'. |<>| *format-bullet-list* This mapping will format any bullet list. It requires that there is an empty line above and below each list entry. The expression commands are used to be able to give comments to the parts of the mapping. :let m = ":map _f :set ai<CR>" " need 'autoindent' set :let m = m . "{O<Esc>" " add empty line above item :let m = m . "}{)^W" " move to text after bullet :let m = m . "i <CR> <Esc>" " add space for indent :let m = m . "gq}" " format text after the bullet :let m = m . "{dd" " remove the empty line :let m = m . "5lDJ" " put text after bullet :execute m |" define the mapping (<> notation |<>|. Note that this is all typed literally. ^W is "^" "W", not CTRL-W. You can copy/paste this into Vim if '<' is not included in 'cpoptions'.) Note that the last comment starts with |", because the ":execute" command doesn't accept a comment directly. You also need to set 'textwidth' to a non-zero value, e.g., :set tw=70 A mapping that does about the same, but takes the indent for the list from the first line (Note: this mapping is a single long line with a lot of spaces): :map _f :set ai<CR>}{a <Esc>WWmmkD`mi<CR><Esc>kkddpJgq}'mJO<Esc>j *collapse* These two mappings reduce a sequence of empty (;b) or blank (;n) lines into a single line :map ;b GoZ<Esc>:g/^$/.,/./-j<CR>Gdd :map ;n GoZ<Esc>:g/^[ <Tab>]*$/.,/[^ <Tab>]/-j<CR>Gdd
Compressing the help files *gzip-helpfile* For those of you who are really short on disk space, you can compress the help files and still be able to view them with Vim. This makes accessing the help files a bit slower and requires the "gzip" program. (1) Compress all the help files: "gzip doc/*.txt". (2) Edit "doc/tags" and change the ".txt" to ".txt.gz": :%s=\(\t.*\.txt\)\t=\1.gz\t= (3) Add this line to your vimrc: set helpfile={dirname}/help.txt.gz Where {dirname} is the directory where the help files are. The |gzip| plugin will take care of decompressing the files. You must make sure that $VIMRUNTIME is set to where the other Vim files are, when they are not in the same location as the compressed "doc" directory. See |$VIMRUNTIME|.
Executing shell commands in a window *shell-window* There have been questions for the possibility to execute a shell in a window inside Vim. The answer: you can't! Including this would add a lot of code to Vim, which is a good reason not to do this. After all, Vim is an editor, it is not supposed to do non-editing tasks. However, to get something like this, you might try splitting your terminal screen or display window with the "splitvt" program. You can probably find it on some ftp server. The person that knows more about this is Sam Lantinga<EMAIL_ADDRESS>An alternative is the "window" command, found on BSD Unix systems, which supports multiple overlapped windows. Or the "screen" program, found at www.uni-erlangen.de, which supports a stack of windows.
Hex editing *hex-editing* *using-xxd* See section |23.4| of the user manual. If one has a particular extension that one uses for binary files (such as exe, bin, etc), you may find it helpful to automate the process with the following bit of autocmds for your <.vimrc>. Change that "*.bin" to whatever comma-separated list of extension(s) you find yourself wanting to edit: " vim -b : edit binary using xxd-format! augroup Binary au! au BufReadPre *.bin let &bin=1 au BufReadPost *.bin if &bin | %!xxd au BufReadPost *.bin set ft=xxd | endif au BufWritePre *.bin if &bin | %!xxd -r au BufWritePre *.bin endif au BufWritePost *.bin if &bin | %!xxd au BufWritePost *.bin set nomod | endif augroup END
Using <> notation in autocommands *autocmd-<>* The <> notation is not recognized in the argument of an :autocmd. To avoid having to use special characters, you could use a self-destroying mapping to get the <> notation and then call the mapping from the autocmd. Example: *map-self-destroy* " This is for automatically adding the name of the file to the menu list. " It uses a self-destroying mapping! " 1. use a line in the buffer to convert the 'dots' in the file name to \. " 2. store that in register '"' " 3. add that name to the Buffers menu list " WARNING: this does have some side effects, like overwriting the " current register contents and removing any mapping for the "i" command. " autocmd BufNewFile,BufReadPre * nmap i :nunmap i<CR>O<C-R>%<Esc>:.g/\./s/\./\\./g<CR>0"9y$u:menu Buffers.<C-R>9 :buffer <C-R>%<C-V><CR><CR> autocmd BufNewFile,BufReadPre * normal i Another method, perhaps better, is to use the ":execute" command. In the string you can use the <> notation by preceding it with a backslash. Don't forget to double the number of existing backslashes and put a backslash before '"''. autocmd BufNewFile,BufReadPre * exe "normal O\<C-R>%\<Esc>:.g/\\./s/\\./\\\\./g\<CR>0\"9y$u:menu Buffers.\<C-R>9 :buffer \<C-R>%\<C-V>\<CR>\<CR>" For a real buffer menu, user functions should be used (see |:function|), but then the <> notation isn't used, which defeats using it as an example here.
Highlighting matching parens *match-parens* This example shows the use of a few advanced tricks: - using the |CursorMoved| autocommand event - using |searchpairpos()| to find a matching paren - using |synID()| to detect whether the cursor is in a string or comment - using |:match| to highlight something - using a |pattern| to match a specific position in the file. This should be put in a Vim script file, since it uses script-local variables. It skips matches in strings or comments, unless the cursor started in string or comment. This requires syntax highlighting. A slightly more advanced version is used in the |matchparen| plugin. let s:paren_hl_on = 0 function s:Highlight_Matching_Paren() if s:paren_hl_on match none let s:paren_hl_on = 0 endif let c_lnum = line('.') let c_col = col('.') let c = getline(c_lnum)[c_col - 1] let plist = split(&matchpairs, ':\|,') let i = index(plist, c) if i < 0 return endif if i % 2 == 0 let s_flags = 'nW' let c2 = plist[i + 1] else let s_flags = 'nbW' let c2 = c let c = plist[i - 1] endif if c == '[' let c = '\[' let c2 = '\]' endif let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' . \ '=~? "string\\|comment"' execute 'if' s_skip '| let s_skip = 0 | endif' let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip) if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$') exe 'match Search /\(\%' . c_lnum . 'l\%' . c_col . \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' let s:paren_hl_on = 1 endif endfunction autocmd CursorMoved,CursorMovedI * call s:Highlight_Matching_Paren() autocmd InsertEnter * match none top - main help file


Last date of submission was on 03/12/2017.To consider your work for presentation, you may communicate to racis 2018 programme chairs using official mail.
← Back to Home


Before Change
assert "fnirs_raw" in raw
assert "fnirs_od" not in raw
picks = pick_types(raw.info, fnirs="fnirs_cw_amplitude")
with pytest.deprecated_call():
picks_alias = pick_types(raw.info, fnirs="fnirs_raw")
assert_array_equal(picks, picks_alias)
@requires_testing_data
After Change
// Old name aliases for backward compat
assert "fnirs_cw_amplitude" in raw
with pytest.raises(ValueError, match="Invalid value"):
"fnirs_raw" in raw
assert "fnirs_od" not in raw
picks = pick_types(raw.info, fnirs="fnirs_cw_amplitude")


Hannah Bridges
Local and General Analysis
There were many topics to chose from pertaining to the Egyptian Gazette however, in my analysis project I decided to look at the “Local and General” section of the newspaper. I was interested in the topics that showed up most in the section and moreover what topics kept getting printed in the issues of the newspaper. I wanted to know throughout the newspaper what topics were, not so much being read more than the other but, reoccurring actions to be talked or read about in Egypt during the time.
Word Cloud Photo
As a result of this I decided to create a word cloud to make a visual representation of the headlines of each section of the newspaper. In the word cloud, the headlines that were printed most are the largest in the figure and then following that are the headlines that are posted less which are represented by the smaller words in the figure.
Data
For this data set I created a query that would find only the headlines in the section of local and general and it would also include the date of the issue posted. I used two queries to do this because the @feature
and @element
tags were implemented and each contained data that I needed to combine to get accurate results. The first query used was as presented //div[@feature="local"]/div/head
, the second query is different by one word //div[@element="local"]/div/head
. The first query search returned 2,497 items while the second query resulted in 308 items. After this I transferred all the results into atom and refined the visual content that the search gave me. At the end I had two columns of data that was the date of the issue and the headline that was posted on that date in the “Local and General” section of the newspaper.
Comparison and Outside Sources
Reading through other analysis projects from previous students, as well as the discussion of it in class, there was one that stood out to me about the Plague. As I was reading through their project they mention that their search for any div
in any item
would contain the word “plague” and it only returned 82 items. This search seems to have returned a small number of instances for the return of the word plague considering one of the more prominent words in my word cloud is the word “plague”. They continue to go on to explain the way the word was used and the context of the word in the multiple occurrence in the Egyptian Gazette.
Also in relation to my analysis search I want to reference today’s newspapers and/or ways of information in today’s society. We hardly get our information from a daily newspaper anymore, we typically get our intel from either social media or from the form of digital news still found on the internet. There is the more common way of reeling in viewers with a headline that is either a hook or a brief excerpt of what the piece entails. This differs from the way the Egyptian Gazette displayed its news. The headlines for the news paper in the section are 2 to 3 word headlines that explain the passage.
Conclusion
The largest printed headline was the word “Canal” and the second most printed headline was “Suez”. There were other headlines printed that were seen quite often throughout consisting of: Alexandria, Plague, Egyptian, Stray Dogs, etc. There were often topics that were repeated in this section of the newspaper and new information was displayed this way in the Egyptian Gazette.
Below is a clip of the newspaper that I would find the “Local and General” section in and it is typically found on the third page of the issue. Also, to conclude this analysis project I think that the way I represented this data works much better visually than any bar graph would have been able to.


View High Scores
Time:
0
Coding Quiz Challenge
Try to answer the following code-related questions within the time limit.
Keep in mind that incorrect answers will penalize your score/time by ten seconds.
START QUIZ
Quiz Over!


> I write Twitter
> learn more
> I also:
> list skill
> where <skill> is one of: HTML5, CSS3, ReactJS, Golang, D3, GIT and Github,
HTML5, CSS3, ReactJS, Golang, D3, GIT and Github,
> list familiar area:
> where <area> is one of:
Haxe, OpenFL, Python, THREE.js, Node.js
>


Anelia Koleva
Junior front-end web developer
home
resume
projects
contact
resume
skills
I am familiar with:
HTML
CSS
SASS
JavaScript
jQuery
Bootstrap Framework
I’ve heard of:
Git
PHP
Photoshop
Wordpress


Protocols
The following protocols are available globally.
-
Objective-C Foundation types that are natively supported by Core Data managed attributes all conform to
CoreDataNativeType
.Declaration
Swift
@objc public protocol CoreDataNativeType : NSObjectProtocol
-
Custom loggers should implement the
See moreCoreStoreLogger
protocol and pass its instance toCoreStoreDefaults.logger
. Calls tolog(...)
,assert(...)
, andabort(...)
are not tied to a specific queue/thread, so it is the implementer’s job to handle thread-safety.Declaration
Swift
public protocol CoreStoreLogger
-
Observation token for
CoreStoreObject
properties. Make sure to retain this instance to keep observing notifications.
See moreinvalidate()
will be called automatically when anCoreStoreObjectKeyValueObservation
is deinited.Declaration
Swift
public protocol CoreStoreObjectKeyValueObservation : AnyObject
-
All CoreStore’s utilities are designed around
See moreDynamicObject
instances.NSManagedObject
andCoreStoreObject
instances all conform toDynamicObject
.Declaration
Swift
public protocol DynamicObject : AnyObject
-
The
See moreDiffableDataSource.Target
protocol allows custom views to consumeListSnapshot
diffable data similar to howDiffableDataSource.TableViewAdapter
andDiffableDataSource.CollectionViewAdapter
reloads data for their corresponding views.Declaration
Swift
public protocol DiffableDataSourceTarget
-
DynamicSchema
are types that provideNSManagedObjectModel
instances for a single model version. CoreStore currently supports the following concrete types:XcodeDataModelSchema
: describes models loaded from a .xcdatamodeld file.UnsafeDataModelSchema
: describes models loaded directly from an existingNSManagedObjectModel
. It is not advisable to continue using this model as its metadata are not available to CoreStore.CoreStoreSchema
: describes models written forCoreStoreObject
Swift class declarations.
Declaration
Swift
public protocol DynamicSchema
-
Values to be used for
See moreField.Relationship
properties.Declaration
Swift
public protocol FieldRelationshipType
-
Utility protocol for
See moreFetchChainBuilder
. Used in fetch methods that support chained fetch builders.Declaration
Swift
public protocol FetchChainableBuilderType
-
Encapsulates containers which manages an internal
See moreNSManagedObjectContext
, such asDataStack
s and transactions, that can be used for fetching objects. CoreStore provides implementations for this protocol and should be used as a read-only abstraction.Declaration
Swift
public protocol FetchableSource : AnyObject
-
Types that implement encoding to and decoding from
Data
to be used inField.Coded
properties’coder:
argument.
See moreclass Person: CoreStoreObject { @Field.Coded("profile", coder: FieldCoders.Json.self) var profile: Profile = .init() }
Declaration
Swift
public protocol FieldCoderType
-
Types that are supported by
FieldCoders.DefaultNSSecureCoding
Declaration
Swift
public protocol DefaultNSSecureCodable : NSObject, NSSecureCoding
-
Optional values to be used for
See moreField
properties.Declaration
Swift
public protocol FieldOptionalType : ExpressibleByNilLiteral
-
Values to be used for
See moreField.Stored
properties.Declaration
Swift
public protocol FieldStorableType
-
Types supported by CoreStore as
NSManagedObject
andCoreStoreObject
property types. Supported default types:- Bool
- CGFloat
- Data
Date
Date- Double
- Float
- Int
- Int8
- Int16
- Int32
- Int64
- NSData
- NSDate
- NSDecimalNumber
- NSNumber
- NSString
- NSURL
- NSUUID
- String
- URL
- UUID
In addition,
RawRepresentable
types whoseRawValue
already implementsImportableAttributeType
only need to declare conformance toImportableAttributeType
.Declaration
Swift
public protocol ImportableAttributeType : QueryableAttributeType
-
NSManagedObject
andCoreStoreObject
subclasses that conform to theImportableObject
protocol can be imported from a specifiedImportSource
. This allows transactions to create and insert instances this way:
See moreclass Person: NSManagedObject, ImportableObject { typealias ImportSource = NSDictionary // ... } dataStack.perform( asynchronous: { (transaction) -> Void in let json: NSDictionary = // ... let person = try transaction.importObject( Into<Person>(), source: json ) // ... }, completion: { (result) in // ... } )
Declaration
Swift
public protocol ImportableObject : DynamicObject
-
NSManagedObject
subclasses that conform to theImportableUniqueObject
protocol can be imported from a specifiedImportSource
. This allows transactions to either update existing objects or create new instances this way:
See moreclass Person: NSManagedObject, ImportableObject { typealias ImportSource = NSDictionary typealias UniqueIDType = NSString // ... } dataStack.perform( asynchronous: { (transaction) -> Void in let json: NSDictionary = // ... let person = try transaction.importUniqueObject( Into<Person>(), source: json ) // ... }, completion: { (result) in // ... } )
Declaration
Swift
public protocol ImportableUniqueObject : ImportableObject, Hashable
-
Used only for utility methods. Types allowed as
See moreValue
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
Value
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedOptionalObjectiveCKeyPathValue : AllowedObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
See moreValue
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedObjectiveCAttributeKeyPathValue : AllowedObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
Value
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedObjectiveCRelationshipKeyPathValue : AllowedOptionalObjectiveCKeyPathValue
-
Used only for utility methods. Types allowed as
Value
generic type toKeyPath
utilities.Declaration
Swift
public protocol AllowedObjectiveCToManyRelationshipKeyPathValue : AllowedOptionalObjectiveCKeyPathValue
-
Used only for utility methods.
See moreDeclaration
Swift
public protocol KeyPathStringConvertible : AnyKeyPathStringConvertible
-
Used only for utility methods.
See moreDeclaration
Swift
public protocol AttributeKeyPathStringConvertible : KeyPathStringConvertible
-
Used only for utility methods.
See moreDeclaration
Swift
public protocol RelationshipKeyPathStringConvertible : KeyPathStringConvertible
-
Used only for utility methods.
Declaration
Swift
public protocol ToManyRelationshipKeyPathStringConvertible : RelationshipKeyPathStringConvertible where Self.ReturnValueType : Sequence
-
Implement the
ListObserver
protocol to observe changes to a list ofNSManagedObject
s.ListObserver
s may register themselves to aListMonitor
‘saddObserver(_:)
method:
See morelet monitor = dataStack.monitorList( From<Person>(), OrderBy(.ascending("lastName")) ) monitor.addObserver(self)
Declaration
Swift
public protocol ListObserver : AnyObject
-
Implement the
ListObjectObserver
protocol to observe detailed changes to a list’s object.ListObjectObserver
s may register themselves to aListMonitor
‘saddObserver(_:)
method:
See morelet monitor = dataStack.monitorList( From<MyPersonEntity>(), OrderBy(.ascending("lastName")) ) monitor.addObserver(self)
Declaration
Swift
public protocol ListObjectObserver : ListObserver
-
Implement the
ListSectionObserver
protocol to observe changes to a list’s section info.ListSectionObserver
s may register themselves to aListMonitor
‘saddObserver(_:)
method:
See morelet monitor = dataStack.monitorSectionedList( From<MyPersonEntity>(), SectionBy("age") { "Age \($0)" }, OrderBy(.ascending("lastName")) ) monitor.addObserver(self)
Declaration
Swift
public protocol ListSectionObserver : ListObjectObserver
-
Implement the
ObjectObserver
protocol to observe changes to a singleDynamicObject
instance.ObjectObserver
s may register themselves to anObjectMonitor
‘saddObserver(_:)
method:
See morelet monitor = dataStack.monitorObject(object) monitor.addObserver(self)
Declaration
Swift
public protocol ObjectObserver : AnyObject
-
Used internally by CoreStore. Do not conform to directly.
See moreDeclaration
Swift
public protocol AnyObjectRepresentation
-
An object that acts as interfaces for
See moreCoreStoreObject
s orNSManagedObject
sDeclaration
Swift
public protocol ObjectRepresentation : AnyObjectRepresentation
-
Utility protocol for
See moreQueryChainBuilder
. Used in fetch methods that support chained query builders.Declaration
Swift
public protocol QueryChainableBuilderType
-
Types supported by CoreStore for querying, especially as generic type for
Select
clauses. Supported default types:Bool
CGFloat
Data
Date
Double
Float
Int
Int8
Int16
Int32
Int64
NSData
NSDate
NSDecimalNumber
NSManagedObjectID
NSNull
NSNumber
NSString
NSURL
NSUUID
String
URL
UUID
In addition,
See moreRawRepresentable
types whoseRawValue
already implementsQueryableAttributeType
only need to declare conformance toQueryableAttributeType
.Declaration
Swift
public protocol QueryableAttributeType : SelectResultType, Hashable
-
Encapsulates containers which manages an internal
See moreNSManagedObjectContext
, such asDataStack
s and transactions, that can be used for querying values. CoreStore provides implementations for this protocol and should be used as a read-only abstraction.Declaration
Swift
public protocol QueryableSource : AnyObject
-
The
See moreSchemaMappingProvider
provides migration mapping information between twoDynamicSchema
versions.Declaration
Swift
public protocol SchemaMappingProvider
-
Utility protocol for
See moreSectionMonitorChainBuilder
. Used in methods that support chained fetch builders.Declaration
Swift
public protocol SectionMonitorBuilderType
-
The
SelectResultType
protocol is implemented by return types supported by theSelect
clause.Declaration
Swift
public protocol SelectResultType
-
The
SelectAttributesResultType
protocol is implemented by return types supported by thequeryAttributes(...)
methods.Declaration
Swift
public protocol SelectAttributesResultType : SelectResultType
-
The
See moreStorageInterface
represents the data store managed (or to be managed) by theDataStack
. When added to theDataStack
, theStorageInterface
serves as the interface for theNSPersistentStore
. This may be a database file, an in-memory store, etc.Declaration
Swift
public protocol StorageInterface : AnyObject
-
The
See moreLocalStorage
representsStorageInterface
s that are backed by local files.Declaration
Swift
public protocol LocalStorage : StorageInterface
-
The
FetchClause
implement clauses used to configureNSFetchRequest
s.Declaration
Swift
public protocol FetchClause
-
The
QueryClause
implement clauses used to configureNSFetchRequest
s.Declaration
Swift
public protocol QueryClause : FetchClause
-
The
DeleteClause
implement clauses used to configureNSFetchRequest
s.Declaration
Swift
public protocol DeleteClause : FetchClause
-
Declaration
Swift
public protocol AnyWhereClause : DeleteClause, QueryClause
-
Used only for
Where.Expression
type constraints. Currently supportsSingleTarget
andCollectionTarget
.Declaration
Swift
public protocol WhereExpressionTrait
-
Abstracts the
See moreWhere
clause for protocol utilities. Typically used only for utility method generic constraints.Declaration
Swift
public protocol WhereClauseType : AnyWhereClause


1. Introduction
This section is not normative.
The success of WebFonts is unevenly distributed. This specification allows WebFonts to be used where slow networks, very large fonts, or complex subsetting requirements currently preclude their use. For example, even using WOFF 2 [WOFF2], fonts for CJK languages are too large to be practical.
See the Progressive Font Enrichment: Evaluation Report [PFE-report] for the investigation which led to this specification.
2. Patch Based Incremental Transfer
TODO(garretrieger): Describe the high level version of how this version operates.
2.1. Data Types
This section lists all of the data types that are used to form the request and response messages sent between the client and server.
2.1.1. Encoding
All data types defined here are encoded into a byte representation for transport using CBOR (Concise Binary Object Representation) [rfc8949]. More information on how each data types should be encoded by CBOR are given in the definition of those data types.
2.1.2. Primitives
| Data Type | Description | CBOR Major Type |
|---|---|---|
| Integer | An integer value range [-2^64 - 1, 2^64 - 1] inclusive | 0 or 1 |
| ByteString | Variable number of bytes | 2 |
| ArrayOf<Type> | Array of a variable number of items of Type | 4 |
2.1.3. SparseBitSet
A data structure which compactly stores a set of distinct unsigned integers. The set is represented as a tree where each node has a fixed number of children that recursively sub-divides an interval into equal partitions. A tree of height H with branching factor B can store set membership for integers in the interval [0 to BH-1] inclusive. The tree is encoded into a ByteString for transport.
To construct the tree T which encodes set S first select the branching factor B (how many children each node has). B can be 4, 8, 16, or 32.
Note: the encoder can use any of the possible branching factors, but it is recommended to use 4 as that has been shown to give the smallest encodings for most sets typically encountered.
Next, determine the height, H, of the tree:
H = ceil(logB(max(S) + 1))
Next create a tree of height H where all non-leaf nodes have B children. Each node in the tree has a single value composed of B bits. Given a node p which has B children: c0 ... cB - 1 and is in a tree, T, of height H, then:
-
D(ci) is depth of node ci, that is the number of edges between the root node and ci.
-
Start(ci) is the start (inclusive) of the interval covered by ci :
Start(ci) = Start(p) + i * BH - D(ci) -
End(ci) is the end (exclusive) of the interval covered by ci :
End(ci) = Start(p) + (i + 1) * BH - D(ci) -
Start(root node) = 0
-
The value of node p is a string of B bits. If its bits are numbered from 0 (least significant) to B - 1 (most significant) then bit i will be 1 if the set S contains at least one member in the interval [Start(ci), End(ci)), otherwise bit i will be 0.
-
If for node p, End(p) - Start(p) = B, then p will have no children.
The tree is encoded into a bit string. The bits of the bit string are numbered from 0 to M. When appending multi bit values to the bit string, bits are added in order from least significant bit to most significant bit.
First append 2 bits which encode the branching factor:
| Bits | Branching Factor |
|---|---|
| 00 | 4 |
| 01 | 8 |
| 10 | 16 |
| 11 | 32 |
Then append the value H - 1 as a 6 bit unsigned integer.
Next the nodes are encoded into the bit string by traversing the nodes of the T in level order and appending the value for each non-zero node to the bit string.If all set values covered by a node’s interval are present within set S that node can instead be encoded in the bit string as B bits all set to zero. All children of that node must not be encoded.
Lastly the bit string is converted into a ByteString by converting each consecutive group of 8 bits into the next byte of the string. The bit with the smallest index in the bit string is the least significant bit in the byte and the bit with the largest index is the most significant bit.
BitString: |- header |- lvl 0 |---- level 1 ----|------- level 2 -----------| | | n0 | n1 n2 | n3 n4 n5 | [ 10010000 10000100 10001000 10000000 00100000 01000000 00010000 ] Which then becomes the ByteString: [ 0b00001001, 0b00100001, 0b00010001, 0b00000001, 0b00000100, 0b00000010, 0b00001000 ]
First determine the height of the tree:
H = ceil(log8(323 + 1)) = 3
Then append
-
branching factor = 8 = 01
-
H - 1 = 2 = 000010
Level 0:
-
root node, n0 append 00100001. Since there are set members in the intervals [0, 64) for bit 0 and [320, 384) for bit 5.
Level 1:
-
There will be two non-zero children corresponding to bit 0 and bit 5 in n0:
-
n1 append 00010001. It is child 0 of n0 and subdivides the interval [0, 64). Bit 0 is set since there are set members in [0, 8) and bit 4 for [32, 40).
-
n2 append 00000001. It is child 5 of n0 it subdivides the interval [320, 384). Bit 0 is set since there are set members in [320 - 328).
Level 2:
-
n3 append 00000100. Child 0 of n1, bit 2 is set for the interval [2, 3) or 2.
-
n4 append 00000010. Child 4 of n1, bit 1 is set for the interval [33, 34) or 33.
-
n5 append 00001000. Child 0 of n2, bit 3 is set for the interval [323, 324) or 323.
BitString: |- header | l0 |- lvl 1 -| l2 | | | n0 | n1 | n2 | n3 | [ 00010000 1100 0000 1000 1100 ] ByteString: [ 0b00001000, 0b00000011, 0b00110001 ]
First determine the height of the tree:
H = ceil(log4(17 + 1)) = 3
Then append
-
branching factor = 4 = 00
-
H - 1 = 2 = 000010
Level 0:
-
n0 append 0011. Bit 0 set for [0, 16), bit 1 set for [16, 32)
Level 1:
-
n1 append 0000. All bits zero to indicate interval [0, 16) is fully filled.
-
n2 append 0001. Bit 0 set for [16, 20)
Level 2:
-
n3 append 0011. Bit 0 set for value 16, bit 1 set for value 17.
2.1.4. Objects
Objects are data structures comprised of key and value pairs. Objects are encoded via CBOR as maps (major type 5). Each key and value pair is encoded as a single map entry. Keys are always unsigned integers and are encoded using major type 0. Values are encoded using the encoding specified by the type of the value.
All fields in an object are optional and do not need to have an associated value. Conversely when decoding and object fields may be present which are not specified in the schema. The decoder must ignore without error any key and value pairs where the key is not recognized.
There are several types of object used, each type is defined by a schema in § 2.1.5 Object Schemas. The schema for a type specifies for each field:
-
A human readable name for the field. For reference only, not used in the encoding.
-
A unsigned integer id for the field. This is used as the key in the encoding.
-
The type of the value stored in this field. Can be any of the types defined in § 2.1 Data Types including object types.
2.1.5. Object Schemas
<IP_ADDRESS>. CompressedList
| ID | Field Name | Value Type |
|---|---|---|
| 0 | value_deltas | ArrayOf<Integer> |
Encodes a list of unsigned integers. The list is ordered and allows duplicate values. Given a list L to be encoded the array value_deltas is calculated:
value_deltas = [] if len(value_deltas) > 0: value_deltas[0] = L[0] for i in range(1, len(value_deltas)): value_deltas[i] = L[i] - L[i-1]
<IP_ADDRESS>. CompressedSet
Encodes a set of unsigned integers. The set is not ordered and does not allow duplicates. Members of the set are encoded into either a sparse bit set or a list of ranges. To obtain the final set the members of the sparse bit set and the list of ranges are unioned together.
The list of ranges is encoded as a series of deltas. For example the ranges
\[3, 10\], \[13, 15\], \[17, 17\] would be encoded as \[3, 7, 3, 2, 2, 0\].
| ID | Field Name | Type | | -- | ---------------------- | ---------------------- | | 0 | sparse_bit_set | SparseBitSet | | 1 | range_deltas | ArrayOf<Integer> |
<IP_ADDRESS>. PatchRequest
| ID | Field Name | Value Type |
|---|---|---|
| 0 | protocol_version | Integer |
| 1 | original_font_checksum | Integer |
| 2 | base_checksum | Integer |
| 3 | patch_format | ArrayOf<Integer> |
| 4 | codepoints_have | CompressedSet |
| 5 | codepoints_needed | CompressedSet |
| 6 | ordering_checksum | Integer |
| 7 | indices_have | CompressedSet |
| 8 | indices_needed | CompressedSet |
patch_format can include be any of the values specified in § 2.8.3 Patch and Compression Formats.
<IP_ADDRESS>. PatchResponse
| ID | Field Name | Value Type |
|---|---|---|
| 0 | response_type | Integer |
| 1 | original_font_checksum | Integer |
| 2 | patch_format | Integer |
| 3 | patch | ByteString |
| 4 | patched_checksum | Integer |
| 4 | codepoint_ordering | CompressedList |
| 5 | ordering_checksum | Integer |
response_type can be one of the following values:
| Value | Response Type |
|---|---|
| 0 | PATCH |
| 1 | REBASE |
| 2 | REINDEX |
2.2. New Font Request
2.2.1. Standard Response
2.2.2. Errors
2.3. Patch Font Request
2.3.1. Standard Response
2.3.2. Recoverable Errors
<IP_ADDRESS>. Client’s Original Font does not Match Server’s
<IP_ADDRESS>. Client’s Base does not Match Server’s
<IP_ADDRESS>. Client Codepoint Reordering does not Match Servers
<IP_ADDRESS>. Client Side Patched Base Checksum Mismatch
<IP_ADDRESS>. Cmap Format 4 Overflow
<IP_ADDRESS>. Offset Overflow during Subsetting
2.3.3. Errors
2.4. New Font Response
2.5. Patch Font Response
2.6. Update Codepoint Ordering Response
2.7. Error Response
-
font not found.
-
bad request.
-
internal error.
2.8. Procedures
2.8.1. Computing Checksums
2.8.2. Codepoint reodering
<IP_ADDRESS>. Computing Checksum
<IP_ADDRESS>. Recommended algorithm
2.8.3. Patch and Compression Formats
3. Range Request Incremental Transfer
4. Negotiating Incremental Transfer Type
Privacy and Security Considerations
Note any issues that have been raised about privacy and security.


---
layout: post
title: 9/7 progress report
date: '2013-09-07T22:12:00.001-06:00'
author: Jacob .
tags:
- progress-reports
modified_time: '2013-09-07T22:12:40.977-06:00'
blogger_id: tag:blogger.com,1999:blog-6400085873105072120.post-224760439073096680
blogger_orig_url: http://www.svlark.com/2013/09/97-progress-report.html
---
I'm really enjoying the Goodlander book, and it's making me think about boat-buying a little differently. I'm not sure just how completely we'll end up embracing the approach of buying a boat with a major problem and a ticking clock, but certainly the ticking clock sounds good. I have yet to read Cap'n Fatty's master plan for rehabbing a boat, but hopefully it won't involve years of work. We'll see. He's certainly an engaging writer, one way or the other.
We're trying to make ourselves get serious about moving out but it's kinda hard...


Namespace BonEngineSharp.Defs
Classes
AssetType
Asset types enum - used to identify type of assets.
This is not really necessary in C#, but exists to match the definition in the CPP side of it.
AudioFormats
Audio format options.
BlendModes
Possible rendering blend modes for drawing images and shapes.
BonFeatures
Determine which features to enable on initialization. This allow you to enable / disable special runtime features and flags.
DiagnosticsCounters
Diagnostics counters we can query from the Diagnostics manager.
EngineStates
Different states the engine can be in. You can query engine states to better understand whats going on while debugging.
ImageFilterMode
Image filtering modes.
KeyCodes
Keyboard and mouse key codes. Use these codes to query the Input manager directly, or to bind keys to game actions and query actions instead.
LogLevel
Log levels to use when writing logs.
SoundChannelId
A wrapper around System.Int32 to hold channel id. Channel ids represent the mix channel we play sound effects on. You can use this channel id to control the playing sound volume, panning, duration ect. Note that there are two special channel ids you should watch for: AllChannels (-1), used to affect all channels at once, and Invalid (-2), which is what you get when engine couldn't play a sound.
TextInputData
Contains text input information from the input manager.
UIAlignment
UI general alignment.
UIElementState
UI Element state.
UIElementType
All built-in UI types.
UIImageTypes
UI Image drawing types. This defines how to scale and what parts of the UI image to draw.
UISides
Represent value with 4 sides - top, bottom, left, right.
UISize
UI size - represent a UI element size with width, height and types.
UISizeType
UI Size unit types.
UITextAlignment
UI text alignment.
UITextInputMode
UI text input modes - determine what type of characters a UI text input accepts, and how to process them.
WindowModes
Window startup modes - used when recreating the window via the Gfx manager.


A.I.: ARTIFICIAL INTELLIGENCE (a film review by Mark R. Leeper)
CAPSULE: A very short story is expanded into a longish but powerful film about time, durability, and purpose of existence by the combined efforts of the late Stanley Kubrick and of Steven Spielberg. There are some very nice sequences in this film, but overall it is stylistically uneven. The story of the robot that wanted to be human is getting a little hackneyed for this film to really work throughout. Though some of the views of the future are very powerful. Rating: 9 (0 to 10), +3 (-4 to +4)
Permanence is a major theme of A.I. I am told a glass bottle takes a million years to biodegrade. The purpose of that existence may end after a month--essentially its first moments of life, but the bottle goes on. Its whole reason for existence is just the barest beginning of its journey. This is bad for the environment, but not really for the bottle because it has no feelings. But what if a machine could be given feelings and told to love one person? What happens to a machine that has emotions, but also longevity far greater than that of its reason for existence? And can a machine really have feelings? If not, why not since an accumulation of biological cells, what a human is, can have feelings? These questions are the heart of A.I.
A.I. was a project developed by Stanley Kubrick going back to the early 1990s. It used as a springboard the 1969 short story "Super-toys Last All Summer Long," by Brian W. Aldiss. (A copy of the story can currently be found at http://www.visual-memory.co.uk/amk/doc/0068.html.) I am not sure I understand why Kubrick saw so much potential in this particular story. It seems to me to be a variation on an episode on "The Lateness of the Hour," an episode of THE TWILIGHT ZONE. (The story in the film seems to lean more toward a different episode, "I Sing the Body Electric.") However, Arthur C. Clarke's "The Sentinel" would also seem an unpromising source and it made one of the classics of cinema 2001: A SPACE ODYSSEY.
Much as he had previously done with Clarke for 2001: A SPACE ODYSSEY, Kubrick wanted to partner with Brian Aldiss on the project of adapting his story. Together they looked at a lot of variations on the narrative, none of which where suitable to Kubrick. Kubrick then called in Clarke as his partner, but they could not agree where the story should go. Kubrick tried science fiction author Bob Shaw, but Kubrick did not have a film until he brought in Ian Watson. Allegedly when Kubrick thought the time was right he arranged a two-film deal, one film on the subject of sex, one returning to the science fiction field where he had enjoyed working in the past. Those films were, of course, EYES WIDE SHUT and A.I. Unfortunately, Kubrick lived only long enough to complete the former and to get the project moving on the latter. Enter Steven Spielberg to inherit the A.I. project and bring it to completion. Now, of course, it is unclear what is Kubrick's contribution and what is Spielberg's, but the resulting film is very different from either director's previous work.
Whatever the truth is on who contributed what, the film is wildly uneven in style like a landscape painted by a committee. That is not necessarily a bad thing, it just makes the future world seem a bit schizophrenic. It uses a variation on the Aldiss story as a core, but abruptly goes off in other directions. There is even some feeling that the story was being held back by spending too much time on the Aldiss themes.
One might speculate that Kubrick filmed the first and last sections of the film and Spielberg did only the middle section. Certainly acting styles seem that way. In the first part of the film people appear pensive and insular in their own shells. Not unlike the characters in 2001: A SPACE ODYSSEY, people just do not seem to be connecting with each other. The middle section of the film is set in a frenetic world like from TOTAL RECALL OF BLADERUNNER BEYOND THUNDERDOME. The viewer should be warned that this is a film of about two and a half hours. Parts of the film, particularly toward the end when the pace slows, seem drawn out as it is. If the viewer is expecting the film to wrap up, the final reel may seem interminable.
The story follows David (played by Haley Joel Osment), the first and only robot who has been given a capacity to love. David is built for a couple, Monica and Henry Swinton (Francis O'Connor and Sam Robards), whose own son Martin is in a frozen state. At first Monica wants no part of an artificial surrogate son, but that resolve starts to crumble. The story takes off from there. This is a lot like the plot of BICENTENNIAL MAN or Ray Bradbury's "I Sing the Body Electric," but the story goes places that those stories do not. It would be a spoiler to say how, but eventually we are introduced a friend for David, a Gigolobot named Gigolo Joe, programmed to dance through life as he performs his Gigolo function. That programming cannot be dropped even when he is on the run for his life. Like David's, his programming outlives its purpose.
Spielberg (or whoever) did a fairly good job of setting the story in some indeterminate future. For once an automobile looks like it might have come from a future world. In the first part the whole world seems subdued.  A crisper image is used for the middle section of the film and toward the end the camera returns to a soft focus. David, the main character, has a special makeup that makes his skin look glossy like smooth plastic. Most of the film is shot in cold lifeless colors, though there are some reds and earth tones in the middle section of the film. The middle section also has a faster pace with images suddenly coming very fast at the viewer. It is like going from sensory deprivation to sensory overload. The final part of the film is again slow and introspective. Most Dreamworks films work an image of the moon into the story someplace, more or less as their trademark. A.I. goes a little overboard in giving us a moon image that is hard to miss. Several celebrity voices are used in the film, though frequently they are only subliminally noticeable. I recognized Robin Williams as the voice of a futuristic vending machine, but reading the end-credits I realized I had missed several of the others. It should make for an interesting game for owners of the future DVD to search out the other voices.
Steven Spielberg was perhaps a very good choice as a replacement for Kubrick. A director of some stature was needed, but also because few directors could handle the poignancy of the final parts of the story. The film has already been criticized for its sentimentality, but the emotion is precisely the point. Spielberg is one of the few directors of mass audience films who are not afraid to put emotion into a film when it is appropriate. The critics who complain about Spielberg's sentimentality would rob cinema of much of its impact. The final dilemma of this film is an emotional one and that is how the story should be told. I rate A.I. a 9 on the 0 to 10 scale and a +3 on the -4 to +4 scale.
Mark R. Leeper<EMAIL_ADDRESS>Copyright 2001 Mark R. Leeper
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Snookes1516.github.io
Descriptive Writing, Imagery Techniques by cazzwebbo. Shorthand is an abbreviated symbolic writing method that increases speed and brevity of writing as compared to longhand, a more common method of writing a language.
Storyboarding is an important process in all kinds of creative projects. Having a storyboard template would be handy and helpful in accomplishing the task faster. Software Test Automation Design - Testing Education. Creative content writing techniques ppt - sipirokcoffee.com.  Sample quotation in essay. My personal philosophy of life essay essay responsibility of parents words, bad essay writing kamarajar all about me essay bunting tes. Theatre or cinema essay paradiso.
Another Lewington production, this time it s my Creative Writing powerpoint for you to enjoy and share. Intro to Creative Writing its Techniques. 2016: Discovery Short Story: DOCX (N/A) 2016: minty 19/20 mod c essay : DOCX (N/A) 2016: This technique sheet contains Poetic Devices, photography techniques. Free printable narrative essay assignments to use in your classroom or to improve your narrative writing skills, a great resource.
The 7 Habits of Highly Effective People. Find essays and research papers on Writing at StudyMode.com. We've helped millions of students since 1999. Join the world's largest study community. Using creative writing techniques ppt - multistorythinking.com. Coaching Mentoring - Richard Rizk Law Office. Types of Writing Narrative. Descriptive. Expository. Persuasive. Creative Note: These writing types can overlap. General Format // Purdue Writing. The Purdue University Online Writing Lab serves writers from around the world and the Purdue University Writing Lab helps writers on Purdue's campus. It is hard to believe we finished “Digital Habitat: Stewarding technology for communities” back in 2009. 7 years later the book is still selling on Amazon. PowerPoint Presentation - Types of Writing.
Low ability creative writing english scheme SOW MTP story writing. Creative Writing General Tips - University of Vermont.
Modal ads, ads that reorganize content, and autoplaying video ads were among the most disliked.  Art creative writing techniques ppt - platiniumcoiffure.com.
7 Techniques from Creative Writing You Can Use to Improve.
A childhood dream essay assignment am essay i life who hero example plan essay proposal essay examples academic with analysis, life experience short essay bhagat. The Most Hated Advertising Techniques - Nielsen Norman Group. 英文简历模版整合_百度文库. EasyBib — your online writing hub All the tools to submit your paper with confidence. 英文简历：高效英文简历样板 来源：21英语网 日期: 2011-03-21 一份出色的 Resume，是向外企求职的关键之一。不了解有关的常识. Workers rights essay and duties Harvard essay application ucf My ideal boss essay living room essay on interview with examples pt3 management essay topic internet. Narrative Essay Worksheets Writing Assignments.
Creative Writing Techniques PowerPoint Presentation Teaching Creative Writing - SlideShare. Creative Curriculum.net An Overview for Families Agenda Overview of The Creative Curriculum Overview of CreativeCurriculum.net Teacher Site Observations Child. Title: The 7 Habits of Highly Effective People Author: DOCULAND Last modified by: Datta Created Date: 7/16/2002 11:03:58 AM Document presentation format. Creative Writing Techniques PowerPoint Presentation, PPT - DocSlides- Techniques!. Narrative Point of View. A narrative can be told from a variety of perspectives. Bored of Studies - Student online community, resources. Teaching Creative Writing creative efforts Value their creative attributes Teach them creative thinking techniques Create a climate.
Turnitin provides instructors with the tools to prevent plagiarism, engage students in the writing process, and provide personalized feedback. Creative Writing General Tips there are writers writing. And as a creative writer, the skills or techniques being practiced in a given assignment. Creative Writing Powerpoint - SlideShare. Learning about creative writing techniques ppt - rugby.uz.
Here s how you can use popular creative writing techniques to make your essays more interesting and improve your marks. EasyBib: Free Bibliography Generator - MLA, APA, Chicago. Writing Essays and Research Papers StudyMode.com. Title: Coaching Mentoring Author: Rick Sell Last modified by: Rick Sell Created Date: 5/2/1997 7:54:38 AM Document presentation format: On-screen.
Test Automation Design Doug Hoffman, BA, MBA, MSEE, ASQ-CSQE Software Quality Methods, LLC. (SQM) www.SoftwareQualityMethods.com doug.hoffman@acm.org.


Introduction
Word2Vec was introduced by a team of researchers at Google in 2013, which is one of the most widely used neural network language models.
The underlying assumption of Word2Vec is that two words sharing similar contexts also share a similar meaning (Distributional Hypothesis) and consequently a similar vector representation from the model. For instance, “dog”, “puppy” and “pup” are often used in similar situations, with similar surrounding words like “good”, “fluffy” or “cute”, and according to Word2Vec they will therefore share a similar vector representation.
From this assumption, Word2Vec can be used to find out the relations between words in a dataset, compute the similarity between them, or use the vector representation of those words as input for other applications such as text classification or clustering.
How does Word2Vec learn the representation of a word?
The Word2Vec learns the representation of words from sentences. The word we focus on to learn its representation is called center word, and the words around it are called context words. The window size C determines the number of context words which is considered.
Here, let’s see the algorithm by using an example sentence: “The cute cat jumped over the lazy dog”.
- All of the following figures consider “cat” as the center word.
- According to the window size C, we can see that the number of context words is changed.
So, in order to learn the representation of a word, we will try to learn the context in which a particular word appears. Now the question is how can we do that?
Main algorithm
It does so in one of two ways, either using context to predict a target word (a method known as continuous bag of words, or CBOW), or using a word to predict a target context, which is called Skip-gram.
An intuitive understanding of Skip-gram
The ideas behind the two algorithms are quite similar, so I take Skip-gram to illustrate how it works.
Skip-gram uses the current word to predict its neighbors (i.e., its context). To limit the number of words in each context, let’s set the parameter window size to 2. As the window slides against the training text, we create our training samples in our training dataset:
We cannot feed the neural network with inputs of actual characters, so we have to find a way to represent these words. One way to do that is to create a vocabulary of all the words in our text corpus and then to encode our word as a vector of the same dimension of our vocabulary. Each dimension can be thought as a word in our vocabulary. So we will have a vector with all zeros and a 1 which represents the corresponding word in the vocabulary. This encoding technique is called one-hot encoding. Considering our example, suppose our text corpus contains only one sentence made of the words“the”, “cute”, “cat”, “jumped”,“over”, “lazy”, “dog”, we would have the following vector representation:
Here we have transformed the eight-word sentence into a \( 8 \times 7 \) matrix, with the 7 being the size of the vocabulary (“the” is repeated). In the real practice, the size of vocabulary can be very large, which looks like what is shown below:
It should be noted that such a word representation is so sparse and tells nothing about the relation between word pairs (as the dot product of each pair of word vector is 0, which produces a cosine distance of 0). Yet, we can use these one-hot encodings to train our model. After that, we will get a more efficient representation of word semantics.
Now that we have our Skip-gram training dataset that we extracted from existing running text, let’s glance at how we use it to train a basic neural language model that predicts the context word. We start with a sample in our dataset - using the center word cat to predict the context word cute. The training includes the following operations:
- First, multiply the one-hot encoding vector \(x\) (\( V \times 1 \) dimension) and the word embedding matrix \(W\) of size \(V \times N\) (\(V\) is the size of the vocabulary and \(N\) is the dimension of the word embedding; the elements in the matrix \(W\) is initialized with random numbers) gives us the embedding vector of the input word \(w_i\) (i.e., the word cat in our case).
- This newly discovered embedding vector of dimension \(N\) forms the hidden layer.
- Multiply the hidden layer vector and the word context matrix \(W'\) of size \(N \times V\) produces the predicted vector of the target word \(\hat{y}\) (i.e., the word cute in our case).
- The predicted vector \(\hat{y}\) is further compared to the actual target vector \(y\) (of the word cute with one-hot encoding), and the error is used to update the word embedding matrix \(W\) using back-propagation. The next time the model get cat as the input, it is more likely to guess cute.
- Note: the above process can be computationally intensive. To improve the performance, the technique of negtive-sampling is applied.
The above operations conclude the first step of the training. We proceed to do the same process with the next sample in our dataset, and then the next, until we have covered all the samples in the dataset. That concludes one epoch of training. We do it over again for a number of epochs, and then we have the so called Word2Vec model.
The by-product of the model - the embedding matrix - is extremely useful, as the weights are constantly adjusted during the whole process of training. Therefore, it can be used to represent the relations between words.
We will soon show the magical word embeddings in our demo!
Word2Vec Demo
Python implementation
For training and evaluating, we use Gensim, a python package for language modeling which started with topic models (LDA) and grew into neural word representations (Word2Vec, GloVe).
Training the Word2Vec model
Here, we use the Word2Vec model downloaded from the text-classification project, which was trained on a large Chinese corpus (Baidu Baike). The current word2vec model contains 209969 word vectors with 200 dimensions.
Loading the model
The following code is used to load the model and store the word vectors in a dictionary.
import gensim
from os.path import join
# directory path and model
dir_path = '\\baike.vectors'
file_name = 'baike.vectors.bin'
# load model
w2v_model = gensim.models.KeyedVectors.load_word2vec_format(join(dir_path, file_name), binary = True)
# get dictionary
vocab_dic = w2v_model.wv.vocab
# get vocabulary
vocab_ls = vocab_dic.keys()
# number of vocabularies in the dictionary
print('There are %s vocabularies in the dictionary.' % str(len(vocab_ls)))
There are 209969 vocabularies in the dictionary.
Playing around with the pre-trained model
First, let’s obtain the vectors for terms, as it is the most basic operation.
It should be noted that:
- We can only obtain vectors for terms the model is familiar with (i.e., words in the dictionary). For unknown words, the model is unable to infer their vectors.
- Alternatively, FastText model can be used to obtain the vectors of unknown words.
For example, we would like to obtain the vector (200 dimensions) for the term “苹果”.
w2v_model['苹果']
Moving on, Word2Vec supports several word similarity tasks. Typically, the cosine similarity is used as the metric: $$ Cosine \ Similarity = \frac{U^TV}{\left|U\right|\left|V\right|} $$
Let’s see how the similarity intuitively decreases as the words get less and less similar.
import pandas as pd
pairs = [('汽车', '货车'), # a minivan is a kind of vehicle
('汽车', '自行车'), # a bicycle is a wheeled vehicle
('汽车', '船'), # a boat has no wheels, but still a vehicle
('汽车', '谷物'), # cereal is a kind of food
('汽车', '共产主义')] # communism is a political belief
df_ls = []
for w1, w2 in pairs:
df_ls += [[w1, w2, '%.3f' % w2v_model.similarity(w1, w2)]]
pd.DataFrame(df_ls, columns = ['Word 1', 'Word 2', 'Similarity'])
| Word 1 | Word 2 | Similarity |
|---|---|---|
| 汽车 | 货车 | 0.526 |
| 汽车 | 自行车 | 0.533 |
| 汽车 | 船 | 0.157 |
| 汽车 | 谷物 | 0.102 |
| 汽车 | 共产主义 | 0.061 |
We can print the 5 most similar words to “香港大学”.
top_similar = w2v_model.most_similar(['香港大学'], topn = 5)
# formatting
top_similar_ls = []
for i in range(len(top_similar)):
top_similar_ls += [[top_similar[i][0], '%.3f' % top_similar[i][1]]]
pd.DataFrame(top_similar_ls, columns = ['Similar Word', 'Similarity'])
| Similar Word | Similarity |
|---|---|
| 香港中文大学 | 0.912 |
| 美国哥伦比亚大学 | 0.825 |
| 新加坡国立大学 | 0.824 |
| 香港浸会大学 | 0.794 |
| 加拿大多伦多大学 | 0.792 |
The model can also detect words that do not belong to a certain semantic category. For example, we have a sequence of words {中国, 美国, 苹果, 英国, 日本}, and based on the model’s prediction, “苹果” does not belong to the category of country.
w2v_model.doesnt_match('中国 美国 苹果 英国 日本'.split())
'苹果'
The model can even do some analogical inference on relations (A is to B as C is to ?). The most well known example is the “Man is to King as Woman is to Queen” analogy, which can be represented as $King - Man + Woman = Queen$.
Now, let’s have a try using our model.
def analogy(x1, x2, y1):
result = w2v_model.most_similar(positive=[y1, x2], negative=[x1])
return result[0][0]
print('国王 - 男人 + 女人 = %s' % analogy('男人', '女人', '国王'))
print('中国 - 北京 + 东京 = %s' % analogy('北京', '东京', '中国'))
国王 - 男人 + 女人 = 王后
中国 - 北京 + 东京 = 日本
Finally, we can visualize word vectors in the semantic space. To project the high-dimensional word embeddings to a 2D space, we can reduce dimensionality using PCA and t-SNE, which obtains lower-dimensional data while preserving as much of the data’s variation as possible. Both methods are implemented in the machine learning package sciket-learn.
# scikit-learn: reduce dimensionality
import numpy as np
from sklearn.decomposition import PCA
# matplotlib: interactive plot
%matplotlib notebook
import matplotlib.pyplot as plt
plt.style.use('ggplot')
# show font in Chinese
from pylab import *
mpl.rcParams['font.sans-serif'] = ['SimHei']
# display PCA-based 2D scatterplot
def display_pca_scatterplot(model, words=None, sample=0):
if words == None:
if sample > 0:
words = np.random.choice(list(model.vocab.keys()), sample)
else:
words = [word for word in model.vocab]
word_vectors = np.array([model[w] for w in words])
two_dim = PCA().fit_transform(word_vectors)[:, :2]
plt.figure(figsize = (6, 6), dpi = 300)
plt.scatter(two_dim[:, 0], two_dim[:, 1], edgecolors = 'k', c = 'r')
for word, (x,y) in zip(words, two_dim):
plt.text(x + 0.05, y + 0.05, word)
# words to plot
word_plot = ['中国', '日本', '英国', '美国', '印度', '意大利', '西班牙', '新加坡', '菲律宾',
'苹果', '香蕉', '西瓜', '草莓', '葡萄', '哈密瓜', '火龙果', '奇异果', '车厘子',
'老虎', '狮子', '大象', '青蛙', '绵羊', '长颈鹿', '藏羚羊', '梅花鹿', '猫头鹰']
display_pca_scatterplot(w2v_model, word_plot)
References
- Stanford CS224n: Natural Language Processing with Deep Learning
- The illustrated Word2Vec
- Demystifying Neural Network in Skip-Gram Language Modeling
- gensim documentation


[gecode-users] empty array with argmin (and min)
Kish Shen
kisshen at cisco.com
Fri Jun 26 20:25:25 CEST 2015
Hi,
argmin throws an exception when the array is empty, which surprised me.
I expected the constraint to fail, because for an empty array, the index
for the minimum does not exist, i.e. the index has an empty domain,
which should mean failure.
It seems that min also throws an exception for an empty array. and
although it looks less clear-cut in this case, it still seem more
logical to me that min should also fail rather than throw an exception.
I guess you might not want to do this with min as it will mean that
IntExpr might fail, but argmin cannot occur in IntExpr.
To me, it seems reasonable that the user may want to call these
constraints with an empty array -- the array may be generated from data,
and finding no variables seems a reasonable possibility.
Cheers,
Kish
More information about the users
mailing list


| Top |
| #define | G_THREADS_IMPL_POSIX |
| #define | G_THREADS_IMPL_WIN32 |
| enum | GThreadPriority |
| GStaticMutex | |
| #define | G_STATIC_MUTEX_INIT |
| struct | GStaticRecMutex |
| #define | G_STATIC_REC_MUTEX_INIT |
| struct | GStaticRWLock |
| #define | G_STATIC_RW_LOCK_INIT |
| struct | GStaticPrivate |
| #define | G_STATIC_PRIVATE_INIT |
These APIs are deprecated. You should not use them in new code. This section remains only to assist with understanding code that was written to use these APIs at some point in the past.
void
g_thread_init (gpointer vtable
);
g_thread_init
has been deprecated since version 2.32 and should not be used in newly-written code.
This function is no longer necessary. The GLib threading system is automatically initialized at the start of your program.
If you use GLib from more than one thread, you must initialize the
thread system by calling g_thread_init()
.
Since version 2.24, calling g_thread_init()
multiple times is allowed,
but nothing happens except for the first call.
Since version 2.32, GLib does not support custom thread implementations
anymore and the vtable
parameter is ignored and you should pass NULL
.
<note><para>g_thread_init()
must not be called directly or indirectly
in a callback from GLib. Also no mutexes may be currently locked while
calling g_thread_init()
.</para></note>
<note><para>To use g_thread_init()
in your program, you have to link
with the libraries that the command <command>pkg-config --libs
gthread-2.0</command> outputs. This is not the case for all the
other thread-related functions of GLib. Those can be used without
having to link with the thread libraries.</para></note>
vtable |
a function table of type GThreadFunctions, that provides
the entry points to the thread system to be used. Since 2.32,
this parameter is ignored and should always be |
gboolean g_thread_supported ();
g_thread_supported
is deprecated and should not be used in newly-written code.
This macro returns TRUE
if the thread system is initialized,
and FALSE
if it is not.
For language bindings, g_thread_get_initialized()
provides
the same functionality as a function.
gboolean
g_thread_get_initialized (void
);
g_thread_get_initialized
is deprecated and should not be used in newly-written code.
Indicates if g_thread_init()
has been called.
Since 2.20
GThread * g_thread_create (GThreadFunc func
,gpointer data
,gboolean joinable
,GError **error
);
g_thread_create
has been deprecated since version 2.32 and should not be used in newly-written code.
Use g_thread_new()
instead
This function creates a new thread.
The new thread executes the function func
with the argument data
.
If the thread was created successfully, it is returned.
error
can be NULL
to ignore errors, or non-NULL
to report errors.
The error is set, if and only if the function returns NULL
.
This function returns a reference to the created thread only if
joinable
is TRUE
. In that case, you must free this reference by
calling g_thread_unref()
or g_thread_join()
. If joinable
is FALSE
then you should probably not touch the return value.
func |
a function to execute in the new thread |
|
data |
an argument to supply to the new thread |
|
joinable |
should this thread be joinable? |
|
error |
return location for error, or |
GThread * g_thread_create_full (GThreadFunc func
,gpointer data
,gulong stack_size
,gboolean joinable
,gboolean bound
,GThreadPriority priority
,GError **error
);
g_thread_create_full
has been deprecated since version 2.32 and should not be used in newly-written code.
The bound
and priority
arguments are now ignored.
Use g_thread_new()
.
This function creates a new thread.
void g_thread_set_priority (GThread *thread
,GThreadPriority priority
);
g_thread_set_priority
has been deprecated since version 2.32 and should not be used in newly-written code.
Thread priorities no longer have any effect.
This function does nothing.
void g_thread_foreach (GFunc thread_func
,gpointer user_data
);
g_thread_foreach
has been deprecated since version 2.32 and should not be used in newly-written code.
There aren't many things you can do with a GThread,
except comparing it with one that was returned from g_thread_create()
.
There are better ways to find out if your thread is still alive.
Call thread_func
on all GThreads that have been
created with g_thread_create()
.
Note that threads may decide to exit while thread_func
is
running, so without intimate knowledge about the lifetime of
foreign threads, thread_func
shouldn't access the GThread*
pointer passed in as first argument. However, thread_func
will
not be called for threads which are known to have exited already.
Due to thread lifetime checks, this function has an execution complexity which is quadratic in the number of existing threads.
thread_func |
function to call for all GThread structures |
|
user_data |
second argument to |
Since 2.10
GMutex * g_mutex_new ();
g_mutex_new
has been deprecated since version 2.32 and should not be used in newly-written code.
GMutex can now be statically allocated, or embedded
in structures and initialised with g_mutex_init()
.
Allocates and initializes a new GMutex.
void
g_mutex_free (GMutex *mutex
);
g_mutex_free
has been deprecated since version 2.32 and should not be used in newly-written code.
GMutex can now be statically allocated, or embedded
in structures and initialised with g_mutex_init()
.
Destroys a mutex
that has been created with g_mutex_new()
.
Calling g_mutex_free()
on a locked mutex may result
in undefined behaviour.
GCond* g_cond_new ();
g_cond_new
has been deprecated since version 2.32 and should not be used in newly-written code.
GCond can now be statically allocated, or embedded
in structures and initialised with g_cond_init()
.
Allocates and initializes a new GCond.
void
g_cond_free (GCond *cond
);
g_cond_free
has been deprecated since version 2.32 and should not be used in newly-written code.
GCond can now be statically allocated, or embedded
in structures and initialised with g_cond_init()
.
Destroys a GCond that has been created with g_cond_new()
.
Calling g_cond_free()
for a GCond on which threads are
blocking leads to undefined behaviour.
GPrivate *
g_private_new (GDestroyNotify notify
);
g_private_new
has been deprecated since version 2.32 and should not be used in newly-written code.
dynamic allocation of GPrivate is a bad idea. Use
static storage and G_PRIVATE_INIT()
instead.
Creates a new GPrivate.
void
g_static_mutex_init (GStaticMutex *mutex
);
g_static_mutex_init
has been deprecated since version 2.32 and should not be used in newly-written code.
Use g_mutex_init()
Initializes mutex
.
Alternatively you can initialize it with G_STATIC_MUTEX_INIT.
void
g_static_mutex_lock (GStaticMutex *mutex
);
g_static_mutex_lock
has been deprecated since version 2.32 and should not be used in newly-written code.
Use g_mutex_lock()
Works like g_mutex_lock()
, but for a GStaticMutex.
gboolean
g_static_mutex_trylock (GStaticMutex *mutex
);
g_static_mutex_trylock
has been deprecated since version 2.32 and should not be used in newly-written code.
Works like g_mutex_trylock()
, but for a GStaticMutex.
void
g_static_mutex_unlock (GStaticMutex *mutex
);
g_static_mutex_unlock
has been deprecated since version 2.32 and should not be used in newly-written code.
Use g_mutex_unlock()
Works like g_mutex_unlock()
, but for a GStaticMutex.
GMutex *
g_static_mutex_get_mutex (GStaticMutex *mutex
);
g_static_mutex_get_mutex
has been deprecated since version 2.32 and should not be used in newly-written code.
Just use a GMutex
For some operations (like g_cond_wait()
) you must have a GMutex
instead of a GStaticMutex. This function will return the
corresponding GMutex for mutex
.
void
g_static_mutex_free (GStaticMutex *mutex
);
g_static_mutex_free
has been deprecated since version 2.32 and should not be used in newly-written code.
Use g_mutex_clear()
Releases all resources allocated to mutex
.
You don't have to call this functions for a GStaticMutex with an unbounded lifetime, i.e. objects declared 'static', but if you have a GStaticMutex as a member of a structure and the structure is freed, you should also free the GStaticMutex.
Calling g_static_mutex_free()
on a locked mutex may result in
undefined behaviour.
void
g_static_rec_mutex_init (GStaticRecMutex *mutex
);
g_static_rec_mutex_init
has been deprecated since version 2.32 and should not be used in newly-written code.
A GStaticRecMutex must be initialized with this function before it can be used. Alternatively you can initialize it with G_STATIC_REC_MUTEX_INIT.
void
g_static_rec_mutex_lock (GStaticRecMutex *mutex
);
g_static_rec_mutex_lock
has been deprecated since version 2.32 and should not be used in newly-written code.
Locks mutex
. If mutex
is already locked by another thread, the
current thread will block until mutex
is unlocked by the other
thread. If mutex
is already locked by the calling thread, this
functions increases the depth of mutex
and returns immediately.
gboolean
g_static_rec_mutex_trylock (GStaticRecMutex *mutex
);
g_static_rec_mutex_trylock
has been deprecated since version 2.32 and should not be used in newly-written code.
Tries to lock mutex
. If mutex
is already locked by another thread,
it immediately returns FALSE
. Otherwise it locks mutex
and returns
TRUE
. If mutex
is already locked by the calling thread, this
functions increases the depth of mutex
and immediately returns
TRUE
.
void
g_static_rec_mutex_unlock (GStaticRecMutex *mutex
);
g_static_rec_mutex_unlock
has been deprecated since version 2.32 and should not be used in newly-written code.
Unlocks mutex
. Another thread will be allowed to lock mutex
only
when it has been unlocked as many times as it had been locked
before. If mutex
is completely unlocked and another thread is
blocked in a g_static_rec_mutex_lock()
call for mutex
, it will be
woken and can lock mutex
itself.
void g_static_rec_mutex_lock_full (GStaticRecMutex *mutex
,guint depth
);
g_static_rec_mutex_lock_full
has been deprecated since version 2.32 and should not be used in newly-written code.
Works like calling g_static_rec_mutex_lock()
for mutex
depth
times.
mutex |
a GStaticRecMutex to lock. |
|
depth |
number of times this mutex has to be unlocked to be completely unlocked. |
guint
g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex
);
g_static_rec_mutex_unlock_full
has been deprecated since version 2.32 and should not be used in newly-written code.
Completely unlocks mutex
. If another thread is blocked in a
g_static_rec_mutex_lock()
call for mutex
, it will be woken and can
lock mutex
itself. This function returns the number of times that
mutex
has been locked by the current thread. To restore the state
before the call to g_static_rec_mutex_unlock_full()
you can call
g_static_rec_mutex_lock_full()
with the depth returned by this
function.
void
g_static_rec_mutex_free (GStaticRecMutex *mutex
);
g_static_rec_mutex_free
has been deprecated since version 2.32 and should not be used in newly-written code.
Releases all resources allocated to a GStaticRecMutex.
You don't have to call this functions for a GStaticRecMutex with an unbounded lifetime, i.e. objects declared 'static', but if you have a GStaticRecMutex as a member of a structure and the structure is freed, you should also free the GStaticRecMutex.
void
g_static_rw_lock_init (GStaticRWLock *lock
);
g_static_rw_lock_init
has been deprecated since version 2.32 and should not be used in newly-written code.
Use g_rw_lock_init()
instead
A GStaticRWLock must be initialized with this function before it can be used. Alternatively you can initialize it with G_STATIC_RW_LOCK_INIT.
void
g_static_rw_lock_reader_lock (GStaticRWLock *lock
);
g_static_rw_lock_reader_lock
has been deprecated since version 2.32 and should not be used in newly-written code.
Use g_rw_lock_reader_lock()
instead
Locks lock
for reading. There may be unlimited concurrent locks for
reading of a GStaticRWLock at the same time. If lock
is already
locked for writing by another thread or if another thread is already
waiting to lock lock
for writing, this function will block until
lock
is unlocked by the other writing thread and no other writing
threads want to lock lock
. This lock has to be unlocked by
g_static_rw_lock_reader_unlock()
.
GStaticRWLock is not recursive. It might seem to be possible to recursively lock for reading, but that can result in a deadlock, due to writer preference.
gboolean
g_static_rw_lock_reader_trylock (GStaticRWLock *lock
);
g_static_rw_lock_reader_trylock
is deprecated and should not be used in newly-written code.
Tries to lock lock
for reading. If lock
is already locked for
writing by another thread or if another thread is already waiting to
lock lock
for writing, immediately returns FALSE
. Otherwise locks
lock
for reading and returns TRUE
. This lock has to be unlocked by
g_static_rw_lock_reader_unlock()
.
TRUE
, if lock
could be locked for reading
Deprectated: 2.32: Use g_rw_lock_reader_trylock()
instead
void
g_static_rw_lock_reader_unlock (GStaticRWLock *lock
);
g_static_rw_lock_reader_unlock
is deprecated and should not be used in newly-written code.
Unlocks lock
. If a thread waits to lock lock
for writing and all
locks for reading have been unlocked, the waiting thread is woken up
and can lock lock
for writing.
Deprectated: 2.32: Use g_rw_lock_reader_unlock()
instead
void
g_static_rw_lock_writer_lock (GStaticRWLock *lock
);
g_static_rw_lock_writer_lock
is deprecated and should not be used in newly-written code.
Locks lock
for writing. If lock
is already locked for writing or
reading by other threads, this function will block until lock
is
completely unlocked and then lock lock
for writing. While this
functions waits to lock lock
, no other thread can lock lock
for
reading. When lock
is locked for writing, no other thread can lock
lock
(neither for reading nor writing). This lock has to be
unlocked by g_static_rw_lock_writer_unlock()
.
Deprectated: 2.32: Use g_rw_lock_writer_lock()
instead
gboolean
g_static_rw_lock_writer_trylock (GStaticRWLock *lock
);
g_static_rw_lock_writer_trylock
is deprecated and should not be used in newly-written code.
Tries to lock lock
for writing. If lock
is already locked (for
either reading or writing) by another thread, it immediately returns
FALSE
. Otherwise it locks lock
for writing and returns TRUE
. This
lock has to be unlocked by g_static_rw_lock_writer_unlock()
.
TRUE
, if lock
could be locked for writing
Deprectated: 2.32: Use g_rw_lock_writer_trylock()
instead
void
g_static_rw_lock_writer_unlock (GStaticRWLock *lock
);
g_static_rw_lock_writer_unlock
is deprecated and should not be used in newly-written code.
Unlocks lock
. If a thread is waiting to lock lock
for writing and
all locks for reading have been unlocked, the waiting thread is
woken up and can lock lock
for writing. If no thread is waiting to
lock lock
for writing, and some thread or threads are waiting to
lock lock
for reading, the waiting threads are woken up and can
lock lock
for reading.
Deprectated: 2.32: Use g_rw_lock_writer_unlock()
instead
void
g_static_rw_lock_free (GStaticRWLock *lock
);
g_static_rw_lock_free
has been deprecated since version 2.32 and should not be used in newly-written code.
Use a GRWLock instead
Releases all resources allocated to lock
.
You don't have to call this functions for a GStaticRWLock with an unbounded lifetime, i.e. objects declared 'static', but if you have a GStaticRWLock as a member of a structure, and the structure is freed, you should also free the GStaticRWLock.
void
g_static_private_init (GStaticPrivate *private_key
);
g_static_private_init
is deprecated and should not be used in newly-written code.
Initializes private_key
. Alternatively you can initialize it with
G_STATIC_PRIVATE_INIT.
gpointer
g_static_private_get (GStaticPrivate *private_key
);
g_static_private_get
is deprecated and should not be used in newly-written code.
Works like g_private_get()
only for a GStaticPrivate.
This function works even if g_thread_init()
has not yet been called.
void g_static_private_set (GStaticPrivate *private_key
,gpointer data
,GDestroyNotify notify
);
g_static_private_set
is deprecated and should not be used in newly-written code.
Sets the pointer keyed to private_key
for the current thread and
the function notify
to be called with that pointer (NULL
or
non-NULL
), whenever the pointer is set again or whenever the
current thread ends.
This function works even if g_thread_init()
has not yet been called.
If g_thread_init()
is called later, the data
keyed to private_key
will be inherited only by the main thread, i.e. the one that called
g_thread_init()
.
notify
is used quite differently from destructor
in g_private_new()
.
void
g_static_private_free (GStaticPrivate *private_key
);
g_static_private_free
is deprecated and should not be used in newly-written code.
Releases all resources allocated to private_key
.
You don't have to call this functions for a GStaticPrivate with an unbounded lifetime, i.e. objects declared 'static', but if you have a GStaticPrivate as a member of a structure and the structure is freed, you should also free the GStaticPrivate.
#define G_THREADS_IMPL_POSIX
G_THREADS_IMPL_POSIX
has been deprecated since version 2.32 and should not be used in newly-written code.
POSIX threads are in use on all non-Windows systems. Use G_OS_WIN32 to detect Windows.
This macro is defined if POSIX style threads are used.
#define G_THREADS_IMPL_NONE
G_THREADS_IMPL_WIN32
has been deprecated since version 2.32 and should not be used in newly-written code.
Use G_OS_WIN32 to detect Windows.
This macro is defined if Windows style threads are used.
GThreadPriority
has been deprecated since version 2.32 and should not be used in newly-written code.
Thread priorities no longer have any effect.
Thread priorities.
typedef struct _GStaticMutex GStaticMutex;
A GStaticMutex works like a GMutex.
Prior to GLib 2.32, GStaticMutex had the significant advantage that it doesn't need to be created at run-time, but can be defined at compile-time. Since 2.32, GMutex can be statically allocated as well, and GStaticMutex has been deprecated.
Here is a version of our give_me_next_number()
example using
a GStaticMutex:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
int give_me_next_number (void) { static int current_number = 0; int ret_val; static GStaticMutex mutex = G_STATIC_MUTEX_INIT; g_static_mutex_lock (&mutex); ret_val = current_number = calc_next_number (current_number); g_static_mutex_unlock (&mutex); return ret_val; } |
Sometimes you would like to dynamically create a mutex. If you don't
want to require prior calling to g_thread_init()
, because your code
should also be usable in non-threaded programs, you are not able to
use g_mutex_new()
and thus GMutex, as that requires a prior call to
g_thread_init()
. In theses cases you can also use a GStaticMutex.
It must be initialized with g_static_mutex_init()
before using it
and freed with with g_static_mutex_free()
when not needed anymore to
free up any allocated resources.
Even though GStaticMutex is not opaque, it should only be used with the following functions, as it is defined differently on different platforms.
All of the g_static_mutex_* functions apart from
g_static_mutex_get_mutex()
can also be used even if g_thread_init()
has not yet been called. Then they do nothing, apart from
g_static_mutex_trylock()
which does nothing but returning TRUE
.
All of the g_static_mutex_* functions are actually macros. Apart from taking their addresses, you can however use them as if they were functions.
#define G_STATIC_MUTEX_INIT
G_STATIC_MUTEX_INIT
is deprecated and should not be used in newly-written code.
A GStaticMutex must be initialized with this macro, before it can
be used. This macro can used be to initialize a variable, but it
cannot be assigned to a variable. In that case you have to use
g_static_mutex_init()
.
1 |
GStaticMutex my_mutex = G_STATIC_MUTEX_INIT; |
struct GStaticRecMutex { };
GStaticRecMutex
is deprecated and should not be used in newly-written code.
A GStaticRecMutex works like a GStaticMutex, but it can be locked
multiple times by one thread. If you enter it n times, you have to
unlock it n times again to let other threads lock it. An exception
is the function g_static_rec_mutex_unlock_full()
: that allows you to
unlock a GStaticRecMutex completely returning the depth, (i.e. the
number of times this mutex was locked). The depth can later be used
to restore the state of the GStaticRecMutex by calling
g_static_rec_mutex_lock_full()
. In GLib 2.32, GStaticRecMutex has
been deprecated in favor of GRecMutex.
Even though GStaticRecMutex is not opaque, it should only be used with the following functions.
All of the g_static_rec_mutex_* functions can be used even if
g_thread_init()
has not been called. Then they do nothing, apart
from g_static_rec_mutex_trylock()
, which does nothing but returning
TRUE
.
#define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT }
G_STATIC_REC_MUTEX_INIT
is deprecated and should not be used in newly-written code.
A GStaticRecMutex must be initialized with this macro before it can
be used. This macro can used be to initialize a variable, but it
cannot be assigned to a variable. In that case you have to use
g_static_rec_mutex_init()
.
1 |
GStaticRecMutex my_mutex = G_STATIC_REC_MUTEX_INIT; |
struct GStaticRWLock { };
GStaticRWLock
has been deprecated since version 2.32 and should not be used in newly-written code.
Use a GRWLock instead
The GStaticRWLock struct represents a read-write lock. A read-write lock can be used for protecting data that some portions of code only read from, while others also write. In such situations it is desirable that several readers can read at once, whereas of course only one writer may write at a time.
Take a look at the following example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
GStaticRWLock rwlock = G_STATIC_RW_LOCK_INIT; GPtrArray *array; gpointer my_array_get (guint index) { gpointer retval = NULL; if (!array) return NULL; g_static_rw_lock_reader_lock (&rwlock); if (index < array->len) retval = g_ptr_array_index (array, index); g_static_rw_lock_reader_unlock (&rwlock); return retval; } void my_array_set (guint index, gpointer data) { g_static_rw_lock_writer_lock (&rwlock); if (!array) array = g_ptr_array_new (); if (index >= array->len) g_ptr_array_set_size (array, index + 1); g_ptr_array_index (array, index) = data; g_static_rw_lock_writer_unlock (&rwlock); } |
This example shows an array which can be accessed by many readers
(the my_array_get()
function) simultaneously, whereas the writers
(the my_array_set()
function) will only be allowed once at a time
and only if no readers currently access the array. This is because
of the potentially dangerous resizing of the array. Using these
functions is fully multi-thread safe now.
Most of the time, writers should have precedence over readers. That means, for this implementation, that as soon as a writer wants to lock the data, no other reader is allowed to lock the data, whereas, of course, the readers that already have locked the data are allowed to finish their operation. As soon as the last reader unlocks the data, the writer will lock it.
Even though GStaticRWLock is not opaque, it should only be used with the following functions.
All of the g_static_rw_lock_* functions can be used even if
g_thread_init()
has not been called. Then they do nothing, apart
from g_static_rw_lock_*_trylock, which does nothing but returning TRUE
.
A read-write lock has a higher overhead than a mutex. For example, both
g_static_rw_lock_reader_lock()
and g_static_rw_lock_reader_unlock()
have
to lock and unlock a GStaticMutex, so it takes at least twice the time
to lock and unlock a GStaticRWLock that it does to lock and unlock a
GStaticMutex. So only data structures that are accessed by multiple
readers, and which keep the lock for a considerable time justify a
GStaticRWLock. The above example most probably would fare better with a
GStaticMutex.
#define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0 }
G_STATIC_RW_LOCK_INIT
is deprecated and should not be used in newly-written code.
A GStaticRWLock must be initialized with this macro before it can
be used. This macro can used be to initialize a variable, but it
cannot be assigned to a variable. In that case you have to use
g_static_rw_lock_init()
.
1 |
GStaticRWLock my_lock = G_STATIC_RW_LOCK_INIT; |
struct GStaticPrivate { };
GStaticPrivate
is deprecated and should not be used in newly-written code.
A GStaticPrivate works almost like a GPrivate, but it has one significant advantage. It doesn't need to be created at run-time like a GPrivate, but can be defined at compile-time. This is similar to the difference between GMutex and GStaticMutex.
Now look at our give_me_next_number()
example with GStaticPrivate:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
int give_me_next_number () { static GStaticPrivate current_number_key = G_STATIC_PRIVATE_INIT; int *current_number = g_static_private_get (¤t_number_key); if (!current_number) { current_number = g_new (int, 1); *current_number = 0; g_static_private_set (¤t_number_key, current_number, g_free); } *current_number = calc_next_number (*current_number); return *current_number; } |
#define G_STATIC_PRIVATE_INIT
G_STATIC_PRIVATE_INIT
is deprecated and should not be used in newly-written code.
Every GStaticPrivate must be initialized with this macro, before it can be used.
1 |
GStaticPrivate my_private = G_STATIC_PRIVATE_INIT; |


PART XIII. OPERATION OF BICYCLES AND PLAY VEHICLES
§291C-141 Effect of regulations. (a) It is a traffic infraction for any person to do any act forbidden or fail to perform any act required in this part.
(b) The parent of any child and the guardian of any ward shall not authorize or knowingly permit any such child or ward to violate this chapter.
(c) These regulations applicable to bicycles shall apply whenever a bicycle is operated upon any highway or upon any bicycle path set aside for the preferential or exclusive use of bicycles subject to those exceptions stated herein. [L 1971, c 150, pt of §1; am L 1978, c 39, §3; am L 1993, c 214, §14]
Cross References
Special rules for mopeds, see §§291C-191 to 207.


Wanna get away, but unsure where to? Fill out our questionnaire below and let us be your travel guide.
Bon voyage, ! You should go to:
So, you want to explore in a tropical climate...
With cerulean seas and verdant forests, magnificent Maya ruins and smoking volcanoes, Central America is like a tropical fairy tale – except all of it is real.
Click here to learn more about Central America.
So, you want to relax in a tropical climate...
From high mountain peaks to shimmering reefs, spicy salsa rhythms to deep rolling reggae, pirate hideouts to sugar-sand beaches, the Caribbean is dizzyingly diverse.
Click here to learn more about the Caribbean.
So, you want to explore in a temperate climate...
There simply is no way to tour Europe and not be awestruck by its natural beauty, epic history and dazzling artistic and culinary diversity.
Click here to learn more about Europe.
So, you want to relax in a temperate climate...
The heart of North America beats through towering forests, undulating fields, high-plain deserts, pulsating metropolises and offbeat oases.
Click here to learn more about North America.
So, you just want to be in a polar climate...
No place on Earth compares to this vast white wilderness of elemental forces: snow, ice, water, rock. Antarctica is simply stunning.
Click here to learn more about Antarctica.


@x:Act Reference
+ 1 Introduction
+ 2 User Manual
+ 3 System Manual
+ Reference
- Libraries
library:enum
library:escape
library:graph
library:html
library:iterator
library:lang
library:path
library:stdunit
library:typeor
library:unit
library:unparser
library:walk