working on it ...

Filters

Explore Public Snippets

Sort by

Found 586 snippets matching: iterate

    public by lbottaro  332835  2  4  0

    C# enum iteration

    This c# code allows to iterate through all element of an enum
    public enum Suit
    {
            Spades,
            Hearts,
            Clubs,
            Diamonds
    }
    
    foreach (Suit suit in Enum.GetValues(typeof(Suit)))
    {
       Console.WriteLine(suit);
    }

    public by lbottaro  2562  1  6  0

    How to create a Java HashMap and iterate through keys and values

    This is how to simply create a templated Map, using HashMap and loop through its keys and values
    final Map<String, Object> myMap = new HashMap<String, Object>();
            myMap.put("key1", "true");
            myMap.put("key2", "123");
    
    for (Map.Entry<String, Object> entry : myMap.entrySet())
    {
        System.out.println(entry.getKey() + "/" + entry.getValue());
    }                                                          

    public by CodeGuru  2065  0  4  3

    Best way to iterate Map or Properties in Java

    If you're only interested in the keys, you can iterate through the keySet() of the map:
    
        Map<String, Object> map = ...;
    
        for (String key : map.keySet()) {
            // ...
        }
    
        If you only need the values, use values():
    
        for (Object value : map.values()) {
            // ...
        }
    
        Finally, if you want both the key and value, use entrySet():
    
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            // ...
        }

    public by micurs  7727  4  9  11

    Typescript + underscore: iterating through a collection property of a class

    In this example we define a signature interface (Students) to locate a student using a student ID. In the Course class we use property getters function to provide read only access to the class members. Finally we use underscore to iterate on the Students as it was an array. The example runs on node.js with Typescript 0.9.5
    ///<reference path='../types/node.d.ts'/>
    ///<reference path='../types/underscore.d.ts'/>
    
    import _ = require("underscore");
    
    function write(msg) {
        process.stdout.write(msg+'\n');
    }
    // Index Interface to locate a student given an id
    interface Students {
      [ studentId: number ] : Student;
    }
    
    class Student {
      private _id : number;
      private _name : string;
      private _lastName : string;
      constructor ( id: number, name : string, lastName : string ) {
        this._id = id;
        this._name = name;
        this._lastName = lastName;
      }
      // Property getters for Student
      get id() :number { return this._id; }
      get lastName() : string { return this._lastName; }
    }
    
    class Course {
      private title : string;
      _participants : Students = {};
    
      constructor( t : string ) {
        this.title = t;
      }
    
      addStudent( s: Student ) {
        this._participants[s.id] = s;
      }
      getStudent( sid: number ) : Student {
        return this._participants[sid];
      }
    
      // Property getter to retrieve the participants of a Course
      get participants() {
        return _.values(this._participants)    
      }
    
    }
    
    var c = new Course("Computer Science 101");
    c.addStudent(new Student(23,"Mark","Twain"));
    c.addStudent(new Student(100,"Albert","Einstein"));
    c.addStudent(new Student(120,"Isaac","Asimov"));
    
    _.each( c.participants , (s : Student) => write(s.lastName));
     

    public by mporru @ Amazon_AWS_PHP_API  12829  16  6  0

    Amazon AWS - PHP: List objects in Bucket

    This snippet demonstrates how to list Objects in a S3 Bucket. The procedure iterates, reading 1000 snippets then reading every page until the end. In order to use this service you must enable Amazon Simple Storage Service (Amazon S3) in your account.
    <?php
    require_once('sdk.class.php');
    $s3 = new AmazonS3();
    
    $bucketName = 'myBucketName';
    $isTruncated=false;
    $lastObj = '';
    do {
    	if (!$isTruncated)
    		$response = $s3->list_objects($bucketName);	// first 1000 items
    	else 
    		$response = $s3->list_objects($bucketName, array('marker' => $lastObj)); // next items
    		
    	if (!$response->isOK())
    		break;
    	
    	$objects = $response->body->Contents;
    	foreach ($objects as $obj) {
    		echo("<b>" . $obj->Key . "</b> " . $obj->Size . " " . $obj->LastModified . "<br />");
    	}
    	$isTruncated = $response->body->IsTruncated == 'true';
    	$lastObj = $obj->Key;
    	echo("$isTruncated - $lastObj");
    } while($isTruncated)
    ?>

    public by lbottaro @ Amazon_AWS_Python_API  6323  3  8  0

    Amazon S3 Aws - How to get content information for a given bucket using boto python api

    This snippet shows how to iterate through your own Amazon S3 buckets and list the available content.
    import boto
    import boto.s3.connection
    access_key = '<aws access key>'
    secret_key = '<aws secret key>'
    
    # This code initialize the Amazon S3 connection to your account
    conn = boto.connect_s3(
            aws_access_key_id = access_key,
            aws_secret_access_key = secret_key)
    
    # Iteration through all available buckets stored into S3
    # Name and creation date are listed
    for bucket in conn.get_all_buckets():
            print "{name}\t{created}".format(
                    name = bucket.name,
                    created = bucket.creation_date,
            )
            # For each bucket get all data content put into the bucket
            for key in bucket.list():
                    # Get name, size and date
                    print "{name}\t{size}\t{modified}".format(
                            name = key.name,
                            size = key.size,
                            modified = key.last_modified,
                            )

    public by lbottaro  2754  0  6  1

    C# linq expression to check all data in a given List

    This c# linq lambda function example shows how to verify if all items in a List are present in another List object. You don't need to loop or iterate for each element, just use the All extension method.
    List<string> myList = new List<string>();
    myList.Add("123");
    myList.Add("456");
    
    // myTargetList is a given List<string>
    
    Assert.IsTrue(myList.All(x => myTargetList.Contains(x)), "myList has element missing in myTargetList!"));

    public by lbottaro  2476  1  5  0

    Linux bash switch

    Linux bash switch to iterate through parameters passed to a script. The switch is able to detect optional parameter and mandatory inline fields
    while [ "$1" != "" ] ; do
       case $1 in
         -h | --help )
           usage
           exit 0
           ;;
         -v | --version )
           version
           exit 0
           ;;
         -b=* | --build-scripts-dir=* )
          my_build_scripts_dir=$1
          my_build_scripts_dir=${my_build_scripts_dir#--build-scripts-dir=}
          my_build_scripts_dir=${my_build_scripts_dir#-b=}
          if [ "$my_build_scripts_dir" == "" ]; then
            my_build_scripts_dir="."
          fi
          ;;
          -*)
           usage
           echo $1: unknown option
           exit 1
           ;;
         * )
          case $param in
            0 )
             my_stream=$1 
             param=$(($param + 1))
             ;;
            1 )
             my_r_state=$1 
             param=$(($param + 1))
             ;;
            2 )
             my_product_name=$1 
             param=$(($param + 1))
             ;;
            3 )
              usage
              echo $1: unknown parameter
              exit 1
             ;;
          esac
          ;;
       esac
       shift
    done
    

    public by juntalis  3826  8  6  0

    Reimplementation of rmtree supporting Windows reparse points

    Ctypes-based implementation of shutil.rmtree that correctly handles Windows reparse point folders. (symbolic links, junctions, etc) As of Python 2.7.5, the builtin shutil.rmtree does not detect the presence of reparse points. (junctions and symbolic links) As a result, any reparse point folder found during the execution of shutil.rmtree is itera
    #!python.exe
    # encoding: utf-8
    from __future__ import with_statement
    import os, ctypes, sys
    from ctypes.wintypes import DWORD, INT, LPWSTR, LONG, WORD, BYTE, WCHAR
    
    # Some utility wrappers for pointer stuff. 
    class c_void(ctypes.Structure):
        # c_void_p is a buggy return type, converting to int, so
        # POINTER(None) == c_void_p is actually written as
        # POINTER(c_void), so it can be treated as a real pointer.
        _fields_ = [('dummy', ctypes.c_int)]
    
        def __init__(self, value=None):
            if value is None: value = 0
            super(c_void, self).__init__(value)
    
    def POINTER(obj):
        ptr = ctypes.POINTER(obj)
        # Convert None to a real NULL pointer to work around bugs
        # in how ctypes handles None on 64-bit platforms
        if not isinstance(ptr.from_param, classmethod):
            def from_param(cls, x):
                if x is None: return cls()
                return x
    
            ptr.from_param = classmethod(from_param)
        return ptr
    
    # Shadow built-in c_void_p
    LPVOID = c_void_p = POINTER(c_void)
    
    # Globals
    NULL = LPVOID(0)
    kernel32 = ctypes.WinDLL('kernel32')
    advapi32 = ctypes.WinDLL('advapi32')
    _obtained_privileges = []
    
    # Aliases to functions/classes, and utility lambdas
    cast = ctypes.cast
    byref = ctypes.byref
    sizeof = ctypes.sizeof
    WinError = ctypes.WinError
    hasflag = lambda value, flag: (value & flag) == flag
    
    # Constants derived from C
    INVALID_HANDLE_VALUE = -1
    
    # Desired access for OpenProcessToken
    TOKEN_ADJUST_PRIVILEGES = 0x0020
    
    # SE Privilege Names
    SE_RESTORE_NAME = 'SeRestorePrivilege'
    SE_BACKUP_NAME = 'SeBackupPrivilege'
    
    # SE Privilege Attributes
    SE_PRIVILEGE_ENABLED = 0x00000002L
    
    # Access
    FILE_ANY_ACCESS = 0
    
    # CreateFile flags
    FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
    FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
    
    # Generic access
    GENERIC_READ = 0x80000000L
    GENERIC_WRITE = 0x40000000L
    GENERIC_RW = GENERIC_READ | GENERIC_WRITE
    
    # File shared access
    FILE_SHARE_READ = 0x00000001
    FILE_SHARE_WRITE = 0x00000002
    FILE_SHARE_DELETE = 0x00000004
    FILE_SHARE_ALL = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
    
    # File stuff
    OPEN_EXISTING = 3
    FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
    FILE_DEVICE_FILE_SYSTEM = 0x00000009
    
    # Utility lambdas for figuring out ctl codes
    CTL_CODE = lambda devtype, func, meth, acc: (devtype << 16) | (acc << 14) | (func << 2) | meth
    
    # Methods
    METHOD_BUFFERED = 0
    
    # WinIoCtl Codes
    FSCTL_GET_REPARSE_POINT = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
    FSCTL_DELETE_REPARSE_POINT = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_ANY_ACCESS)
    
    # Reparse Point buffer constants
    MAX_NAME_LENGTH = 1024
    MAX_REPARSE_BUFFER = 16 * MAX_NAME_LENGTH
    REPARSE_GUID_DATA_BUFFER_HEADER_SIZE = (2 * sizeof(WORD)) + (sizeof(DWORD) * 5)
    
    # For our generic reparse buffer
    MAX_GENERIC_REPARSE_BUFFER = MAX_REPARSE_BUFFER - REPARSE_GUID_DATA_BUFFER_HEADER_SIZE
    
    # Type aliases
    UCHAR = ctypes.c_ubyte
    ULONG_PTR = ctypes.c_ssize_t
    LPDWORD = POINTER(DWORD)
    
    # CTypes-based wrapper classes
    class BOOL(INT):
        """
        Wrapper around ctypes.wintypes.INT (ctypes.c_int) to make BOOL act a bit more like
        a boolean.
        """
    
        @classmethod
        def from_param(cls, value):
            if isinstance(value, ctypes._SimpleCData):
                return BOOL(value.value)
            elif not value or value is None:
                return BOOL(0)
            else:
                raise TypeError('Dont know what to do with instance of {0}'.format(type(value)))
    
        def __eq__(self, other):
            value = bool(self.value)
            if isinstance(other, bool):
                return value and other
            elif isinstance(other, ctypes._SimpleCData):
                return value and bool(other.value)
            else:
                return value and bool(other)
    
        def __hash__(self):
            return hash(self._as_parameter_)
    
    class HANDLE(ULONG_PTR):
        """
        Wrapper around the numerical representation of a pointer to
        add checks for INVALID_HANDLE_VALUE
        """
        NULL = None
        INVALID = None
    
        def __init__(self, value=None):
            if value is None: value = 0
            super(HANDLE, self).__init__(value)
            self.autoclose = False
    
        @classmethod
        def from_param(cls, value):
            if value is None:
                return HANDLE(0)
            elif isinstance(value, ctypes._SimpleCData):
                return value
            else:
                return HANDLE(value)
    
        def close(self):
            if bool(self):
                try:
                    CloseHandle(self)
                except:
                    pass
    
        def __enter__(self):
            self.autoclose = True
            return self
    
        def __exit__(self, exc_typ, exc_val, trace):
            self.close()
            return False
        
        def __del__(self):
            if hasattr(self, 'autoclose') and self.autoclose:
                CloseHandle(self)
    
        def __nonzero__(self):
            return super(HANDLE, self).__nonzero__() and \
                   self.value != HANDLE.INVALID.value
    
    class GUID(ctypes.Structure):
        """ Borrowed small parts of this from the comtypes module. """
        _fields_ = [
            ('Data1', DWORD),
            ('Data2', WORD),
            ('Data3', WORD),
            ('Data4', (BYTE * 8)),
        ]
    
    # Ctypes Structures
    class LUID(ctypes.Structure):
        _fields_ = [
            ('LowPart', DWORD),
            ('HighPart', LONG),
        ]
    
    class LUID_AND_ATTRIBUTES(LUID):
        _fields_ = [('Attributes', DWORD)]
    
    class GenericReparseBuffer(ctypes.Structure):
        _fields_ = [('PathBuffer', UCHAR * MAX_GENERIC_REPARSE_BUFFER)]
    
    class ReparsePoint(ctypes.Structure):
        """
        Originally, Buffer was a union made up of SymbolicLinkBuffer, MountpointBuffer,
        and GenericReparseBuffer. Since we're not actually doing anything with the buffer
        aside from passing it along to the native functions, however, I've gone ahead
        and cleaned up some of of the unnecessary code.
        """
        
        _fields_ = [
            ('ReparseTag', DWORD),
            ('ReparseDataLength', WORD),
            ('Reserved', WORD),
            ('ReparseGuid', GUID),
            ('Buffer', GenericReparseBuffer)
        ]
    
    # Common uses of HANDLE
    HANDLE.NULL = HANDLE()
    HANDLE.INVALID = HANDLE(INVALID_HANDLE_VALUE)
    LPHANDLE = POINTER(HANDLE)
    
    # C Function Prototypes
    CreateFile = kernel32.CreateFileW
    CreateFile.restype = HANDLE
    CreateFile.argtypes = [LPWSTR, DWORD, DWORD, LPVOID, DWORD, DWORD, HANDLE]
    
    GetFileAttributes = kernel32.GetFileAttributesW
    GetFileAttributes.restype = DWORD
    GetFileAttributes.argtypes = [LPWSTR]
    
    RemoveDirectory = kernel32.RemoveDirectoryW
    RemoveDirectory.restype = BOOL
    RemoveDirectory.argtypes = [LPWSTR]
    
    CloseHandle = kernel32.CloseHandle
    CloseHandle.restype = BOOL
    CloseHandle.argtypes = [HANDLE]
    
    GetCurrentProcess = kernel32.GetCurrentProcess
    GetCurrentProcess.restype = HANDLE
    GetCurrentProcess.argtypes = []
    
    OpenProcessToken = advapi32.OpenProcessToken
    OpenProcessToken.restype = BOOL
    OpenProcessToken.argtypes = [HANDLE, DWORD, LPHANDLE]
    
    LookupPrivilegeValue = advapi32.LookupPrivilegeValueW
    LookupPrivilegeValue.restype = BOOL
    LookupPrivilegeValue.argtypes = [LPWSTR, LPWSTR, POINTER(LUID_AND_ATTRIBUTES)]
    
    AdjustTokenPrivileges = advapi32.AdjustTokenPrivileges
    AdjustTokenPrivileges.restype = BOOL
    AdjustTokenPrivileges.argtypes = [HANDLE, BOOL, LPVOID, DWORD, LPVOID, LPDWORD]
    
    _DeviceIoControl = kernel32.DeviceIoControl
    _DeviceIoControl.restype = BOOL
    _DeviceIoControl.argtypes = [HANDLE, DWORD, LPVOID, DWORD, LPVOID, DWORD, LPDWORD, LPVOID]
    
    def DeviceIoControl(hDevice, dwCtrlCode, lpIn, szIn, lpOut, szOut, lpOverlapped=None):
        """
        Wrapper around the real DeviceIoControl to return a tuple containing a bool indicating
        success, and a number containing the size of the bytes returned. (Also, lpOverlapped to
        default to NULL) """
        dwRet = DWORD(0)
        return bool(
            _DeviceIoControl(hDevice, dwCtrlCode, lpIn, szIn, lpOut, szOut, byref(dwRet), lpOverlapped)
        ), dwRet.value
    
    def obtain_privileges(privileges):
        """
        Given a list of SE privilege names (eg: [ SE_CREATE_TOKEN_NAME, SE_BACKUP_NAME ]), lookup
        the privilege values for each and then attempt to acquire them for the current process.
        """
        global _obtained_privileges
        privileges = filter(lambda priv: priv not in _obtained_privileges, list(set(privileges)))
        privcount = len(privileges)
        if privcount == 0: return
    
        class TOKEN_PRIVILEGES(ctypes.Structure):
            # noinspection PyTypeChecker
            _fields_ = [
                ('PrivilegeCount', DWORD),
                ('Privileges', LUID_AND_ATTRIBUTES * privcount),
            ]
    
        with HANDLE() as hToken:
            tp = TOKEN_PRIVILEGES()
            tp.PrivilegeCount = privcount
            hProcess = GetCurrentProcess()
            if not OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, byref(hToken)):
                raise WinError()
    
            for i, privilege in enumerate(privileges):
                tp.Privileges[i].Attributes = SE_PRIVILEGE_ENABLED
                if not LookupPrivilegeValue(None, privilege, byref(tp.Privileges[i])):
                    raise Exception('LookupPrivilegeValue failed for privilege: {0}'.format(privilege))
    
            if not AdjustTokenPrivileges(hToken, False, byref(tp), sizeof(TOKEN_PRIVILEGES), None, None):
                raise WinError()
    
            _obtained_privileges.extend(privileges)
    
    def open_file(filepath, flags=FILE_FLAG_OPEN_REPARSE_POINT, autoclose=False):
        """ Open file for read & write, acquiring the SE_BACKUP & SE_RESTORE privileges. """
        obtain_privileges([SE_BACKUP_NAME, SE_RESTORE_NAME])
        if (flags & FILE_FLAG_BACKUP_SEMANTICS) != FILE_FLAG_BACKUP_SEMANTICS:
            flags |= FILE_FLAG_BACKUP_SEMANTICS
        hFile = CreateFile(filepath, GENERIC_RW, FILE_SHARE_ALL, NULL, OPEN_EXISTING, flags, HANDLE.NULL)
        if not hFile: raise WinError()
        if autoclose: hFile.autoclose = True
        return hFile
    
    def get_buffer(filepath, hFile=HANDLE.INVALID):
        """ Get a reparse point buffer. """
        if not hFile:
            hFile = open_file(filepath, autoclose=True)
        
        obj = ReparsePoint()
        result, dwRet = DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, None, 0L, byref(obj), MAX_REPARSE_BUFFER)
        return obj if result else None
    
    def delete_reparse_point(filepath):
        """ Remove the reparse point folder at filepath. """
        dwRet = 0
        with open_file(filepath) as hFile:
            # Try to delete it first without the reparse GUID
            info = ReparsePoint()
            info.ReparseTag = 0
            result, dwRet = DeviceIoControl(hFile, FSCTL_DELETE_REPARSE_POINT, byref(info),
                REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, None, 0L)
    
            if not result:
                # If the first try fails, we'll set the GUID and try again
                buffer = get_buffer(filepath, hFile)
                info.ReparseTag = buffer.ReparseTag
                info.ReparseGuid = info.ReparseGuid
                result, dwRet = DeviceIoControl(hFile, FSCTL_DELETE_REPARSE_POINT, byref(info),
                    REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, None, 0L)
                if not result: raise WinError()
        
        if not RemoveDirectory(filepath):
            raise WinError()
        
        return dwRet
    
    def is_reparse_point(filepath):
        """ Check whether or not filepath refers to a reparse point. """
        return hasflag(GetFileAttributes(filepath), FILE_ATTRIBUTE_REPARSE_POINT)
    
    def rmtree(filepath, ignore_errors=False, onerror=None):
        """
        Re-implementation of shutil.rmtree that checks for reparse points
        (junctions/symbolic links) before iterating folders.
        """
        
        def rm(fn, childpath):
            try:
                fn(childpath)
            except:
                if not ignore_errors:
                    if onerror is None:
                        raise
                    else:
                        onerror(fn, childpath, sys.exc_info()[0])
        
        def visit_files(root, targets):
            for target in targets:
                rm(os.unlink, os.path.join(root, target))
        
        def visit_dirs(root, targets):
            for target in targets:
                childpath = os.path.join(root, target)
                rmtree(childpath, ignore_errors, onerror)
        
        if is_reparse_point(filepath):
            rm(delete_reparse_point, filepath)
            return
        
        for root, dirs, files in os.walk(filepath):
            visit_files(root, files)
            visit_dirs(root, dirs)
        
        rm(os.rmdir, filepath)
    
    """
    Here's the original declaration used for the ReparsePoint class, just in case
    someone is looking to try reading/writing from/to reparse points.
    
    import math as _math
    
    # Maximum buffer sizes
    MAX_GENERIC_REPARSE_BUFFER = MAX_REPARSE_BUFFER - REPARSE_GUID_DATA_BUFFER_HEADER_SIZE
    MAX_MOUNTPOINT_REPARSE_BUFFER = MAX_GENERIC_REPARSE_BUFFER - (sizeof(WORD) * 4)
    MAX_SYMLINK_REPARSE_BUFFER = MAX_MOUNTPOINT_REPARSE_BUFFER - sizeof(DWORD)
    
    # Need to factor in the size of wide characters for symlinks and mountpoint buffers.
    _WCHAR_SIZE = ceil(sizeof(WCHAR))
    _WCHAR_COUNT = lambda bufsize: int(_math.ceil( float(bufsize) / _WCHAR_SIZE ))
    
    MAX_MOUNTPOINT_BUFFER_COUNT = _WCHAR_COUNT(MAX_SYMLINK_REPARSE_BUFFER)
    MAX_SYMLINK_BUFFER_COUNT = _WCHAR_COUNT(MAX_SYMLINK_REPARSE_BUFFER)
    
    del _WCHAR_SIZE, _WCHAR_COUNT
    
    class ReparsePointBuffer(ctypes.Union):
        class SymbolicLinkBuffer(ctypes.Structure):
            _fields_ = [
                ('SubstituteNameOffset', WORD),
                ('SubstituteNameLength', WORD),
                ('PrintNameOffset', WORD),
                ('PrintNameLength', WORD),
                ('Flags', DWORD),
                ('PathBuffer', WCHAR * MAX_SYMLINK_BUFFER_COUNT)
            ]
        
        class MountPointBuffer(ctypes.Structure):
            _fields_ = [
                ('SubstituteNameOffset', WORD),
                ('SubstituteNameLength', WORD),
                ('PrintNameOffset', WORD),
                ('PrintNameLength', WORD),
                ('PathBuffer', WCHAR * MAX_MOUNTPOINT_BUFFER_COUNT)
            ]
        
        class GenericReparseBuffer(ctypes.Structure):
            _fields_ = [('PathBuffer', UCHAR * MAX_GENERIC_REPARSE_BUFFER)]
    
        _fields_ = [
            ('SymbolicLink', SymbolicLinkBuffer),
            ('MountPoint', MountPointBuffer),
            ('Generic', GenericReparseBuffer)
        ]
    
    class ReparsePoint(ctypes.Structure):
        _fields_ = [
            ('ReparseTag', DWORD),
            ('ReparseDataLength', WORD),
            ('Reserved', WORD),
            ('ReparseGuid', GUID),
            ('_Buffer', ReparsePointBuffer)
        ]
        
        @property
        def Buffer(self):
            if self.ReparseTag == IO_REPARSE_TAG_MOUNT_POINT:
                return self._Buffer.MountPoint
            elif self.ReparseTag == IO_REPARSE_TAG_SYMBOLIC_LINK:
                return self._Buffer.SymbolicLink
            else:
                return self._Buffer
    """
    

    public by panshulgupta  2187  2  5  0

    Java Queue

    Using queues to iterate over a collection which can add elements during iteration of the collection
    Queue<Integer> queue = new LinkedList<Integer>();
    queue.add(1);
    queue.add(2);
    queue.add(3);
    queue.add(4);
    
    while (!queue.isEmpty()) {
        Integer i = queue.remove();
        if (i == 2)
            queue.add(42);
    
        System.out.println(i);
    }
    • Public Snippets
    • Channels Snippets